From 41f30faca1b202da59a233f0556fc9580586f893 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 4 May 2016 10:10:42 +0200 Subject: Fix rendering of tool bar icons. (bzr r14869.1.2) --- src/widgets/button.cpp | 16 ++++++++++------ src/widgets/icon.cpp | 8 ++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 54f073c01..6ea8c1360 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -106,11 +106,13 @@ static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkBorder padding; + GtkBorder border; - gtk_style_context_get_border(context, static_cast(0), &padding); + gtk_style_context_get_padding(context, GTK_STATE_FLAG_NORMAL, &padding); + gtk_style_context_get_border( context, GTK_STATE_FLAG_NORMAL, &border ); - *minimal_width += 2 + 2 * MAX(2, padding.left + padding.right); - *natural_width += 2 + 2 * MAX(2, padding.left + padding.right); + *minimal_width += MAX(2, padding.left + padding.right + border.left + border.right); + *natural_width += MAX(2, padding.left + padding.right + border.left + border.right); } static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height) @@ -126,11 +128,13 @@ static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_heig GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkBorder padding; + GtkBorder border; - gtk_style_context_get_border(context, static_cast(0), &padding); + gtk_style_context_get_padding(context, GTK_STATE_FLAG_NORMAL, &padding); + gtk_style_context_get_border( context, GTK_STATE_FLAG_NORMAL, &border ); - *minimal_height += 2 + 2 * MAX(2, padding.top + padding.bottom); - *natural_height += 2 + 2 * MAX(2, padding.top + padding.bottom); + *minimal_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom); + *natural_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom); } #else static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition) diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 5acdc613c..f2031fe51 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -235,7 +235,6 @@ void IconImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation) // GTK3 Only, Doesn't actually seem to be used. gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) { - std::cout << "IconImpl::draw: Entrance" << std::endl; SPIcon *icon = SP_ICON(widget); if ( !icon->pb ) { fetchPixbuf( icon ); @@ -249,7 +248,7 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) if (gtk_widget_get_state_flags (GTK_WIDGET(icon)) != GTK_STATE_FLAG_NORMAL && image) { #else if (gtk_widget_get_state (GTK_WIDGET(icon)) != GTK_STATE_NORMAL && image) { - std::cout << "IconImpl::draw: Ooops! It is called in GTK2" << std::endl; + std::cerr << "IconImpl::draw: Ooops! It is called in GTK2" << std::endl; #endif std::cerr << "IconImpl::draw: No image, creating fallback" << std::endl; @@ -805,6 +804,10 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name ) GtkWidget *widget = NULL; gint trySize = CLAMP( static_cast(lsize), 0, static_cast(G_N_ELEMENTS(iconSizeLookup) - 1) ); + if (trySize != lsize ) { + std::cerr << "GtkWidget *IconImple::newFull(): lsize != trySize: lsize: " << lsize + << " try Size: " << trySize << " " << (name?name:"NULL") << std::endl; + } if ( !sizeMapDone ) { injectCustomSize(); } @@ -832,6 +835,7 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name ) if ( Inkscape::Preferences::get()->getBool("/options/iconrender/named_nodelay") ) { int psize = getPhysSize(lsize); + // std::cout << " name: " << name << " size: " << psize << std::endl; prerenderIcon(name, mappedSize, psize); } else { addPreRender( mappedSize, name ); -- cgit v1.2.3