vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 167 ++++++++------------------ 1 file changed, 57 insertions(+), 110 deletions(-)
New commits: commit 3a06fbc0418e04eab2bcfcc47ffc7d04faf6dac9 Author: Cosimo Cecchi <cosi...@gnome.org> Date: Fri Jul 27 14:38:58 2012 +0100 gtk3: remove obsolete forced background rendering Change-Id: I3fabfcee9166d2b32dbadaedba6d364ae1a7559e diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index b948ac7..64dc0bc 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -765,8 +765,6 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart GtkShadowType shadow; gint renderType = RENDER_BACKGROUND_AND_FRAME; GtkStyleContext *context = NULL; - GtkStyleContext *additionalContext = NULL; - bool renderWindowBackground = true; const gchar *styleClass = NULL; NWConvertVCLStateToGTKState(nState, &flags, &shadow); @@ -808,24 +806,20 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart styleClass = GTK_STYLE_CLASS_CHECK; context = mpMenuItemStyle; renderType = RENDER_CHECK; - renderWindowBackground = false; break; case PART_MENU_ITEM_RADIO_MARK: styleClass = GTK_STYLE_CLASS_RADIO; context = mpMenuItemStyle; renderType = RENDER_RADIO; - renderWindowBackground = false; break; case PART_MENU_SEPARATOR: styleClass = GTK_STYLE_CLASS_SEPARATOR; context = mpMenuItemStyle; renderType = RENDER_LINE; - additionalContext = mpMenuStyle; break; case PART_MENU_SUBMENU_ARROW: context = mpMenuStyle; renderType = RENDER_ARROW; - renderWindowBackground = false; break; } break; @@ -840,7 +834,6 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart flags = (GtkStateFlags)(flags | ( (aValue.getTristateVal() == BUTTONVALUE_ON) ? GTK_STATE_FLAG_ACTIVE : GTK_STATE_FLAG_NORMAL)); context = mpToolButtonStyle; - additionalContext = mpToolbarStyle; break; default: return sal_False; @@ -852,7 +845,6 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart context = mpCheckButtonStyle; styleClass = GTK_STYLE_CLASS_CHECK; renderType = RENDER_CHECK; - renderWindowBackground = false; break; case CTRL_RADIOBUTTON: flags = (GtkStateFlags)(flags | @@ -860,7 +852,6 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart context = mpCheckButtonStyle; styleClass = GTK_STYLE_CLASS_RADIO; renderType = RENDER_RADIO; - renderWindowBackground = false; break; case CTRL_PUSHBUTTON: context = mpButtonStyle; @@ -872,7 +863,6 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart case PART_DRAW_BACKGROUND_HORZ: context = mpScrollbarStyle; renderType = RENDER_SCROLLBAR; - renderWindowBackground = false; break; } break; @@ -885,22 +875,7 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, translatedRegion.width, translatedRegion.height); cairo_t *cr = cairo_create(surface); - cairo_surface_destroy(surface); - - if (!additionalContext && renderWindowBackground) - additionalContext = gtk_widget_get_style_context(mpWindow); - - if (additionalContext) - { - gtk_style_context_save(additionalContext); - gtk_style_context_set_state(additionalContext, flags); - - gtk_render_background(additionalContext, cr, - 0, 0, - translatedRegion.width, translatedRegion.height); - - gtk_style_context_restore(additionalContext); - } + cairo_surface_destroy(surface); // unref gtk_style_context_save(context); gtk_style_context_set_state(context, flags); @@ -957,7 +932,7 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart gtk_style_context_restore(context); renderAreaToPix(cr, &translatedRegion); - cairo_destroy(cr); + cairo_destroy(cr); // unref return sal_True; } commit 032a695332c6ec1359290a5fc49d30d397b1c245 Author: Cosimo Cecchi <cosi...@gnome.org> Date: Thu May 10 23:00:19 2012 -0400 gtk3: fix colors for menubar and menu items Change-Id: Iea44b34fbfc189c21267e095860c3bab3217bcfb diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index 11bf0c8..b948ac7 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -825,7 +825,7 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart case PART_MENU_SUBMENU_ARROW: context = mpMenuStyle; renderType = RENDER_ARROW; - additionalContext = mpMenuStyle; + renderWindowBackground = false; break; } break; @@ -1206,7 +1206,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) aStyleSet.SetMenuBarTextColor( aTextColor ); // menu items - gtk_style_context_get_color( mpMenuItemStyle, GTK_STATE_FLAG_NORMAL, &color ); + gtk_style_context_get_color( mpMenuStyle, GTK_STATE_FLAG_NORMAL, &color ); aTextColor = getColor( color ); aStyleSet.SetMenuTextColor( aTextColor ); @@ -1521,6 +1521,7 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) /* Menu bar */ getStyleContext(&mpMenuBarStyle, gtk_menu_bar_new()); + gtk_style_context_add_class(mpMenuBarStyle, GTK_STYLE_CLASS_MENU); /* Menu items in a menu bar */ path = gtk_widget_path_new(); commit b2e5a674c41d892471636209ff39ffe3533f46e4 Author: Cosimo Cecchi <cosi...@gnome.org> Date: Thu May 10 22:54:56 2012 -0400 gtk3: simplify code Change-Id: Iad78f62bedb93c456830b2133b67e081ab035b5e diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index e5bd3d0..11bf0c8 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -1013,29 +1013,22 @@ sal_Bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart Rectangle aEditRect = rControlRegion; gint indicator_size, point; - if( nPart == PART_ENTIRE_CONTROL) + if(((nType == CTRL_CHECKBOX) || (nType == CTRL_RADIOBUTTON)) && + nPart == PART_ENTIRE_CONTROL) { - switch(nType) - { - case CTRL_CHECKBOX: - case CTRL_RADIOBUTTON: - gtk_style_context_get_style( mpCheckButtonStyle, - "indicator-size", &indicator_size, - (char *)NULL ); + gtk_style_context_get_style( mpCheckButtonStyle, + "indicator-size", &indicator_size, + (char *)NULL ); - point = MAX(0, rControlRegion.GetHeight() - indicator_size); - aEditRect = Rectangle( Point( 0, point / 2), - Size( indicator_size, indicator_size ) ); - break; - default: - return sal_False; - } + point = MAX(0, rControlRegion.GetHeight() - indicator_size); + aEditRect = Rectangle( Point( 0, point / 2), + Size( indicator_size, indicator_size ) ); } - else if( (nPart == PART_MENU_ITEM_CHECK_MARK) || - (nPart == PART_MENU_ITEM_RADIO_MARK) ) { - switch (nType) + else if( nType == CTRL_MENU_POPUP) + { + if (((nPart == PART_MENU_ITEM_CHECK_MARK) || + (nPart == PART_MENU_ITEM_RADIO_MARK) )) { - case CTRL_MENU_POPUP: indicator_size = 0; gtk_style_context_get_style( mpMenuItemStyle, @@ -1046,12 +1039,8 @@ sal_Bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart aEditRect = Rectangle( Point( 0, point / 2), Size( indicator_size, indicator_size ) ); } - } - else if (nPart == PART_MENU_SEPARATOR) - { - switch (nType) + else if (nPart == PART_MENU_SEPARATOR) { - case CTRL_MENU_POPUP: gint separator_height, separator_width, wide_separators; gtk_style_context_get_style (mpMenuItemStyle, @@ -1063,12 +1052,8 @@ sal_Bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart aEditRect = Rectangle( aEditRect.TopLeft(), Size( aEditRect.GetWidth(), wide_separators ? separator_height : 1 ) ); } - } - else if (nPart == PART_MENU_SUBMENU_ARROW) - { - switch (nType) + else if (nPart == PART_MENU_SUBMENU_ARROW) { - case CTRL_MENU_POPUP: gfloat arrow_scaling, arrow_size; arrow_scaling = 0; commit 2f874b85b2374f9d609db44ba03210812c8fb405 Author: Cosimo Cecchi <cosi...@gnome.org> Date: Thu May 10 20:50:36 2012 -0400 gtk3: fix tooltip colors Change-Id: Iacd8578ee71c5e0403c3398cb1f8d427be27d603 diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index 73e9e5d..e5bd3d0 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -1153,18 +1153,6 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) aStyleSet.SetButtonRolloverTextColor( aTextColor ); aStyleSet.SetFieldRolloverTextColor( aTextColor ); - // FIXME: each gtk3 theme needs to define a set of well-known - // color names for LibreOffice eg. - // @define-color tooltip_bg_color #343434; - GdkRGBA tooltip_bg_color; - if( gtk_style_context_lookup_color( pStyle, "tooltip_bg_color", &tooltip_bg_color ) ) - { - aStyleSet.SetHelpTextColor( getColor( tooltip_bg_color ) ); - fprintf (stderr, "Set tooltip bg color %g %g %g %g\n", - tooltip_bg_color.red, tooltip_bg_color.green, - tooltip_bg_color.blue, tooltip_bg_color.alpha ); - } - // background colors GdkRGBA background_color; gtk_style_context_get_background_color(pStyle, GTK_STATE_FLAG_NORMAL, &background_color); @@ -1176,6 +1164,25 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) aStyleSet.SetWorkspaceColor( aBackColor ); aStyleSet.SetCheckedColorSpecialCase( ); + // highlighting colors + gtk_style_context_get_background_color(pStyle, GTK_STATE_FLAG_SELECTED, &text_color); + ::Color aHighlightColor = getColor( text_color ); + gtk_style_context_get_color(pStyle, GTK_STATE_FLAG_SELECTED, &text_color); + ::Color aHighlightTextColor = getColor( text_color ); + aStyleSet.SetHighlightColor( aHighlightColor ); + aStyleSet.SetHighlightTextColor( aHighlightTextColor ); + + // tooltip colors + GdkRGBA tooltip_bg_color, tooltip_fg_color; + gtk_style_context_save (pStyle); + gtk_style_context_add_class (pStyle, GTK_STYLE_CLASS_TOOLTIP); + gtk_style_context_get_color (pStyle, GTK_STATE_FLAG_NORMAL, &tooltip_fg_color); + gtk_style_context_get_background_color (pStyle, GTK_STATE_FLAG_NORMAL, &tooltip_bg_color); + gtk_style_context_restore (pStyle); + + aStyleSet.SetHelpColor( getColor( tooltip_bg_color )); + aStyleSet.SetHelpTextColor( getColor( tooltip_fg_color )); + { // FIXME: turn me into a helper function ... // construct style context for text view GtkStyleContext *pCStyle = gtk_style_context_new(); @@ -1195,14 +1202,6 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) aStyleSet.SetWindowColor( aBackFieldColor ); } - // highlighting colors - gtk_style_context_get_background_color(pStyle, GTK_STATE_FLAG_SELECTED, &text_color); - ::Color aHighlightColor = getColor( text_color ); - gtk_style_context_get_color(pStyle, GTK_STATE_FLAG_SELECTED, &text_color); - ::Color aHighlightTextColor = getColor( text_color ); - aStyleSet.SetHighlightColor( aHighlightColor ); - aStyleSet.SetHighlightTextColor( aHighlightTextColor ); - // menu disabled entries handling aStyleSet.SetSkipDisabledInMenus( sal_True ); aStyleSet.SetAcceleratorsInContextMenus( sal_False ); commit 6fbbea7dca8b3f1a5f794191ea42cc12b990cc9c Author: Cosimo Cecchi <cosi...@gnome.org> Date: Thu May 10 20:39:28 2012 -0400 gtk3: fix rendering for scrollbars Change-Id: Ibcdc3b73b845954817f08a3f50900d96a25a8e3d diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index 726821d..73e9e5d 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -284,9 +284,6 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, gint stepper_spacing = 0; gint trough_border = 0; gint min_slider_length = 0; - gint vShim = 0; - gint hShim = 0; - gint x,y,w,h; // make controlvalue rectangles relative to area thumbRect.Move( -rControlRectangle.Left(), -rControlRectangle.Top() ); @@ -322,17 +319,15 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, "has-secondary-backward-stepper", &has_backward2, (char *)NULL ); gint magic = trough_border ? 1 : 0; gint nFirst = 0; + gint slider_side = slider_width + (trough_border * 2); if ( has_backward ) nFirst += 1; if ( has_forward2 ) nFirst += 1; if ( nPart == PART_DRAW_BACKGROUND_HORZ ) { - unsigned int sliderHeight = slider_width + (trough_border * 2); - vShim = (scrollbarRect.GetHeight() - sliderHeight) / 2; - - scrollbarRect.Move( 0, vShim ); - scrollbarRect.SetSize( Size( scrollbarRect.GetWidth(), sliderHeight ) ); + scrollbarRect.Move( 0, (scrollbarRect.GetHeight() - slider_side) / 2 ); + scrollbarRect.SetSize( Size( scrollbarRect.GetWidth(), slider_side ) ); scrollbarOrientation = GTK_ORIENTATION_HORIZONTAL; arrow1Angle = G_PI * 3 / 2; @@ -371,11 +366,8 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, } else { - unsigned int sliderWidth = slider_width + (trough_border * 2); - hShim = (scrollbarRect.GetWidth() - sliderWidth) / 2; - - scrollbarRect.Move( hShim, 0 ); - scrollbarRect.SetSize( Size( sliderWidth, scrollbarRect.GetHeight() ) ); + scrollbarRect.Move( (scrollbarRect.GetWidth() - slider_side) / 2, 0 ); + scrollbarRect.SetSize( Size( slider_side, scrollbarRect.GetHeight() ) ); scrollbarOrientation = GTK_ORIENTATION_VERTICAL; arrow1Angle = 0; @@ -411,18 +403,13 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, } sal_Bool has_slider = ( thumbRect.GetWidth() > 0 && thumbRect.GetHeight() > 0 ); - x = y = 0; - w = scrollbarRect.GetWidth(); - h = scrollbarRect.GetHeight(); // ----------------- TROUGH - gtk_render_background(context, cr, x, y, w, h); - gtk_style_context_save(context); gtk_style_context_add_class(context, GTK_STYLE_CLASS_TROUGH); - gtk_render_background(context, cr, x, y, + gtk_render_background(context, cr, 0, 0, scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); - gtk_render_frame(context, cr, x, y, + gtk_render_frame(context, cr, 0, 0, scrollbarRect.GetWidth(), scrollbarRect.GetHeight() ); gtk_style_context_restore(context); @@ -439,7 +426,7 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, gtk_style_context_add_class(context, GTK_STYLE_CLASS_SLIDER); gtk_render_slider(context, cr, - x+hShim+thumbRect.Left(), y+vShim+thumbRect.Top(), + thumbRect.Left(), thumbRect.Top(), thumbRect.GetWidth(), thumbRect.GetHeight(), scrollbarOrientation); gtk_style_context_restore(context); @@ -454,17 +441,17 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON); gtk_render_background(context, cr, - x+hShim+button11BoundRect.Left(), y+vShim+button11BoundRect.Top(), + button11BoundRect.Left(), button11BoundRect.Top(), button11BoundRect.GetWidth(), button11BoundRect.GetHeight() ); gtk_render_frame(context, cr, - x+hShim+button11BoundRect.Left(), y+vShim+button11BoundRect.Top(), + button11BoundRect.Left(), button11BoundRect.Top(), button11BoundRect.GetWidth(), button11BoundRect.GetHeight() ); // ----------------- ARROW 1 NWCalcArrowRect( button11BoundRect, arrowRect ); gtk_render_arrow(context, cr, arrow1Angle, - x+hShim+arrowRect.Left(), y+vShim+arrowRect.Top(), + arrowRect.Left(), arrowRect.Top(), MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); gtk_style_context_restore(context); @@ -478,17 +465,17 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON); gtk_render_background(context, cr, - x+hShim+button12BoundRect.Left(), y+vShim+button12BoundRect.Top(), + button12BoundRect.Left(), button12BoundRect.Top(), button12BoundRect.GetWidth(), button12BoundRect.GetHeight() ); gtk_render_frame(context, cr, - x+hShim+button12BoundRect.Left(), y+vShim+button12BoundRect.Top(), + button12BoundRect.Left(), button12BoundRect.Top(), button12BoundRect.GetWidth(), button12BoundRect.GetHeight() ); // ----------------- ARROW 1 NWCalcArrowRect( button12BoundRect, arrowRect ); gtk_render_arrow(context, cr, arrow2Angle, - x+hShim+arrowRect.Left(), y+vShim+arrowRect.Top(), + arrowRect.Left(), arrowRect.Top(), MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); gtk_style_context_restore(context); @@ -503,17 +490,17 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON); gtk_render_background(context, cr, - x+hShim+button21BoundRect.Left(), y+vShim+button21BoundRect.Top(), + button21BoundRect.Left(), button21BoundRect.Top(), button21BoundRect.GetWidth(), button21BoundRect.GetHeight() ); gtk_render_frame(context, cr, - x+hShim+button21BoundRect.Left(), y+vShim+button21BoundRect.Top(), + button21BoundRect.Left(), button21BoundRect.Top(), button21BoundRect.GetWidth(), button21BoundRect.GetHeight() ); // ----------------- ARROW 2 NWCalcArrowRect( button21BoundRect, arrowRect ); gtk_render_arrow(context, cr, arrow1Angle, - x+hShim+arrowRect.Left(), y+vShim+arrowRect.Top(), + arrowRect.Left(), arrowRect.Top(), MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); gtk_style_context_restore(context); @@ -527,17 +514,17 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON); gtk_render_background(context, cr, - x+hShim+button22BoundRect.Left(), y+vShim+button22BoundRect.Top(), + button22BoundRect.Left(), button22BoundRect.Top(), button22BoundRect.GetWidth(), button22BoundRect.GetHeight() ); gtk_render_frame(context, cr, - x+hShim+button22BoundRect.Left(), y+vShim+button22BoundRect.Top(), + button22BoundRect.Left(), button22BoundRect.Top(), button22BoundRect.GetWidth(), button22BoundRect.GetHeight() ); // ----------------- ARROW 2 NWCalcArrowRect( button22BoundRect, arrowRect ); gtk_render_arrow(context, cr, arrow2Angle, - x+hShim+arrowRect.Left(), y+vShim+arrowRect.Top(), + arrowRect.Left(), arrowRect.Top(), MIN(arrowRect.GetWidth(), arrowRect.GetHeight()) ); gtk_style_context_restore(context); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits