vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx |  104 +++++++++++++++++++++---------
 1 file changed, 74 insertions(+), 30 deletions(-)

New commits:
commit baa3c7389ec3f570be0486b3647ab424c7835ee1
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Dec 13 14:30:21 2018 +0000
Commit:     Heiko Tietze <tietze.he...@gmail.com>
CommitDate: Sat Dec 15 11:02:07 2018 +0100

    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.he...@gmail.com>
    Tested-by: Heiko Tietze <tietze.he...@gmail.com>

diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx 
b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index babe9273948b..6ca1802706aa 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,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to