summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-12-13 14:30:21 +0000
committerHeiko Tietze <tietze.heiko@gmail.com>2018-12-15 14:17:13 +0100
commitd3e4c06ccb3aa4bb9078077a49dc2b2795835a5c (patch)
treee9e895e193f888f72e950cf51647f8f678e5ea61
parentda9e424c556e25cf42eddc9d6fa22011e80359aa (diff)
Resolves: tdf#121050 draw fixedlines like toolbar separators
Change-Id: Ib91b3f204d847cbe96750b4c080e958597bb3b9b Reviewed-on: https://gerrit.libreoffice.org/65110 Tested-by: Jenkins Reviewed-by: Heiko Tietze <tietze.heiko@gmail.com> Tested-by: Heiko Tietze <tietze.heiko@gmail.com> (cherry picked from commit baa3c7389ec3f570be0486b3647ab424c7835ee1) Reviewed-on: https://gerrit.libreoffice.org/65196
-rw-r--r--vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx104
1 files changed, 74 insertions, 30 deletions
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index 31c665e1af05..769cba86243d 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -2166,6 +2166,77 @@ static gfloat getArrowSize(GtkStyleContext* context)
return arrow_size;
}
+namespace
+{
+ void draw_vertical_separator(GtkStyleContext *context, cairo_t *cr, const tools::Rectangle& rControlRegion)
+ {
+ long nX = 0;
+ long nY = 0;
+
+ const bool bNewStyle = gtk_check_version(3, 20, 0) == nullptr;
+
+ gint nSeparatorWidth = 1;
+
+ if (bNewStyle)
+ {
+ gtk_style_context_get(context,
+ gtk_style_context_get_state(context),
+ "min-width", &nSeparatorWidth, nullptr);
+ }
+
+ gint nHalfSeparatorWidth = nSeparatorWidth / 2;
+ gint nHalfRegionWidth = rControlRegion.GetWidth() / 2;
+
+ nX = nX + nHalfRegionWidth - nHalfSeparatorWidth;
+ nY = rControlRegion.GetHeight() > 5 ? 1 : 0;
+ int nHeight = rControlRegion.GetHeight() - (2 * nY);
+
+ if (bNewStyle)
+ {
+ gtk_render_background(context, cr, nX, nY, nSeparatorWidth, nHeight);
+ gtk_render_frame(context, cr, nX, nY, nSeparatorWidth, nHeight);
+ }
+ else
+ {
+ gtk_render_line(context, cr, nX, nY, nX, nY + nHeight);
+ }
+ }
+
+ void draw_horizontal_separator(GtkStyleContext *context, cairo_t *cr, const tools::Rectangle& rControlRegion)
+ {
+ long nX = 0;
+ long nY = 0;
+
+ const bool bNewStyle = gtk_check_version(3, 20, 0) == nullptr;
+
+ gint nSeparatorHeight = 1;
+
+ if (bNewStyle)
+ {
+ gtk_style_context_get(context,
+ gtk_style_context_get_state(context),
+ "min-height", &nSeparatorHeight, nullptr);
+ }
+
+ gint nHalfSeparatorHeight = nSeparatorHeight / 2;
+ gint nHalfRegionHeight = rControlRegion.GetHeight() / 2;
+
+ nY = nY + nHalfRegionHeight - nHalfSeparatorHeight;
+ nX = rControlRegion.GetWidth() > 5 ? 1 : 0;
+ int nWidth = rControlRegion.GetWidth() - (2 * nX);
+
+ if (bNewStyle)
+ {
+ gtk_render_background(context, cr, nX, nY, nWidth, nSeparatorHeight);
+ gtk_render_frame(context, cr, nX, nY, nWidth, nSeparatorHeight);
+ }
+ else
+ {
+ gtk_render_line(context, cr, nX, nY, nX + nWidth, nY);
+ }
+ }
+}
+
bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion,
ControlState nState, const ImplControlValue& rValue,
const OUString& aCaptions)
@@ -2454,41 +2525,14 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
break;
case RenderType::ToolbarSeparator:
{
- const bool bNewStyle = gtk_check_version(3, 20, 0) == nullptr;
-
- gint nSeparatorWidth = 1;
-
- if (bNewStyle)
- {
- gtk_style_context_get(context,
- gtk_style_context_get_state(context),
- "min-width", &nSeparatorWidth, nullptr);
- }
-
- gint nHalfSeparatorWidth = nSeparatorWidth / 2;
- gint nHalfRegionWidth = rControlRegion.GetWidth() / 2;
-
- nX = nX + nHalfRegionWidth - nHalfSeparatorWidth;
- nWidth = nSeparatorWidth;
- nY = rControlRegion.GetHeight() * 0.1;
- nHeight = rControlRegion.GetHeight() - (2 * nY);
-
- if (bNewStyle)
- {
- gtk_render_background(context, cr, nX, nY, nSeparatorWidth, nHeight);
- gtk_render_frame(context, cr, nX, nY, nSeparatorWidth, nHeight);
- }
- else
- {
- gtk_render_line(context, cr, nX, nY, nX, nY + nHeight);
- }
+ draw_vertical_separator(context, cr, rControlRegion);
break;
}
case RenderType::Separator:
if (nPart == ControlPart::SeparatorHorz)
- gtk_render_line(context, cr, 0, nHeight / 2, nWidth - 1, nHeight / 2);
+ draw_horizontal_separator(context, cr, rControlRegion);
else
- gtk_render_line(context, cr, nWidth / 2, 0, nWidth / 2, nHeight - 1);
+ draw_vertical_separator(context, cr, rControlRegion);
break;
case RenderType::Arrow:
gtk_render_arrow(context, cr,