vcl/inc/unx/gtk/gtkgdi.hxx | 3 ++ vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 40 +++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-)
New commits: commit 4cb720836ab03701ce508e302790c115c7808619 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Oct 14 10:34:27 2016 +0100 Related: tdf#101699 gtk3: get correct arrow width Change-Id: If02c598306ec6f19cf83958c4a176cafa67076dc diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index fa6a064..3f21579 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -680,7 +680,6 @@ void GtkSalGraphics::PaintSpinButton(GtkStyleContext *context, cairo_translate(cr, rControlRectangle.Left(), rControlRectangle.Top()); } -#define ARROW_SIZE 11 * 0.85 Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlType nType, ControlPart nPart, Rectangle aAreaRect ) @@ -692,7 +691,11 @@ Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlType nType, GtkBorder padding; gtk_style_context_get_padding( mpButtonStyle, gtk_style_context_get_state(mpButtonStyle), &padding); - gint nArrowWidth = ARROW_SIZE; + gint nArrowWidth; + gtk_style_context_get(mpComboboxButtonArrowStyle, + gtk_style_context_get_state(mpComboboxButtonArrowStyle), + "min-width", &nArrowWidth, NULL); + gint nButtonWidth = nArrowWidth + padding.left + padding.right; if( nPart == ControlPart::ButtonDown ) { commit 6e8dbdbe1a9d15d7e7d000e4132fd5df3fecd660 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Oct 14 10:30:32 2016 +0100 Related: tdf#101699 gtk3: get correct combobox and listbox arrows Change-Id: Ib2322bfda09b05925c74d93a530b9ed9fac73032 diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx index cd369e5..802dd9a 100644 --- a/vcl/inc/unx/gtk/gtkgdi.hxx +++ b/vcl/inc/unx/gtk/gtkgdi.hxx @@ -40,6 +40,7 @@ enum class GtkControlPart RadioButton, RadioButtonRadio, Entry, + Arrow, SpinButton, SpinButtonUpButton, SpinButtonDownButton, @@ -131,8 +132,10 @@ private: static GtkStyleContext *mpSeparatorMenuItemStyle; static GtkStyleContext *mpComboboxStyle; static GtkStyleContext *mpComboboxButtonStyle; + static GtkStyleContext *mpComboboxButtonArrowStyle; static GtkStyleContext *mpListboxStyle; static GtkStyleContext *mpListboxButtonStyle; + static GtkStyleContext *mpListboxButtonArrowStyle; static GtkStyleContext *mpFrameInStyle; static GtkStyleContext *mpFrameOutStyle; static GtkStyleContext *mpFixedHoriLineStyle; diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index b904dfc..fa6a064 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -53,8 +53,10 @@ GtkStyleContext* GtkSalGraphics::mpSpinUpStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpSpinDownStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpComboboxStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpComboboxButtonStyle = nullptr; +GtkStyleContext* GtkSalGraphics::mpComboboxButtonArrowStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpListboxStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpListboxButtonStyle = nullptr; +GtkStyleContext* GtkSalGraphics::mpListboxButtonArrowStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpFrameInStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpFrameOutStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpFixedHoriLineStyle = nullptr; @@ -744,8 +746,21 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, if (AllSettings::GetLayoutRTL()) aEditBoxRect.SetPos( Point( areaRect.Left() + buttonRect.GetWidth(), areaRect.Top() ) ); - arrowRect.SetSize( Size( (gint)(ARROW_SIZE), - (gint)(ARROW_SIZE) ) ); + gint arrow_width, arrow_height; + if (nType == ControlType::Combobox) + { + gtk_style_context_get(mpComboboxButtonArrowStyle, + gtk_style_context_get_state(mpComboboxButtonArrowStyle), + "min-width", &arrow_width, "min-height", &arrow_height, NULL); + } + else if (nType == ControlType::Listbox) + { + gtk_style_context_get(mpListboxButtonArrowStyle, + gtk_style_context_get_state(mpListboxButtonArrowStyle), + "min-width", &arrow_width, "min-height", &arrow_height, NULL); + } + + arrowRect.SetSize(Size(arrow_width, arrow_height)); arrowRect.SetPos( Point( buttonRect.Left() + (gint)((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2), buttonRect.Top() + (gint)((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) ); @@ -790,7 +805,7 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, (buttonRect.Top() - areaRect.Top()), buttonRect.GetWidth(), buttonRect.GetHeight() ); - gtk_render_arrow(mpComboboxStyle, cr, + gtk_render_arrow(mpComboboxButtonArrowStyle, cr, G_PI, (arrowRect.Left() - areaRect.Left()), (arrowRect.Top() - areaRect.Top()), arrowRect.GetWidth() ); @@ -825,7 +840,7 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, 0, 0, areaRect.GetWidth(), areaRect.GetHeight()); - gtk_render_arrow(mpListboxStyle, cr, + gtk_render_arrow(mpListboxButtonArrowStyle, cr, G_PI, (arrowRect.Left() - areaRect.Left()), (arrowRect.Top() - areaRect.Top()), arrowRect.GetWidth() ); @@ -889,6 +904,14 @@ static GtkStyleContext* createStyleContext(GtkControlPart ePart, GtkStyleContext gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_RADIO); #endif break; + case GtkControlPart::Arrow: + gtk_widget_path_append_type(path, GTK_TYPE_BUTTON); +#if GTK_CHECK_VERSION(3, 19, 2) + gtk_widget_path_iter_set_object_name(path, -1, "arrow"); +#else + gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_BUTTON); +#endif + break; case GtkControlPart::Entry: gtk_widget_path_append_type(path, GTK_TYPE_ENTRY); #if GTK_CHECK_VERSION(3, 19, 2) @@ -2437,12 +2460,14 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) gComboBox = gtk_combo_box_text_new_with_entry(); getStyleContext(&mpComboboxStyle, gComboBox); mpComboboxButtonStyle = createStyleContext(GtkControlPart::Button, mpComboboxStyle); + mpComboboxButtonArrowStyle = createStyleContext(GtkControlPart::Arrow, mpComboboxButtonStyle); /* Listbox */ gListBox = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gListBox), "sample"); getStyleContext(&mpListboxStyle, gListBox); mpListboxButtonStyle = createStyleContext(GtkControlPart::Button, mpListboxStyle); + mpListboxButtonArrowStyle = createStyleContext(GtkControlPart::Arrow, mpListboxButtonStyle); /* Frames */ mpFrameOutStyle = mpFrameInStyle = createStyleContext(GtkControlPart::FrameBorder);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits