tdf#173578 vcl weld: Evaluate/Apply GtkIconView::item-padding
Instead of hard-coding the spacing for the vcl IconView
implementation to 5 pixels, use that as the default, but
override it with the GtkIconView::item-padding [1] property
if that one is set for an icon view in a .ui file.
Together with previous commit
Change-Id: I703504b7e2ce0c4b5351a95616112950a33332dd
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Wed Sep 23 11:00:24 2026 +0200
tdf#173578 Reduce spacing between ColorIconView items
, this results in the spacing between ColorIconView items
now also being smaller than before when the vcl implementation
(SalInstanceIconView) is used.
[1] https://docs.gtk.org/gtk3/property.IconView.item-padding.html
Change-Id: If4997dd5ea40659532424c600bb74e185c69b102
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211359
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
@@ -28,6 +28,9 @@ private:
|
||||
short m_nFixedColumnCount = -1;
|
||||
short m_nColumnCount;
|
||||
|
||||
// number of pixels from top, from bottom, between icon and label
|
||||
int m_nSpacing = 5;
|
||||
|
||||
public:
|
||||
IconView(vcl::Window* pParent, WinBits nBits);
|
||||
|
||||
@@ -35,6 +38,8 @@ public:
|
||||
short GetColumnCount() const { return m_nColumnCount; }
|
||||
void SetFixedColumnCount(short nColumnCount);
|
||||
|
||||
void SetSpacing(int nSpacing) { m_nSpacing = nSpacing; }
|
||||
|
||||
virtual Size GetOptimalSize() const override;
|
||||
virtual void Resize() override;
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
namespace
|
||||
{
|
||||
const int separatorHeight = 10;
|
||||
const int nSpacing = 5; // 5 pixels from top, from bottom, between icon and label
|
||||
}
|
||||
|
||||
IconView::IconView(vcl::Window* pParent, WinBits nBits)
|
||||
@@ -64,7 +63,7 @@ void IconView::UpdateEntrySize(const SvTreeListEntry& rEntry)
|
||||
// provide some minimum width if text exists (will be ellipsized if it doesn't fit completely)
|
||||
const tools::Long nMinTextWidth = rEntry.GetFirstItem(SvLBoxItemType::String) ? 100 : 0;
|
||||
|
||||
int spacing = nSpacing * 2;
|
||||
int spacing = m_nSpacing * 2;
|
||||
const short nMinHeight = aImageSize.getHeight() + spacing;
|
||||
const short nMinWidth = std::max(aImageSize.getWidth() + spacing, nMinTextWidth);
|
||||
|
||||
@@ -98,7 +97,7 @@ bool IconView::HasSeparatorEntry() const
|
||||
|
||||
void IconView::CalcEntryHeight(const SvTreeListEntry& rEntry)
|
||||
{
|
||||
int nHeight = nSpacing * 2;
|
||||
int nHeight = m_nSpacing * 2;
|
||||
SvViewDataEntry& rViewData = GetViewDataEntry(rEntry);
|
||||
const size_t nCount = rEntry.ItemCount();
|
||||
bool bHasIcon = false;
|
||||
@@ -111,7 +110,7 @@ void IconView::CalcEntryHeight(const SvTreeListEntry& rEntry)
|
||||
}
|
||||
|
||||
if (bHasIcon && nCount > 1)
|
||||
nHeight += nSpacing; // between icon and label
|
||||
nHeight += m_nSpacing; // between icon and label
|
||||
|
||||
if (nHeight > m_nEntryHeight)
|
||||
{
|
||||
@@ -245,7 +244,7 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
|
||||
nLabelHeight += nItemHeight;
|
||||
}
|
||||
|
||||
int nLabelYPos = nY + nTempEntryHeight - nLabelHeight - nSpacing; // padding from bottom
|
||||
int nLabelYPos = nY + nTempEntryHeight - nLabelHeight - m_nSpacing; // padding from bottom
|
||||
for (auto nCurItem : aTextItems)
|
||||
{
|
||||
aEntryPos.setY(nLabelYPos);
|
||||
@@ -271,12 +270,12 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
|
||||
// center horizontally
|
||||
aEntryPos.AdjustX((nTempEntryWidth - nItemWidth) / 2);
|
||||
// center vertically
|
||||
int nImageAreaHeight = nTempEntryHeight - nSpacing * 2; // spacings from top, from bottom
|
||||
int nImageAreaHeight = nTempEntryHeight - m_nSpacing * 2; // spacings from top, from bottom
|
||||
if (nLabelHeight > 0)
|
||||
{
|
||||
nImageAreaHeight -= nLabelHeight + nSpacing; // spacing between icon and label
|
||||
nImageAreaHeight -= nLabelHeight + m_nSpacing; // spacing between icon and label
|
||||
}
|
||||
aEntryPos.AdjustY((nImageAreaHeight - nItemHeight) / 2 + nSpacing);
|
||||
aEntryPos.AdjustY((nImageAreaHeight - nItemHeight) / 2 + m_nSpacing);
|
||||
|
||||
rItem.Paint(aEntryPos, *this, rRenderContext, &rViewDataEntry, rEntry);
|
||||
}
|
||||
|
||||
@@ -1418,6 +1418,10 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OUString
|
||||
auto aColumnsIt = rMap.find(u"columns"_ustr);
|
||||
if (aColumnsIt != rMap.end())
|
||||
xBox->SetFixedColumnCount(aColumnsIt->second.toInt32());
|
||||
|
||||
auto aItemPaddingIt = rMap.find(u"item-padding"_ustr);
|
||||
if (aItemPaddingIt != rMap.end())
|
||||
xBox->SetSpacing(aItemPaddingIt->second.toInt32());
|
||||
}
|
||||
else if (name == "GtkTreeView")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user