include/vcl/toolkit/svlbitm.hxx | 18 +++++++------- vcl/inc/iconview.hxx | 4 +-- vcl/source/app/salvtables.cxx | 4 +-- vcl/source/treelist/iconview.cxx | 29 ++++++++++++++++++++--- vcl/source/treelist/svlbitm.cxx | 48 ++++++++------------------------------- 5 files changed, 48 insertions(+), 55 deletions(-)
New commits: commit d41832024b5c69f096ffa323fb114b2fcd529b3e Author: Michael Weghorn <[email protected]> AuthorDate: Mon Feb 9 13:40:13 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Mon Feb 9 20:03:36 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]> 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 971e14494f47..474c9d2b8e7b 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -5204,7 +5204,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) { @@ -5310,7 +5310,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 5acb148688de..f6005b2e8ede 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 abdd6e241e2d21dbad41750fff44bd03e007209e Author: Michael Weghorn <[email protected]> AuthorDate: Mon Feb 9 13:34:06 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Mon Feb 9 20:03:29 2026 +0100 vcl: Inline SvLBoxContextBmp::SetModeImages logic to only caller Change-Id: I7fe446b9baa33dce23565d091afc069d8594138f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198987 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/include/vcl/toolkit/svlbitm.hxx b/include/vcl/toolkit/svlbitm.hxx index 73cd0e40f6a9..6aacce557243 100644 --- a/include/vcl/toolkit/svlbitm.hxx +++ b/include/vcl/toolkit/svlbitm.hxx @@ -251,8 +251,6 @@ public: virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override; - void SetModeImages(const Image& rBitmap1, const Image& rBitmap2); - void SetBitmap1(const Image& rImage) { m_aImage1 = rImage; }; void SetBitmap2(const Image& rImage) { m_aImage2 = rImage; }; const Image& GetBitmap1() const { return m_aImage1; }; diff --git a/vcl/source/treelist/svlbitm.cxx b/vcl/source/treelist/svlbitm.cxx index cff8a958e5b9..5162adc93f9d 100644 --- a/vcl/source/treelist/svlbitm.cxx +++ b/vcl/source/treelist/svlbitm.cxx @@ -439,9 +439,10 @@ void SvLBoxButton::InitViewData(SvTreeListBox* pView,SvTreeListEntry* pEntry, Sv // *************************************************************** SvLBoxContextBmp::SvLBoxContextBmp(const Image& aBmp1, const Image& aBmp2, bool bExpanded) - : m_bExpanded(bExpanded) + : m_aImage1(aBmp1) + , m_aImage2(aBmp2) + , m_bExpanded(bExpanded) { - SetModeImages( aBmp1, aBmp2 ); } SvLBoxContextBmp::SvLBoxContextBmp() @@ -458,12 +459,6 @@ SvLBoxItemType SvLBoxContextBmp::GetType() const return SvLBoxItemType::ContextBmp; } -void SvLBoxContextBmp::SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2 ) -{ - m_aImage1 = _rBitmap1; - m_aImage2 = _rBitmap2; -} - void SvLBoxContextBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry, SvViewDataItem* pViewData) { commit f34d8a41873be59d8e9163ddd69e639b3abedc59 Author: Michael Weghorn <[email protected]> AuthorDate: Mon Feb 9 13:28:28 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Mon Feb 9 20:03:22 2026 +0100 vcl: Merge SvLBoxContextBmp_Impl into SvLBoxContextBmp Move the three SvLBoxContextBmp_Impl members directly into SvLBoxContextBmp and drop SvLBoxContextBmp_Impl. Change-Id: Ic9ae658456a7194eff91dbf83b781ea178cc7146 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198986 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/include/vcl/toolkit/svlbitm.hxx b/include/vcl/toolkit/svlbitm.hxx index ce28331fc96d..73cd0e40f6a9 100644 --- a/include/vcl/toolkit/svlbitm.hxx +++ b/include/vcl/toolkit/svlbitm.hxx @@ -225,11 +225,13 @@ inline void SvLBoxButton::SetStateHilighted( bool bHilight ) nItemFlags &= ~SvItemStateFlags::HIGHLIGHTED; } -struct SvLBoxContextBmp_Impl; - class UNLESS_MERGELIBS(VCL_DLLPUBLIC) SvLBoxContextBmp : public SvLBoxItem { - std::unique_ptr<SvLBoxContextBmp_Impl> m_pImpl; + Image m_aImage1; + Image m_aImage2; + + bool m_bExpanded; + public: SvLBoxContextBmp(const Image& aBmp1, const Image& aBmp2, @@ -251,10 +253,10 @@ public: void SetModeImages(const Image& rBitmap1, const Image& rBitmap2); - void SetBitmap1(const Image& rImage); - void SetBitmap2(const Image& rImage); - const Image& GetBitmap1() const; - const Image& GetBitmap2() const; + void SetBitmap1(const Image& rImage) { m_aImage1 = rImage; }; + void SetBitmap2(const Image& rImage) { m_aImage2 = rImage; }; + const Image& GetBitmap1() const { return m_aImage1; }; + const Image& GetBitmap2() const { return m_aImage2; }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/treelist/svlbitm.cxx b/vcl/source/treelist/svlbitm.cxx index e5e234ff19ae..cff8a958e5b9 100644 --- a/vcl/source/treelist/svlbitm.cxx +++ b/vcl/source/treelist/svlbitm.cxx @@ -438,29 +438,15 @@ void SvLBoxButton::InitViewData(SvTreeListBox* pView,SvTreeListEntry* pEntry, Sv // class SvLBoxContextBmp // *************************************************************** -struct SvLBoxContextBmp_Impl +SvLBoxContextBmp::SvLBoxContextBmp(const Image& aBmp1, const Image& aBmp2, bool bExpanded) + : m_bExpanded(bExpanded) { - Image m_aImage1; - Image m_aImage2; - - bool m_bExpanded; -}; - -// *************************************************************** - -SvLBoxContextBmp::SvLBoxContextBmp(const Image& aBmp1, const Image& aBmp2, - bool bExpanded) - :m_pImpl( new SvLBoxContextBmp_Impl ) -{ - - m_pImpl->m_bExpanded = bExpanded; SetModeImages( aBmp1, aBmp2 ); } SvLBoxContextBmp::SvLBoxContextBmp() - : m_pImpl( new SvLBoxContextBmp_Impl ) + : m_bExpanded(false) { - m_pImpl->m_bExpanded = false; } SvLBoxContextBmp::~SvLBoxContextBmp() @@ -474,24 +460,16 @@ SvLBoxItemType SvLBoxContextBmp::GetType() const void SvLBoxContextBmp::SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2 ) { - m_pImpl->m_aImage1 = _rBitmap1; - m_pImpl->m_aImage2 = _rBitmap2; + m_aImage1 = _rBitmap1; + m_aImage2 = _rBitmap2; } -void SvLBoxContextBmp::SetBitmap1(const Image& _rImage) { m_pImpl->m_aImage1 = _rImage; } - -void SvLBoxContextBmp::SetBitmap2(const Image& _rImage) { m_pImpl->m_aImage2 = _rImage; } - -const Image& SvLBoxContextBmp::GetBitmap1() const { return m_pImpl->m_aImage1; } - -const Image& SvLBoxContextBmp::GetBitmap2() const { return m_pImpl->m_aImage2; } - void SvLBoxContextBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry, SvViewDataItem* pViewData) { if( !pViewData ) pViewData = pView->GetViewDataItem( pEntry, this ); - Size aSize = m_pImpl->m_aImage1.GetSizePixel(); + Size aSize = m_aImage1.GetSizePixel(); pViewData->mnWidth = aSize.Width(); pViewData->mnHeight = aSize.Height(); } @@ -502,8 +480,7 @@ void SvLBoxContextBmp::Paint( { // get the image. - const Image& rImage - = pView->IsExpanded() != m_pImpl->m_bExpanded ? m_pImpl->m_aImage1 : m_pImpl->m_aImage2; + const Image& rImage = pView->IsExpanded() != m_bExpanded ? m_aImage1 : m_aImage2; bool _bSemiTransparent = bool( SvTLEntryFlags::SEMITRANSPARENT & rEntry.GetFlags( ) ); // draw @@ -516,9 +493,9 @@ void SvLBoxContextBmp::Paint( std::unique_ptr<SvLBoxItem> SvLBoxContextBmp::Clone(SvLBoxItem const * pSource) const { std::unique_ptr<SvLBoxContextBmp> pNew(new SvLBoxContextBmp); - pNew->m_pImpl->m_aImage1 = static_cast< SvLBoxContextBmp const * >( pSource )->m_pImpl->m_aImage1; - pNew->m_pImpl->m_aImage2 = static_cast< SvLBoxContextBmp const * >( pSource )->m_pImpl->m_aImage2; - pNew->m_pImpl->m_bExpanded = static_cast<SvLBoxContextBmp const *>(pSource)->m_pImpl->m_bExpanded; + pNew->m_aImage1 = static_cast<SvLBoxContextBmp const*>(pSource)->m_aImage1; + pNew->m_aImage2 = static_cast<SvLBoxContextBmp const*>(pSource)->m_aImage2; + pNew->m_bExpanded = static_cast<SvLBoxContextBmp const*>(pSource)->m_bExpanded; return std::unique_ptr<SvLBoxItem>(pNew.release()); }
