Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi!

there was a discussion about ugly listboxes in gtk theming, and we
decided to draw a border:

http://nabble.documentfoundation.org/PATCH-Revert-Set-the-listbox-height-to-an-integer-multiple-of-the-listbox-entry-height-tp3969374p3980299.html

and after a more than 2 month *cough* I have figured out what is wrong.
The problem is in gtk plugin which does some weird things when drawing
a listbox (see the description in the patch).
I have no idea why it does that, git blame shows that it is from the
initial import. It would be great if someone review the patch, I am
absolutely not sure.

The famous before.png and after.png are attached.

Thanks!

Ivan
From 23768fa0331a1ec32b2210a89a72673bb4fa7b2e Mon Sep 17 00:00:00 2001
From: Ivan Timofeev <timofeev.i.s@gmail.com>
Date: Fri, 27 Jul 2012 20:53:32 +0400
Subject: [PATCH] gtk: listbox border was not rendered

remove extending of pixmapRect in the nPart == PART_WINDOW branch
and simplify code, since rControlRectangle, pixmapRect and widgetRect
are the same.

Change-Id: I253851fad558e525cd533bb3576a9bba82187e53
---
 vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx | 40 +++++++++-----------------------
 1 file changed, 11 insertions(+), 29 deletions(-)

diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index 2f2158a..4d8ba82 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -2733,15 +2733,13 @@ sal_Bool GtkSalGraphics::NWPaintGTKListBox( GdkDrawable* gdkDrawable,
                                         const ImplControlValue& aValue,
                                         const OUString& rCaption )
 {
-    Rectangle        pixmapRect;
-    Rectangle        widgetRect;
     Rectangle        aIndicatorRect;
     GtkStateType    stateType;
     GtkShadowType    shadowType;
     gint            bInteriorFocus;
     gint            nFocusLineWidth;
     gint            nFocusPadding;
-    gint            x,y;
+    gint            x,y,w,h;
     GdkRectangle    clipRect;
 
     NWEnsureGTKButton( m_nXScreen );
@@ -2749,27 +2747,16 @@ sal_Bool GtkSalGraphics::NWPaintGTKListBox( GdkDrawable* gdkDrawable,
     NWEnsureGTKScrolledWindow( m_nXScreen );
     NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
 
-    // Find the overall bounding rect of the buttons's drawing area,
-    // plus its actual draw rect excluding adornment
-    pixmapRect = rControlRectangle;
-    if ( nPart == PART_WINDOW )
-    {
-        // Make the widget a _bit_ bigger
-        pixmapRect.SetPos( Point( pixmapRect.Left() - 1,
-                                  pixmapRect.Top() - 1 ) );
-        pixmapRect.SetSize( Size( pixmapRect.GetWidth() + 2,
-                                  pixmapRect.GetHeight() + 2 ) );
-    }
-
-    widgetRect = pixmapRect;
-    x = pixmapRect.Left();
-    y = pixmapRect.Top();
-
     // set up references to correct drawable and cliprect
     NWSetWidgetState( gWidgetData[m_nXScreen].gBtnWidget, nState, stateType );
     NWSetWidgetState( gWidgetData[m_nXScreen].gOptionMenuWidget, nState, stateType );
     NWSetWidgetState( gWidgetData[m_nXScreen].gScrolledWindowWidget, nState, stateType );
 
+    x = rControlRectangle.Left();
+    y = rControlRectangle.Top();
+    w = rControlRectangle.GetWidth();
+    h = rControlRectangle.GetHeight();
+
     if ( nPart != PART_WINDOW )
     {
         gtk_widget_style_get( gWidgetData[m_nXScreen].gOptionMenuWidget,
@@ -2790,19 +2777,15 @@ sal_Bool GtkSalGraphics::NWPaintGTKListBox( GdkDrawable* gdkDrawable,
         {
             // Listboxes must paint opaque since some themes have alpha-channel enabled bodies
             gtk_paint_flat_box( m_pWindow->style, gdkDrawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
-                                &clipRect, m_pWindow, "base", x, y,
-                                pixmapRect.GetWidth(), pixmapRect.GetHeight() );
+                                &clipRect, m_pWindow, "base", x, y, w, h);
             gtk_paint_box( gWidgetData[m_nXScreen].gOptionMenuWidget->style, gdkDrawable, 
stateType, shadowType, &clipRect,
                            gWidgetData[m_nXScreen].gOptionMenuWidget, "optionmenu",
-                           x+(widgetRect.Left() - pixmapRect.Left()),
-                           y+(widgetRect.Top() - pixmapRect.Top()),
-                           widgetRect.GetWidth(), widgetRect.GetHeight() );
-            aIndicatorRect = NWGetListBoxIndicatorRect( m_nXScreen, nType, nPart, widgetRect, 
nState,
+                           x, y, w, h);
+            aIndicatorRect = NWGetListBoxIndicatorRect( m_nXScreen, nType, nPart, 
rControlRectangle, nState,
                                                         aValue, rCaption );
             gtk_paint_tab( gWidgetData[m_nXScreen].gOptionMenuWidget->style, gdkDrawable, 
stateType, shadowType, &clipRect,
                            gWidgetData[m_nXScreen].gOptionMenuWidget, "optionmenutab",
-                           x+(aIndicatorRect.Left() - pixmapRect.Left()),
-                           y+(aIndicatorRect.Top() - pixmapRect.Top()),
+                           aIndicatorRect.Left(), aIndicatorRect.Top(),
                            aIndicatorRect.GetWidth(), aIndicatorRect.GetHeight() );
         }
         else
@@ -2811,8 +2794,7 @@ sal_Bool GtkSalGraphics::NWPaintGTKListBox( GdkDrawable* gdkDrawable,
 
             gtk_paint_shadow( gWidgetData[m_nXScreen].gScrolledWindowWidget->style, gdkDrawable, 
GTK_STATE_NORMAL, shadowType,
                 &clipRect, gWidgetData[m_nXScreen].gScrolledWindowWidget, "scrolled_window",
-                x+(widgetRect.Left() - pixmapRect.Left()), y+(widgetRect.Top() - pixmapRect.Top()),
-                widgetRect.GetWidth(), widgetRect.GetHeight() );
+                x, y, w, h );
         }
     }
 
-- 
1.7.11.3

Attachment: after.png
Description: PNG image

Attachment: before.png
Description: PNG image


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.