include/vcl/notebookbar.hxx | 9 +++ sfx2/source/notebookbar/NotebookbarPopup.cxx | 73 +++++++++++++++++++++++++++ sfx2/source/notebookbar/NotebookbarPopup.hxx | 4 + vcl/source/control/notebookbar.cxx | 60 +++++++++++++++++++++- 4 files changed, 143 insertions(+), 3 deletions(-)
New commits: commit e02b3b095e472646c58eecd36d5a27b056dcb99e Author: Kshitij Pathania <kshitijpatha...@gmail.com> Date: Mon May 14 14:21:56 2018 +0530 tdf#112034 , tdf#107266 label color on basis of persona and persona flipping is fixed. Labelcolor not gets updated immediately but when statechanged function triggers via executemethod things workwell.(like it triggers on changing mode of notebookbar) Change-Id: I755fb4ff434d7971112d2f0beb44ca09f4a7e0f1 Reviewed-on: https://gerrit.libreoffice.org/54301 Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Tested-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx index 337b3f76ccf0..f3490bfeea89 100644 --- a/include/vcl/notebookbar.hxx +++ b/include/vcl/notebookbar.hxx @@ -37,6 +37,8 @@ public: const css::uno::Reference<css::ui::XContextChangeEventListener>& getContextChangeEventListener() const { return m_pEventListener; } + void StateChanged(const StateChangedType nStateChange ) override; + void DataChanged(const DataChangedEvent& rDCEvt) override; private: @@ -44,7 +46,14 @@ private: css::uno::Reference<css::ui::XContextChangeEventListener> m_pEventListener; std::vector<NotebookbarContextControl*> m_pContextContainers; + AllSettings DefaultSettings; + AllSettings PersonaSettings; + void UpdateBackground(); + + void UpdateDefaultSettings(); + void UpdatePersonaSettings(); + }; diff --git a/sfx2/source/notebookbar/NotebookbarPopup.cxx b/sfx2/source/notebookbar/NotebookbarPopup.cxx index 4c480af2c8d1..9ea14c202cf2 100644 --- a/sfx2/source/notebookbar/NotebookbarPopup.cxx +++ b/sfx2/source/notebookbar/NotebookbarPopup.cxx @@ -17,6 +17,13 @@ NotebookbarPopup::NotebookbarPopup(const VclPtr<VclHBox>& pParent) { get(m_pBox, "box"); m_pBox->SetSizePixel(Size(100, 75)); + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + const BitmapEx aPersona = rStyleSettings.GetPersonaHeader(); + + if (!aPersona.IsEmpty()) + m_pBox->SetBackground(Wallpaper(aPersona)); + else + m_pBox->SetBackground(rStyleSettings.GetDialogColor()); } NotebookbarPopup::~NotebookbarPopup() { disposeOnce(); } @@ -71,6 +78,33 @@ void NotebookbarPopup::hideSeparators(bool bHide) else pWindow->Show(); } + + if (bHide) + { + sal_Int32 BoxId = 0; + while (BoxId <= m_pBox->GetChildCount() - 1) + { + if (m_pBox->GetChild(BoxId)) + { + pWindow = m_pBox->GetChild(BoxId); + ApplyBackground(pWindow); + } + BoxId++; + } + } + else + { + sal_Int32 BoxId = m_pBox->GetChildCount() - 1; + while (BoxId >= 0) + { + if (m_pBox->GetChild(BoxId)) + { + pWindow = m_pBox->GetChild(BoxId); + RemoveBackground(pWindow); + } + BoxId--; + } + } } void NotebookbarPopup::dispose() @@ -82,4 +116,43 @@ void NotebookbarPopup::dispose() FloatingWindow::dispose(); } +void NotebookbarPopup::ApplyBackground(vcl::Window* pWindow) +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + const BitmapEx aPersona = rStyleSettings.GetPersonaHeader(); + + if (!aPersona.IsEmpty()) + pWindow->SetBackground(Wallpaper(aPersona)); + else + pWindow->SetBackground(rStyleSettings.GetDialogColor()); + + sal_Int32 nNext = 0; + VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext); + while (pChild && pWindow->GetType() == WindowType::CONTAINER) + { + ApplyBackground(pChild); + nNext++; + if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER) + pChild = pWindow->GetChild(nNext); + else + break; + } +} + +void NotebookbarPopup::RemoveBackground(vcl::Window* pWindow) +{ + pWindow->SetBackground(Wallpaper(COL_TRANSPARENT)); + + sal_Int32 nNext = 0; + VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext); + while (pChild && pWindow->GetType() == WindowType::CONTAINER) + { + RemoveBackground(pChild); + nNext++; + if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER) + pChild = pWindow->GetChild(nNext); + else + break; + } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/notebookbar/NotebookbarPopup.hxx b/sfx2/source/notebookbar/NotebookbarPopup.hxx index 2a70cd77daf5..1bbb15133bbe 100644 --- a/sfx2/source/notebookbar/NotebookbarPopup.hxx +++ b/sfx2/source/notebookbar/NotebookbarPopup.hxx @@ -48,6 +48,10 @@ public: void hideSeparators(bool bHide); void dispose() override; + + void ApplyBackground(vcl::Window* pWindow); + + void RemoveBackground(vcl::Window* pWindow); }; #endif diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx index 54931df82557..6c04bcaf7423 100644 --- a/vcl/source/control/notebookbar.cxx +++ b/vcl/source/control/notebookbar.cxx @@ -13,6 +13,7 @@ #include <vcl/taskpanelist.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/implbase.hxx> +#include <vcl/vclevent.hxx> /** * split from the main class since it needs different ref-counting mana @@ -165,17 +166,70 @@ void NotebookBar::DataChanged(const DataChangedEvent& rDCEvt) Control::DataChanged(rDCEvt); } +void NotebookBar::StateChanged(const StateChangedType nStateChange ) +{ + UpdateBackground(); + Control::StateChanged(nStateChange); + Invalidate(); +} + void NotebookBar::UpdateBackground() { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); const BitmapEx aPersona = rStyleSettings.GetPersonaHeader(); - + Wallpaper aWallpaper(aPersona); + aWallpaper.SetStyle(WallpaperStyle::TopRight); if (!aPersona.IsEmpty()) - SetBackground(Wallpaper(aPersona)); + { + SetBackground(aWallpaper); + UpdatePersonaSettings(); + SetSettings( PersonaSettings ); + } else - SetBackground(rStyleSettings.GetDialogColor()); + { + SetBackground(rStyleSettings.GetDialogColor()); + UpdateDefaultSettings(); + SetSettings( DefaultSettings ); + } Invalidate(tools::Rectangle(Point(0,0), GetSizePixel())); } +void NotebookBar::UpdateDefaultSettings() +{ + AllSettings aAllSettings( GetSettings() ); + StyleSettings aStyleSet( aAllSettings.GetStyleSettings() ); + + ::Color aTextColor = aStyleSet.GetFieldTextColor(); + aStyleSet.SetDialogTextColor( aTextColor ); + aStyleSet.SetButtonTextColor( aTextColor ); + aStyleSet.SetRadioCheckTextColor( aTextColor ); + aStyleSet.SetGroupTextColor( aTextColor ); + aStyleSet.SetLabelTextColor( aTextColor ); + aStyleSet.SetWindowTextColor( aTextColor ); + aStyleSet.SetTabTextColor(aTextColor); + aStyleSet.SetToolTextColor(aTextColor); + + aAllSettings.SetStyleSettings(aStyleSet); + DefaultSettings = aAllSettings; +} + +void NotebookBar::UpdatePersonaSettings() +{ + AllSettings aAllSettings( GetSettings() ); + StyleSettings aStyleSet( aAllSettings.GetStyleSettings() ); + + ::Color aTextColor = aStyleSet.GetPersonaMenuBarTextColor().get_value_or(COL_BLACK ); + aStyleSet.SetDialogTextColor( aTextColor ); + aStyleSet.SetButtonTextColor( aTextColor ); + aStyleSet.SetRadioCheckTextColor( aTextColor ); + aStyleSet.SetGroupTextColor( aTextColor ); + aStyleSet.SetLabelTextColor( aTextColor ); + aStyleSet.SetWindowTextColor( aTextColor ); + aStyleSet.SetTabTextColor(aTextColor); + aStyleSet.SetToolTextColor(aTextColor); + + aAllSettings.SetStyleSettings(aStyleSet); + PersonaSettings = aAllSettings; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits