vcl/inc/verticaltabctrl.hxx   |    1 +
 vcl/source/control/ivctrl.cxx |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

New commits:
commit 7629d31f02a9fdbdf71295744c8869dee5cb4c54
Author:     Thorsten Behrens <thorsten.behr...@allotropia.de>
AuthorDate: Mon May 27 01:51:02 2024 +0200
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu May 30 22:34:53 2024 +0200

    tdf#161006 tdf#161049 tdf#161020 tdf#161047 fix VertTabCtrl size calculation
    
    * don't rely on initial dummy pages
    * so instead override GetOptimalSize() and do the math again
    * this assumes that all tab pages have been inserted at the time time
      GetOptimalSize() gets called for the last time
    
    Change-Id: I668347744d8ec9b94824f38cfc4b7ca00771a476
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168081
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/vcl/inc/verticaltabctrl.hxx b/vcl/inc/verticaltabctrl.hxx
index 666bef474172..e00770b8d1f8 100644
--- a/vcl/inc/verticaltabctrl.hxx
+++ b/vcl/inc/verticaltabctrl.hxx
@@ -80,6 +80,7 @@ public:
 
     vcl::Window* GetPageParent() { return m_xBox.get(); }
 
+    virtual Size GetOptimalSize() const override;
     virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
 
     virtual FactoryFunction GetUITestFactory() const override;
diff --git a/vcl/source/control/ivctrl.cxx b/vcl/source/control/ivctrl.cxx
index 14e0ec44938b..c7e76a75eab0 100644
--- a/vcl/source/control/ivctrl.cxx
+++ b/vcl/source/control/ivctrl.cxx
@@ -627,6 +627,24 @@ void VerticalTabControl::SetPageText(std::u16string_view 
rPageId, const OUString
     pData->pEntry->SetText(rText);
 }
 
+Size VerticalTabControl::GetOptimalSize() const
+{
+    // re-calculate size - we might have replaced dummy tab pages with
+    // actual content
+    Size aOptimalPageSize(m_xBox->get_preferred_size());
+
+    for (auto const& item : maPageList)
+    {
+        Size aPagePrefSize(item->xPage->get_preferred_size());
+        if (aPagePrefSize.Width() > aOptimalPageSize.Width())
+            aOptimalPageSize.setWidth( aPagePrefSize.Width() );
+        if (aPagePrefSize.Height() > aOptimalPageSize.Height())
+            aOptimalPageSize.setHeight( aPagePrefSize.Height() );
+    }
+
+    return aOptimalPageSize;
+}
+
 void VerticalTabControl::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
 {
     rJsonWriter.put("id", get_id());

Reply via email to