[Libreoffice-commits] core.git: sfx2/source
Szymon Kłos
szymon.klos at collabora.com
Fri Oct 13 07:33:51 UTC 2017
sfx2/source/notebookbar/PriorityHBox.cxx | 46 ++++++++++++++++++++++---------
1 file changed, 34 insertions(+), 12 deletions(-)
New commits:
commit 0ceb9cb40f2a05e06597ca13dbb01e0a2f663a86
Author: Szymon Kłos <szymon.klos at collabora.com>
Date: Thu Oct 12 22:42:20 2017 +0200
Notebookbar: initialize correctly PriorityHBox
Change-Id: If8d94c3496dacb3ae9e0b50ba269f3af87c3bcb4
Reviewed-on: https://gerrit.libreoffice.org/43351
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/sfx2/source/notebookbar/PriorityHBox.cxx b/sfx2/source/notebookbar/PriorityHBox.cxx
index df854701370b..be9c16062615 100644
--- a/sfx2/source/notebookbar/PriorityHBox.cxx
+++ b/sfx2/source/notebookbar/PriorityHBox.cxx
@@ -55,8 +55,31 @@ public:
disposeOnce();
}
+ void Initialize()
+ {
+ m_bInitialized = true;
+
+ GetChildrenWithPriorities();
+ SetSizeFromParent();
+ }
+
+ void SetSizeFromParent()
+ {
+ vcl::Window* pParent = GetParent();
+ if (pParent)
+ {
+ Size aParentSize = pParent->GetSizePixel();
+ SetSizePixel(Size(aParentSize.getWidth(), aParentSize.getHeight()));
+ }
+ }
+
virtual Size calculateRequisition() const override
{
+ if (!m_bInitialized)
+ {
+ return VclHBox::calculateRequisition();
+ }
+
sal_uInt16 nVisibleChildren = 0;
Size aSize;
@@ -90,6 +113,13 @@ public:
virtual void Resize() override
{
+ SetSizeFromParent();
+
+ if (!m_bInitialized)
+ {
+ return VclHBox::Resize();
+ }
+
long nWidth = GetSizePixel().Width();
long nCurrentWidth = VclHBox::calculateRequisition().getWidth();
@@ -132,18 +162,7 @@ public:
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override
{
if (!m_bInitialized && SfxViewFrame::Current())
- {
- m_bInitialized = true;
-
- GetChildrenWithPriorities();
-
- SystemWindow* pSystemWindow = SfxViewFrame::Current()->GetFrame().GetSystemWindow();
- if (pSystemWindow)
- {
- long nWidth = pSystemWindow->GetSizePixel().Width();
- SetSizePixel(Size(nWidth, GetSizePixel().Height()));
- }
- }
+ Initialize();
VclHBox::Paint(rRenderContext, rRect);
}
@@ -160,6 +179,9 @@ public:
m_aSortedChilds.push_back(pPrioritable);
}
+ if (!m_aSortedChilds.size())
+ m_bInitialized = false;
+
std::sort(m_aSortedChilds.begin(), m_aSortedChilds.end(), lcl_comparePriority);
}
};
More information about the Libreoffice-commits
mailing list