vcl/inc/iconview.hxx | 4 ++-- vcl/source/app/salvtables.cxx | 22 +++++++++++----------- vcl/source/treelist/iconview.cxx | 29 +++++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 17 deletions(-)
New commits: commit c8c30e9fc83e148df3f775ba433dd921c68a8df8 Author: Michael Weghorn <[email protected]> AuthorDate: Mon Feb 9 13:40:13 2026 +0100 Commit: Ilmari Lauhakangas <[email protected]> CommitDate: Tue Feb 10 14:24:21 2026 +0100 tdf#170603 vcl: Rework IconView entry width calculation Instead of starting with an initial width of 100 pixels for each vcl IconView entry (as set in the IconView ctor so far), start with an initial entry width of 0 and update the width in IconView::UpdateEntrySize to be large enough for the newly inserted entry. In IconView::UpdateEntrySize, calculate the width and height by taking the new entry's data into account, but at least keeping the previous size. Ensure a minimum width of 100 if the item has any text. Also, call Resize() when the entry size was changed, to ensure items are layed out using the new entry size. This complements commit 01d275a80da4a7d1e83fbcd728e1691f48593351 Author: Michael Weghorn <[email protected]> Date: Thu Aug 7 10:17:57 2025 +0200 tdf#167658 Update vcl IconView entry size when inserting item by restoring a minimum size of 100 pixels for the IconView items in the Impress transition side bar panel that contain text and ensuring items are layed out according to the current entry size. It also fixes the problem of the IconViews used for the recently used and favorite special characters in the special character dialogs become too large when there is no entry yet, as the minimum size of 100 for the items in each of the 16 columns used since commit c184cd984865a0406940b9f39ac1cd538b922e8f Author: Michael Weghorn <[email protected]> Date: Sat Dec 20 22:25:15 2025 +0100 tdf#168594 tdf#119931 a11y special chars: Use IconView for recent/favorites would result in too much space getting allocated until the first entry gets inserted (and item width got recalculated). Change-Id: I3fb98e82f462f293753c35617601dcf6fa8e92c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198988 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> (cherry picked from commit d41832024b5c69f096ffa323fb114b2fcd529b3e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199010 Reviewed-by: Ilmari Lauhakangas <[email protected]> diff --git a/vcl/inc/iconview.hxx b/vcl/inc/iconview.hxx index bb18bedea45f..559a8d8444fe 100644 --- a/vcl/inc/iconview.hxx +++ b/vcl/inc/iconview.hxx @@ -56,8 +56,8 @@ public: /// returns string with encoded image for an entry OUString renderEntry(int pos, int dpix, int dpiy) const; - /// Update entry size based on image size - void UpdateEntrySize(const Image& rImage); + /// Update entry size based on the given entry's image size and text + void UpdateEntrySize(const SvTreeListEntry& rEntry); protected: virtual void CalcEntryHeight(SvTreeListEntry const* pEntry) override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index cc178c3ea31d..69e2525c6626 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -5308,7 +5308,7 @@ void SalInstanceIconView::do_insert(int pos, const OUString* pStr, const OUStrin pEntry->SetUserData(pUserData); m_xIconView->Insert(pEntry, nullptr, nInsertPos); if (!m_bFixedItemWidth) - m_xIconView->UpdateEntrySize(rImage); + m_xIconView->UpdateEntrySize(*pEntry); if (pRet) { @@ -5533,7 +5533,7 @@ void SalInstanceIconView::set_image(int pos, VirtualDevice& rIcon) pItem->SetBitmap1(aImage); pItem->SetBitmap2(aImage); if (!m_bFixedItemWidth) - m_xIconView->UpdateEntrySize(aImage); + m_xIconView->UpdateEntrySize(*pEntry); m_xIconView->ModelHasEntryInvalidated(pEntry); } } diff --git a/vcl/source/treelist/iconview.cxx b/vcl/source/treelist/iconview.cxx index 3aec87e10d33..b096d49ee30e 100644 --- a/vcl/source/treelist/iconview.cxx +++ b/vcl/source/treelist/iconview.cxx @@ -41,7 +41,7 @@ IconView::IconView(vcl::Window* pParent, WinBits nBits) { m_nColumnCount = 1; mbCenterAndClipText = true; - SetEntryWidth(100); + SetEntryWidth(0); pImpl.reset(new IconViewImpl(this, GetModel(), GetStyle())); } @@ -59,11 +59,32 @@ void IconView::SetFixedColumnCount(short nColumnCount) m_nColumnCount = nColumnCount; } -void IconView::UpdateEntrySize(const Image& rImage) +void IconView::UpdateEntrySize(const SvTreeListEntry& rEntry) { + const SvLBoxContextBmp* pBitmapItem + = static_cast<const SvLBoxContextBmp*>(rEntry.GetFirstItem(SvLBoxItemType::ContextBmp)); + const Size aImageSize = pBitmapItem ? pBitmapItem->GetBitmap1().GetSizePixel() : Size(); + // 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; - SetEntryHeight(rImage.GetSizePixel().getHeight() + spacing); - SetEntryWidth(rImage.GetSizePixel().getWidth() + spacing); + const short nMinHeight = aImageSize.getHeight() + spacing; + const short nMinWidth = std::max(aImageSize.getWidth() + spacing, nMinTextWidth); + + bool bChanged = false; + if (nMinWidth > GetEntryWidth()) + { + SetEntryWidth(nMinWidth); + bChanged = true; + } + if (nMinHeight > GetEntryHeight()) + { + SetEntryHeight(nMinHeight); + bChanged = true; + } + + if (bChanged) + Resize(); } bool IconView::HasSeparatorEntry() const commit 63e4bf911dec64a4c1db188b78233465bfccc6aa Author: Michael Weghorn <[email protected]> AuthorDate: Mon Feb 9 12:01:31 2026 +0100 Commit: Ilmari Lauhakangas <[email protected]> CommitDate: Tue Feb 10 14:24:07 2026 +0100 vcl IconView: Use "p" instead of "a" prefix for pointers, etc Adhere to variable naming convention: "p" is for pointers, "r" for references. Change-Id: I7ae102cea9ce4fd9cfd1c737634d59f1d7a50db2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198984 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins (cherry picked from commit f6d3bf57ebef5f6960087eb9261060f296ef1683) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199009 Reviewed-by: Ilmari Lauhakangas <[email protected]> diff --git a/vcl/inc/iconview.hxx b/vcl/inc/iconview.hxx index 67908deafe9d..bb18bedea45f 100644 --- a/vcl/inc/iconview.hxx +++ b/vcl/inc/iconview.hxx @@ -57,7 +57,7 @@ public: OUString renderEntry(int pos, int dpix, int dpiy) const; /// Update entry size based on image size - void UpdateEntrySize(const Image& pImage); + void UpdateEntrySize(const Image& rImage); protected: virtual void CalcEntryHeight(SvTreeListEntry const* pEntry) override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 5f7abc62d94b..cc178c3ea31d 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -5517,24 +5517,24 @@ OUString SalInstanceIconView::get_id(int pos) const void SalInstanceIconView::set_image(int pos, VirtualDevice& rIcon) { - SvTreeListEntry* aEntry = m_xIconView->GetEntry(nullptr, pos); - if (aEntry == nullptr) + SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos); + if (pEntry == nullptr) return; - SvLBoxContextBmp* aItem - = static_cast<SvLBoxContextBmp*>(aEntry->GetFirstItem(SvLBoxItemType::ContextBmp)); + SvLBoxContextBmp* pItem + = static_cast<SvLBoxContextBmp*>(pEntry->GetFirstItem(SvLBoxItemType::ContextBmp)); Image aImage = createImage(rIcon); - if (aItem == nullptr) + if (pItem == nullptr) { - aEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false)); + pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false)); } else { - aItem->SetBitmap1(aImage); - aItem->SetBitmap2(aImage); + pItem->SetBitmap1(aImage); + pItem->SetBitmap2(aImage); if (!m_bFixedItemWidth) m_xIconView->UpdateEntrySize(aImage); - m_xIconView->ModelHasEntryInvalidated(aEntry); + m_xIconView->ModelHasEntryInvalidated(pEntry); } } diff --git a/vcl/source/treelist/iconview.cxx b/vcl/source/treelist/iconview.cxx index 2eb254eb2fe0..3aec87e10d33 100644 --- a/vcl/source/treelist/iconview.cxx +++ b/vcl/source/treelist/iconview.cxx @@ -59,11 +59,11 @@ void IconView::SetFixedColumnCount(short nColumnCount) m_nColumnCount = nColumnCount; } -void IconView::UpdateEntrySize(const Image& pImage) +void IconView::UpdateEntrySize(const Image& rImage) { int spacing = nSpacing * 2; - SetEntryHeight(pImage.GetSizePixel().getHeight() + spacing); - SetEntryWidth(pImage.GetSizePixel().getWidth() + spacing); + SetEntryHeight(rImage.GetSizePixel().getHeight() + spacing); + SetEntryWidth(rImage.GetSizePixel().getWidth() + spacing); } bool IconView::HasSeparatorEntry() const
