[Libreoffice-commits] core.git: 2 commits - dbaccess/source include/vcl vcl/inc vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 2 18:24:06 UTC 2020


 dbaccess/source/ui/inc/TableDesignView.hxx         |    2 -
 dbaccess/source/ui/tabledesign/TableDesignView.cxx |    4 +--
 include/vcl/InterimItemWindow.hxx                  |    4 +--
 include/vcl/weld.hxx                               |    3 ++
 vcl/inc/salvtables.hxx                             |    4 +--
 vcl/source/control/InterimItemWindow.cxx           |    8 +++---
 vcl/unx/gtk3/gtk3gtkinst.cxx                       |   26 ++++++++++++---------
 7 files changed, 29 insertions(+), 22 deletions(-)

New commits:
commit 6c8e9d47f9a8e09349dc1dbd3155461cc96034ff
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Sep 2 12:01:26 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Sep 2 20:23:26 2020 +0200

    support attempting to set a background color for widgets
    
    but try to discourage use of random colors
    
    Change-Id: Iedd4dad7c039fbc4c5793f21e8ef3414ff0d4c96
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101944
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 34234f05ed4e..9d68d839f641 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -264,6 +264,9 @@ public:
     virtual void set_title_background() = 0;
     //make this widget suitable for use in a toolbar
     virtual void set_toolbar_background() = 0;
+    //trying to use a custom color for a background is generally a bad idea. If your need
+    //fits one of the above categories then that's a somewhat better choice
+    virtual void set_background(const Color& rBackColor) = 0;
 
     virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() = 0;
 
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 5c2761448af4..d82e1e5087f6 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -218,8 +218,6 @@ protected:
     virtual bool HandleKeyEventListener(VclWindowEvent& rEvent);
     virtual void HandleMouseEventListener(VclSimpleEvent& rEvent);
 
-    void set_background(const Color& rColor);
-
 public:
     SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
 
@@ -382,6 +380,8 @@ public:
 
     virtual void set_highlight_background() override;
 
+    virtual void set_background(const Color& rColor) override;
+
     virtual void draw(OutputDevice& rOutput, const tools::Rectangle& rRect) override;
 
     SystemWindow* getSystemWindow();
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 2ac4130e4392..18c3baa0341c 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2357,9 +2357,10 @@ private:
         gtk_drag_source_set(m_pWidget, GDK_BUTTON1_MASK, rGtkTargets.data(), rGtkTargets.size(), eDragAction);
     }
 
-    void set_background(const OUString* pColor)
+    void do_set_background(const Color& rColor)
     {
-        if (!pColor && !m_pBgCssProvider)
+        const bool bRemoveColor = rColor == COL_AUTO;
+        if (bRemoveColor && !m_pBgCssProvider)
             return;
         GtkStyleContext *pWidgetContext = gtk_widget_get_style_context(GTK_WIDGET(m_pWidget));
         if (m_pBgCssProvider)
@@ -2367,10 +2368,11 @@ private:
             gtk_style_context_remove_provider(pWidgetContext, GTK_STYLE_PROVIDER(m_pBgCssProvider));
             m_pBgCssProvider = nullptr;
         }
-        if (!pColor)
+        if (bRemoveColor)
             return;
+        OUString sColor = rColor.AsRGBHexString();
         m_pBgCssProvider = gtk_css_provider_new();
-        OUString aBuffer = "* { background-color: #" + *pColor + "; }";
+        OUString aBuffer = "* { background-color: #" + sColor + "; }";
         OString aResult = OUStringToOString(aBuffer, RTL_TEXTENCODING_UTF8);
         gtk_css_provider_load_from_data(m_pBgCssProvider, aResult.getStr(), aResult.getLength(), nullptr);
         gtk_style_context_add_provider(pWidgetContext, GTK_STYLE_PROVIDER(m_pBgCssProvider),
@@ -2917,20 +2919,22 @@ public:
 
     virtual void set_stack_background() override
     {
-        OUString sColor = Application::GetSettings().GetStyleSettings().GetWindowColor().AsRGBHexString();
-        set_background(&sColor);
+        do_set_background(Application::GetSettings().GetStyleSettings().GetWindowColor());
     }
 
     virtual void set_title_background() override
     {
-        OUString sColor = Application::GetSettings().GetStyleSettings().GetShadowColor().AsRGBHexString();
-        set_background(&sColor);
+        do_set_background(Application::GetSettings().GetStyleSettings().GetShadowColor());
     }
 
     virtual void set_highlight_background() override
     {
-        OUString sColor = Application::GetSettings().GetStyleSettings().GetHighlightColor().AsRGBHexString();
-        set_background(&sColor);
+        do_set_background(Application::GetSettings().GetStyleSettings().GetHighlightColor());
+    }
+
+    virtual void set_background(const Color& rColor) override
+    {
+        do_set_background(rColor);
     }
 
     virtual void set_toolbar_background() override
@@ -2987,7 +2991,7 @@ public:
         if (m_nSizeAllocateSignalId)
             g_signal_handler_disconnect(m_pWidget, m_nSizeAllocateSignalId);
 
-        set_background(nullptr);
+        do_set_background(COL_AUTO);
 
         if (m_pMouseEventBox && m_pMouseEventBox != m_pWidget)
         {
commit 8d84d3800065b0c2d25479b84575da6906c035fc
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Sep 2 14:34:22 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Sep 2 20:23:03 2020 +0200

    Do layout immediately in resize
    
    the wait for the idle is too long, keep idle for re-layout when
    the container size doesnt change but the contents do
    
    Change-Id: I6ed4806e96d10937e825192de86a3d602acf1689
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101943
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/dbaccess/source/ui/inc/TableDesignView.hxx b/dbaccess/source/ui/inc/TableDesignView.hxx
index aa1c88e4bcaf..b845a3e8e9e5 100644
--- a/dbaccess/source/ui/inc/TableDesignView.hxx
+++ b/dbaccess/source/ui/inc/TableDesignView.hxx
@@ -48,7 +48,7 @@ namespace dbaui
         virtual void dispose() override;
 
         virtual void GetFocus() override;
-        virtual void IdleResize() override;
+        virtual void Layout() override;
 
         OTableEditorCtrl*       GetEditorCtrl() const { return m_xEditorCtrl.get(); }
         OTableFieldDescWin*     GetDescWin()    const { return m_xFieldDescWin.get(); }
diff --git a/dbaccess/source/ui/tabledesign/TableDesignView.cxx b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
index ae32e9706302..bb2657f91a6f 100644
--- a/dbaccess/source/ui/tabledesign/TableDesignView.cxx
+++ b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
@@ -72,7 +72,7 @@ void OTableBorderWindow::dispose()
     InterimItemWindow::dispose();
 }
 
-void OTableBorderWindow::IdleResize()
+void OTableBorderWindow::Layout()
 {
     // dimensions of parent window
     auto nOutputHeight = GetSizePixel().Height();
@@ -88,7 +88,7 @@ void OTableBorderWindow::IdleResize()
     // set splitter
     m_xHorzSplitter->set_position(nSplitPos);
 
-    InterimItemWindow::IdleResize();
+    InterimItemWindow::Layout();
 
     if (nOldSplitPos != nSplitPos)
         m_xHorzSplitter->set_position(nSplitPos);
diff --git a/include/vcl/InterimItemWindow.hxx b/include/vcl/InterimItemWindow.hxx
index 6e406f41f67e..d6b47d33cade 100644
--- a/include/vcl/InterimItemWindow.hxx
+++ b/include/vcl/InterimItemWindow.hxx
@@ -45,7 +45,7 @@ protected:
     // returns true if keystroke is consumed
     bool ChildKeyInput(const KeyEvent& rKEvt);
 
-    virtual void IdleResize();
+    virtual void Layout();
 
     std::unique_ptr<weld::Builder> m_xBuilder;
     VclPtr<vcl::Window> m_xVclContentArea;
@@ -57,7 +57,7 @@ private:
 
     void StartIdleLayout();
 
-    DECL_LINK(DoResize, Timer*, void);
+    DECL_LINK(DoLayout, Timer*, void);
 
     virtual void ImplPaintToDevice(::OutputDevice* pTargetOutDev, const Point& rPos) override;
 };
diff --git a/vcl/source/control/InterimItemWindow.cxx b/vcl/source/control/InterimItemWindow.cxx
index 86650fb9e8c1..132560247c74 100644
--- a/vcl/source/control/InterimItemWindow.cxx
+++ b/vcl/source/control/InterimItemWindow.cxx
@@ -17,7 +17,7 @@ InterimItemWindow::InterimItemWindow(vcl::Window* pParent, const OUString& rUIXM
     , m_pWidget(nullptr) // inheritors are expected to call InitControlBase
 {
     m_aLayoutIdle.SetPriority(TaskPriority::RESIZE);
-    m_aLayoutIdle.SetInvokeHandler(LINK(this, InterimItemWindow, DoResize));
+    m_aLayoutIdle.SetInvokeHandler(LINK(this, InterimItemWindow, DoLayout));
     m_aLayoutIdle.SetDebugName("InterimItemWindow m_aLayoutIdle");
 
     m_xVclContentArea = VclPtr<VclVBox>::Create(this);
@@ -67,11 +67,11 @@ void InterimItemWindow::queue_resize(StateChangedType eReason)
     StartIdleLayout();
 }
 
-void InterimItemWindow::Resize() { StartIdleLayout(); }
+void InterimItemWindow::Resize() { Layout(); }
 
-IMPL_LINK_NOARG(InterimItemWindow, DoResize, Timer*, void) { IdleResize(); }
+IMPL_LINK_NOARG(InterimItemWindow, DoLayout, Timer*, void) { Layout(); }
 
-void InterimItemWindow::IdleResize()
+void InterimItemWindow::Layout()
 {
     vcl::Window* pChild = GetWindow(GetWindowType::FirstChild);
     assert(pChild);


More information about the Libreoffice-commits mailing list