diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-10-12 22:42:20 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2017-10-13 09:33:30 +0200 |
commit | 0ceb9cb40f2a05e06597ca13dbb01e0a2f663a86 (patch) | |
tree | 34b903a1f606dcd42af5a37e8a59737ce73ea9c4 /sfx2 | |
parent | d4e5e20a29402a305da533357fe538beb45afb96 (diff) |
Notebookbar: initialize correctly PriorityHBox
Change-Id: If8d94c3496dacb3ae9e0b50ba269f3af87c3bcb4
Reviewed-on: https://gerrit.libreoffice.org/43351
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/notebookbar/PriorityHBox.cxx | 46 |
1 files changed, 34 insertions, 12 deletions
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); } }; |