diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-11-17 12:34:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-11-17 15:32:04 +0000 |
commit | 4579c43861635dda15158478404aa90151228e91 (patch) | |
tree | 3e2975405f839de8bc5762c46836145419e3382a | |
parent | 972c1e9e7239ef84611b01dad5b112af8f353d3c (diff) |
gtk3: spinbuttons under Ambiance don't look beautiful enough
lets draw the frame after the sub-contents are done, and
use a dedicated entry child
Change-Id: I7db1ac56e5cfb1a46ddd2fb56c5e95deaa83a95d
-rw-r--r-- | vcl/inc/unx/gtk/gtkgdi.hxx | 4 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 30 |
2 files changed, 26 insertions, 8 deletions
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx index 514c71d1a9b7..e7169e95c20b 100644 --- a/vcl/inc/unx/gtk/gtkgdi.hxx +++ b/vcl/inc/unx/gtk/gtkgdi.hxx @@ -53,6 +53,7 @@ enum class GtkControlPart ListboxBoxButtonBox, ListboxBoxButtonBoxArrow, SpinButton, + SpinButtonEntry, SpinButtonUpButton, SpinButtonDownButton, ScrollbarVertical, @@ -151,6 +152,7 @@ private: static GtkStyleContext *mpRadioButtonStyle; static GtkStyleContext *mpRadioButtonRadioStyle; static GtkStyleContext *mpSpinStyle; + static GtkStyleContext *mpSpinEntryStyle; static GtkStyleContext *mpSpinUpStyle; static GtkStyleContext *mpSpinDownStyle; static GtkStyleContext *mpComboboxStyle; @@ -210,7 +212,7 @@ private: ControlPart nPart, Rectangle aAreaRect, ControlState nState ); - void PaintSpinButton(GtkStyleContext *context, + void PaintSpinButton(GtkStateFlags flags, cairo_t *cr, const Rectangle& rControlRectangle, ControlType nType, diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index 86e039cca0aa..4a957bb5ab8c 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -46,6 +46,7 @@ GtkStyleContext* GtkSalGraphics::mpCheckButtonCheckStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpRadioButtonStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpRadioButtonRadioStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpSpinStyle = nullptr; +GtkStyleContext* GtkSalGraphics::mpSpinEntryStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpSpinUpStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpSpinDownStyle = nullptr; GtkStyleContext* GtkSalGraphics::mpComboboxStyle = nullptr; @@ -711,7 +712,7 @@ void GtkSalGraphics::PaintOneSpinButton( GtkStyleContext *context, g_object_unref(pixbuf); } -void GtkSalGraphics::PaintSpinButton(GtkStyleContext *context, +void GtkSalGraphics::PaintSpinButton(GtkStateFlags flags, cairo_t *cr, const Rectangle& rControlRectangle, ControlType nType, @@ -735,18 +736,24 @@ void GtkSalGraphics::PaintSpinButton(GtkStyleContext *context, if (nPart == ControlPart::Entire) { - gtk_render_background(context, cr, + gtk_style_context_set_state(mpSpinStyle, flags); + + gtk_render_background(mpSpinStyle, cr, 0, 0, rControlRectangle.GetWidth(), rControlRectangle.GetHeight() ); - gtk_render_frame(context, cr, - 0, 0, - rControlRectangle.GetWidth(), rControlRectangle.GetHeight() ); } cairo_translate(cr, -rControlRectangle.Left(), -rControlRectangle.Top()); PaintOneSpinButton(mpSpinUpStyle, cr, nType, upBtnPart, rControlRectangle, upBtnState ); PaintOneSpinButton(mpSpinDownStyle, cr, nType, downBtnPart, rControlRectangle, downBtnState ); cairo_translate(cr, rControlRectangle.Left(), rControlRectangle.Top()); + + if (nPart == ControlPart::Entire) + { + gtk_render_frame(mpSpinStyle, cr, + 0, 0, + rControlRectangle.GetWidth(), rControlRectangle.GetHeight() ); + } } #define FALLBACK_ARROW_SIZE 11 * 0.85 @@ -1122,6 +1129,13 @@ GtkStyleContext* GtkSalGraphics::createNewContext(GtkControlPart ePart, gtk_widg gtk_widget_path_iter_add_class(path, -1, GTK_STYLE_CLASS_HORIZONTAL); return makeContext(path, nullptr); } + case GtkControlPart::SpinButtonEntry: + { + GtkWidgetPath *path = gtk_widget_path_copy(gtk_style_context_get_path(mpSpinStyle)); + gtk_widget_path_append_type(path, G_TYPE_NONE); + set_object_name(path, -1, "entry"); + return makeContext(path, mpSpinStyle); + } case GtkControlPart::SpinButtonUpButton: case GtkControlPart::SpinButtonDownButton: { @@ -1419,6 +1433,7 @@ GtkStyleContext* GtkSalGraphics::createOldContext(GtkControlPart ePart) } case GtkControlPart::Entry: case GtkControlPart::ComboboxBoxEntry: + case GtkControlPart::SpinButtonEntry: { GtkWidgetPath *path = gtk_widget_path_new(); gtk_widget_path_append_type(path, GTK_TYPE_ENTRY); @@ -1787,7 +1802,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co { case ControlType::Spinbox: case ControlType::SpinButtons: - context = mpEntryStyle; + context = mpSpinStyle; renderType = RenderType::Spinbutton; break; case ControlType::Editbox: @@ -2097,7 +2112,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co PaintScrollbar(context, cr, rControlRegion, nType, nPart, rValue); break; case RenderType::Spinbutton: - PaintSpinButton(context, cr, rControlRegion, nType, nPart, rValue); + PaintSpinButton(flags, cr, rControlRegion, nType, nPart, rValue); break; case RenderType::Combobox: PaintCombobox(flags, cr, rControlRegion, nType, nPart, rValue); @@ -2983,6 +2998,7 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) gSpinBox = gtk_spin_button_new(nullptr, 0, 0); gtk_container_add(GTK_CONTAINER(gDumbContainer), gSpinBox); mpSpinStyle = createStyleContext(set_object_name, GtkControlPart::SpinButton); + mpSpinEntryStyle = createStyleContext(set_object_name, GtkControlPart::SpinButtonEntry); mpSpinUpStyle = createStyleContext(set_object_name, GtkControlPart::SpinButtonUpButton); mpSpinDownStyle = createStyleContext(set_object_name, GtkControlPart::SpinButtonDownButton); |