From d3c2fcc3f33f09d655904abdfbad62c1db005288 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 24 Nov 2024 14:16:46 +0000 Subject: Resolves: tdf#163772 move margin into ValueSet itself MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit instead of using margin property in .ui where size_request doesn't take such margins into account, while pref_size does. Change-Id: I7c557fd63c438515814ad32b9627895c27c13b81 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177213 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- cui/source/customize/cfg.cxx | 1 + cui/uiconfig/ui/iconselectordialog.ui | 4 ---- include/svtools/valueset.hxx | 2 ++ svtools/source/control/valueset.cxx | 24 ++++++++++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 9b79a931163f..3aaa07d6bb15 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -2739,6 +2739,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow, m_xTbSymbol->SetItemWidth(m_nExpectedSize); m_xTbSymbol->SetItemHeight(m_nExpectedSize); m_xTbSymbol->SetExtraSpacing(6); + m_xTbSymbol->SetMargin(4); Size aSize(m_xTbSymbol->CalcWindowSizePixel(Size(m_nExpectedSize, m_nExpectedSize), 11, 5)); m_xTbSymbol->set_size_request(aSize.Width(), aSize.Height()); diff --git a/cui/uiconfig/ui/iconselectordialog.ui b/cui/uiconfig/ui/iconselectordialog.ui index 9ee6ee8847cb..1d07337f1cbb 100644 --- a/cui/uiconfig/ui/iconselectordialog.ui +++ b/cui/uiconfig/ui/iconselectordialog.ui @@ -119,10 +119,6 @@ True True GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK - 3 - 3 - 3 - 3 True True diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx index 03dea4c03749..2244dfc805af 100644 --- a/include/svtools/valueset.hxx +++ b/include/svtools/valueset.hxx @@ -209,6 +209,7 @@ private: sal_uInt16 mnUserVisLines; sal_uInt16 mnFirstLine; sal_uInt16 mnSpacing; + sal_uInt16 mnMargin; DrawFrameStyle mnFrameStyle; Color maColor; OUString maText; @@ -369,6 +370,7 @@ public: } void SetExtraSpacing( sal_uInt16 nNewSpacing ); + void SetMargin( sal_uInt16 nNewMargin ); void Format(vcl::RenderContext const & rRenderContext); void SetFormat(); diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 03666c97688b..5a056751b105 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -96,6 +96,7 @@ ValueSet::ValueSet(std::unique_ptr pScrolledWindow) mnUserCols = 0; mnUserVisLines = 0; mnSpacing = 0; + mnMargin = 0; mnFrameStyle = DrawFrameStyle::NONE; mbNoSelection = true; mbDoubleSel = false; @@ -861,6 +862,12 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) else nOff = 0; + if ( mnMargin ) + { + aWinSize.AdjustWidth(-mnMargin * 2); + aWinSize.AdjustHeight(-mnMargin * 2); + } + // consider size, if NameField does exist if (nStyle & WB_NAMEFIELD) { @@ -876,6 +883,8 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) else mnTextOffset = 0; + mnTextOffset += mnMargin; + // consider offset and size, if NoneField does exist if (nStyle & WB_NONEFIELD) { @@ -1038,6 +1047,9 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) nStartY = 0; } + nStartX += mnMargin; + nStartY += mnMargin; + // calculate and draw items maVirDev->SetLineColor(); tools::Long x = nStartX; @@ -1648,6 +1660,12 @@ Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesireCol aSize.AdjustHeight(nTxtHeight + n + mnSpacing ); } + if ( mnMargin ) + { + aSize.AdjustWidth(mnMargin * 2); + aSize.AdjustHeight(mnMargin * 2); + } + return aSize; } @@ -1820,6 +1838,12 @@ void ValueSet::SetExtraSpacing( sal_uInt16 nNewSpacing ) } } +void ValueSet::SetMargin( sal_uInt16 nNewMargin ) +{ + mnMargin = nNewMargin; + QueueReformat(); +} + void ValueSet::SetFormat() { mbFormat = true; -- cgit