DeskCalc: Live update base color again

... but only if you don't have a custom base color set.

Was broken trying to fix color drop regression in hrev50428

We don't want your custom Deskcalc color to get
overridden accidentially.

If you have dropped a custom base color and you want live
updating to work again, drop the current panel background
color.
This commit is contained in:
John Scipione
2016-07-20 10:53:25 -07:00
parent f8056cd9a4
commit d704be3579
2 changed files with 17 additions and 3 deletions
+15 -3
View File
@@ -130,6 +130,8 @@ CalcView::CalcView(BRect frame, rgb_color rgbBaseColor, BMessage* settings)
fBaseColor(rgbBaseColor), fBaseColor(rgbBaseColor),
fExpressionBGColor((rgb_color){ 0, 0, 0, 255 }), fExpressionBGColor((rgb_color){ 0, 0, 0, 255 }),
fHasCustomBaseColor(rgbBaseColor != ui_color(B_PANEL_BACKGROUND_COLOR)),
fWidth(1), fWidth(1),
fHeight(1), fHeight(1),
@@ -167,6 +169,8 @@ CalcView::CalcView(BMessage* archive)
fBaseColor(ui_color(B_PANEL_BACKGROUND_COLOR)), fBaseColor(ui_color(B_PANEL_BACKGROUND_COLOR)),
fExpressionBGColor((rgb_color){ 0, 0, 0, 255 }), fExpressionBGColor((rgb_color){ 0, 0, 0, 255 }),
fHasCustomBaseColor(false),
fWidth(1), fWidth(1),
fHeight(1), fHeight(1),
@@ -231,9 +235,13 @@ CalcView::AttachedToWindow()
void void
CalcView::MessageReceived(BMessage* message) CalcView::MessageReceived(BMessage* message)
{ {
if (message->what == B_COLORS_UPDATED if (message->what == B_COLORS_UPDATED && !fHasCustomBaseColor) {
&& message->HasColor(ui_color_name(B_PANEL_BACKGROUND_COLOR))) { const char* panelBgColorName = ui_color_name(B_PANEL_BACKGROUND_COLOR);
_Colorize(); if (message->HasColor(panelBgColorName)) {
fBaseColor = message->GetColor(panelBgColorName, fBaseColor);
_Colorize();
}
return; return;
} }
@@ -774,6 +782,8 @@ CalcView::Paste(BMessage* message)
// check location of color drop // check location of color drop
if (keypadRect.Contains(dropPoint) && dropColor != NULL) { if (keypadRect.Contains(dropPoint) && dropColor != NULL) {
fBaseColor = *dropColor; fBaseColor = *dropColor;
fHasCustomBaseColor =
fBaseColor != ui_color(B_PANEL_BACKGROUND_COLOR);
_Colorize(); _Colorize();
// redraw // redraw
Invalidate(); Invalidate();
@@ -1099,6 +1109,8 @@ CalcView::_LoadSettings(BMessage* archive)
fExpressionBGColor = *color; fExpressionBGColor = *color;
} }
fHasCustomBaseColor = fBaseColor != ui_color(B_PANEL_BACKGROUND_COLOR);
// load options // load options
fOptions->LoadSettings(archive); fOptions->LoadSettings(archive);
+2
View File
@@ -135,6 +135,8 @@ class CalcView : public BView {
rgb_color fExpressionBGColor; rgb_color fExpressionBGColor;
rgb_color fExpressionTextColor; rgb_color fExpressionTextColor;
bool fHasCustomBaseColor;
// view dimensions // view dimensions
float fWidth; float fWidth;
float fHeight; float fHeight;