[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - solenv/sanitizers sw/inc sw/source sw/uiconfig

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 23 19:01:54 UTC 2021


 solenv/sanitizers/ui/modules/swriter.suppr |    1 
 sw/inc/AnnotationWin.hxx                   |    1 
 sw/source/uibase/docvw/AnnotationWin2.cxx  |   41 +++++++++++++++++++++--------
 sw/uiconfig/swriter/ui/annotation.ui       |   23 +++++++++-------
 4 files changed, 45 insertions(+), 21 deletions(-)

New commits:
commit d4a456f9df14cd03f82d3d2e18e1f13069cf623d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Feb 19 10:52:49 2021 +0000
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Jun 23 21:01:18 2021 +0200

    Related: tdf#140409 scale the menubutton like the other widgets
    
    Change-Id: I6b42ef958dd1625cfef5e48e45c932aef9a5960f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111211
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117463
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr
index 19d33c2133a4..55fc178a6213 100644
--- a/solenv/sanitizers/ui/modules/swriter.suppr
+++ b/solenv/sanitizers/ui/modules/swriter.suppr
@@ -1,6 +1,7 @@
 sw/uiconfig/swriter/ui/abstractdialog.ui://GtkLabel[@id='label4'] orphan-label
 sw/uiconfig/swriter/ui/addentrydialog.ui://GtkEntry[@id='entry'] no-labelled-by
 sw/uiconfig/swriter/ui/annotation.ui://GtkDrawingArea[@id='editview'] no-labelled-by
+sw/uiconfig/swriter/ui/annotation.ui://GtkMenuButton[@id='menubutton'] button-no-label
 sw/uiconfig/swriter/ui/asciifilterdialog.ui://GtkLabel[@id='label5'] orphan-label
 sw/uiconfig/swriter/ui/authenticationsettingsdialog.ui://GtkLabel[@id='label1'] orphan-label
 sw/uiconfig/swriter/ui/authenticationsettingsdialog.ui://GtkLabel[@id='label2'] orphan-label
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 706531ec4137..a930ca0af940 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -153,7 +153,6 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin : public InterimItemWindow
         sal_Int32   GetMetaHeight() const;
         sal_Int32   GetMinimumSizeWithMeta() const;
         sal_Int32   GetMinimumSizeWithoutMeta() const;
-        sal_Int32   GetMetaButtonAreaWidth() const;
         int         GetPrefScrollbarWidth() const;
         sal_Int32   GetNumFields() const;
 
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx
index 12126e35829a..c083ee8fa2e1 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -51,8 +51,10 @@
 #include <sfx2/bindings.hxx>
 #include <sfx2/dispatch.hxx>
 
+#include <vcl/decoview.hxx>
 #include <vcl/fixed.hxx>
 #include <vcl/event.hxx>
+#include <vcl/gradient.hxx>
 #include <vcl/scrbar.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
@@ -100,7 +102,6 @@ namespace sw::annotation {
 
 #define METABUTTON_WIDTH        16
 #define METABUTTON_HEIGHT       18
-#define METABUTTON_AREA_WIDTH   30
 #define POSTIT_META_FIELD_HEIGHT  sal_Int32(15)
 #define POSTIT_MINIMUMSIZE_WITHOUT_META     50
 
@@ -435,6 +436,13 @@ void SwAnnotationWin::CheckMetaText()
               SwPostItMgr::GetColorAnchor(aIndex));
 }
 
+static Color ColorFromAlphaColor(const sal_uInt8 aTransparency, const Color& aFront, const Color& aBack)
+{
+    return Color(sal_uInt8(aFront.GetRed()   * aTransparency / 255.0 + aBack.GetRed()   * (1 - aTransparency / 255.0)),
+                 sal_uInt8(aFront.GetGreen() * aTransparency / 255.0 + aBack.GetGreen() * (1 - aTransparency / 255.0)),
+                 sal_uInt8(aFront.GetBlue()  * aTransparency / 255.0 + aBack.GetBlue()  * (1 - aTransparency / 255.0)));
+}
+
 void SwAnnotationWin::Rescale()
 {
     // On Android, this method leads to invoke ImpEditEngine::UpdateViews
@@ -462,9 +470,27 @@ void SwAnnotationWin::Rescale()
         mxMetadataDate->set_font(aFont);
     if (mxMetadataResolved)
         mxMetadataResolved->set_font(aFont);
+    if (mxMenuButton)
+    {
+        ScopedVclPtrInstance<VirtualDevice> xVirDev;
+        Size aSize(tools::Long(METABUTTON_WIDTH * rFraction),
+                   tools::Long(METABUTTON_HEIGHT * rFraction));
+        tools::Rectangle aRect(Point(0, 0), aSize);
+        xVirDev->SetOutputSizePixel(aSize);
+
+        Gradient aGradient(GradientStyle::Linear,
+                                 ColorFromAlphaColor(15, mColorAnchor, mColorDark),
+                                 ColorFromAlphaColor(80, mColorAnchor, mColorDark));
+        xVirDev->DrawGradient(aRect, aGradient);
+
+        DecorationView aDecoView(xVirDev.get());
+        aDecoView.DrawSymbol(aRect, SymbolType::SPIN_DOWN, GetTextColor(),
+                             DrawSymbolFlags::NONE);
+        mxMenuButton->set_image(xVirDev);
+        mxMenuButton->set_size_request(aSize.Width() + 4, aSize.Height());
+    }
     if (mxVScrollbar)
         mxVScrollbar->set_scroll_thickness(GetPrefScrollbarWidth());
-
 }
 
 void SwAnnotationWin::SetPosAndSize()
@@ -1163,20 +1189,15 @@ void SwAnnotationWin::ResetAttributes()
 
 int SwAnnotationWin::GetPrefScrollbarWidth() const
 {
-    return mrView.GetWrtShell().GetViewOptions()->GetZoom() / 10;
-}
-
-sal_Int32 SwAnnotationWin::GetMetaButtonAreaWidth() const
-{
-    const Fraction& f( GetMapMode().GetScaleX() );
-    return tools::Long(METABUTTON_AREA_WIDTH * f);
+    const Fraction& f(mrView.GetWrtShellPtr()->GetOut()->GetMapMode().GetScaleY());
+    return tools::Long(Application::GetSettings().GetStyleSettings().GetScrollBarSize() * f);
 }
 
 sal_Int32 SwAnnotationWin::GetMetaHeight() const
 {
     const Fraction& f(mrView.GetWrtShellPtr()->GetOut()->GetMapMode().GetScaleY());
     const int fields = GetNumFields();
-    return tools::Long(fields*POSTIT_META_FIELD_HEIGHT*f);
+    return tools::Long(fields*POSTIT_META_FIELD_HEIGHT * f);
 }
 
 sal_Int32 SwAnnotationWin::GetNumFields() const
diff --git a/sw/uiconfig/swriter/ui/annotation.ui b/sw/uiconfig/swriter/ui/annotation.ui
index 753f373136af..c0d937d00245 100644
--- a/sw/uiconfig/swriter/ui/annotation.ui
+++ b/sw/uiconfig/swriter/ui/annotation.ui
@@ -2,6 +2,12 @@
 <!-- Generated with glade 3.38.2 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.20"/>
+  <object class="GtkImage" id="image7">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="icon_name">sfx2/res/menu.png</property>
+    <property name="icon_size">2</property>
+  </object>
   <object class="GtkMenu" id="menu">
     <property name="visible">True</property>
     <property name="can-focus">False</property>
@@ -206,19 +212,16 @@
         <child>
           <object class="GtkMenuButton" id="menubutton">
             <property name="visible">True</property>
-            <property name="can-focus">True</property>
-            <property name="focus-on-click">False</property>
-            <property name="label" translatable="no"></property>
-            <property name="receives-default">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="popup">menu</property>
+            <property name="image">image7</property>
+            <property name="always_show_image">True</property>
+            <property name="relief">none</property>
             <property name="valign">start</property>
             <property name="margin-end">10</property>
             <property name="margin-top">5</property>
-            <property name="relief">none</property>
-            <property name="draw-indicator">True</property>
-            <property name="popup">menu</property>
-            <child>
-              <placeholder/>
-            </child>
+            <property name="use_popover">False</property>
             <style>
               <class name="small-button"/>
             </style>


More information about the Libreoffice-commits mailing list