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.klos@collabora.com>
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
This commit is contained in:
Kshitij Pathania
2018-05-14 14:21:56 +05:30
committed by Szymon Kłos
parent a8f8cf72b2
commit e02b3b095e
4 changed files with 143 additions and 3 deletions

View File

@@ -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();
};

View File

@@ -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: */

View File

@@ -48,6 +48,10 @@ public:
void hideSeparators(bool bHide);
void dispose() override;
void ApplyBackground(vcl::Window* pWindow);
void RemoveBackground(vcl::Window* pWindow);
};
#endif

View File

@@ -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: */