diff --git a/src/add-ons/translators/bmp/BMPView.cpp b/src/add-ons/translators/bmp/BMPView.cpp index d6eeadc023..03bef52f3b 100644 --- a/src/add-ons/translators/bmp/BMPView.cpp +++ b/src/add-ons/translators/bmp/BMPView.cpp @@ -28,7 +28,7 @@ BMPView::BMPView(const BRect &frame, const char *name, uint32 resizeMode, : BView(frame, name, resizeMode, flags) { fSettings = settings; - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *titleView = new BStringView("title", B_TRANSLATE("BMP image translator")); diff --git a/src/add-ons/translators/exr/ConfigView.cpp b/src/add-ons/translators/exr/ConfigView.cpp index 60fd78baa9..8b18c666f5 100644 --- a/src/add-ons/translators/exr/ConfigView.cpp +++ b/src/add-ons/translators/exr/ConfigView.cpp @@ -24,7 +24,7 @@ ConfigView::ConfigView(uint32 flags) : BView("EXRTranslator Settings", flags) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *titleView = new BStringView("title", B_TRANSLATE("EXR image translator")); diff --git a/src/add-ons/translators/gif/GIFView.cpp b/src/add-ons/translators/gif/GIFView.cpp index e26bc2d520..8bd7c84ed4 100644 --- a/src/add-ons/translators/gif/GIFView.cpp +++ b/src/add-ons/translators/gif/GIFView.cpp @@ -49,7 +49,7 @@ GIFView::GIFView(TranslatorSettings* settings) BGroupView("GIFView", B_VERTICAL), fSettings(settings) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fTitle = new BStringView("Title", B_TRANSLATE("GIF image translator")); fTitle->SetFont(be_bold_font); diff --git a/src/add-ons/translators/hpgs/ConfigView.cpp b/src/add-ons/translators/hpgs/ConfigView.cpp index 6a0083fd71..6ac6fe8eaa 100644 --- a/src/add-ons/translators/hpgs/ConfigView.cpp +++ b/src/add-ons/translators/hpgs/ConfigView.cpp @@ -22,7 +22,7 @@ ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) : BView(frame, B_TRANSLATE("HPGSTranslator Settings"), resize, flags) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); font_height fontHeight; be_bold_font->GetHeight(&fontHeight); diff --git a/src/add-ons/translators/jpeg/JPEGTranslator.cpp b/src/add-ons/translators/jpeg/JPEGTranslator.cpp index 21ec873fb7..e9b296dd4c 100644 --- a/src/add-ons/translators/jpeg/JPEGTranslator.cpp +++ b/src/add-ons/translators/jpeg/JPEGTranslator.cpp @@ -683,7 +683,7 @@ TranslatorAboutView::TranslatorAboutView(const char* name) BTextView* infoView = new BTextView("info"); infoView->SetText(sTranslatorInfo); - infoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + infoView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); infoView->MakeEditable(false); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) diff --git a/src/add-ons/translators/jpeg2000/JPEG2000Translator.cpp b/src/add-ons/translators/jpeg2000/JPEG2000Translator.cpp index 9d3f3d00a7..1ae99fc46b 100644 --- a/src/add-ons/translators/jpeg2000/JPEG2000Translator.cpp +++ b/src/add-ons/translators/jpeg2000/JPEG2000Translator.cpp @@ -725,7 +725,7 @@ TranslatorAboutView::TranslatorAboutView(const char* name) BTextView* infoView = new BTextView("info"); infoView->SetText(sTranslatorInfo); - infoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + infoView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); infoView->MakeEditable(false); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) diff --git a/src/add-ons/translators/pcx/ConfigView.cpp b/src/add-ons/translators/pcx/ConfigView.cpp index 39056f3844..85f2a28339 100644 --- a/src/add-ons/translators/pcx/ConfigView.cpp +++ b/src/add-ons/translators/pcx/ConfigView.cpp @@ -24,7 +24,7 @@ ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) : BView(frame, B_TRANSLATE("PCXTranslator Settings"), resize, flags) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *titleView = new BStringView("title", B_TRANSLATE("PCX image translator")); diff --git a/src/add-ons/translators/png/PNGView.cpp b/src/add-ons/translators/png/PNGView.cpp index ad5af2e359..71489c8422 100644 --- a/src/add-ons/translators/png/PNGView.cpp +++ b/src/add-ons/translators/png/PNGView.cpp @@ -32,7 +32,7 @@ PNGView::PNGView(const BRect &frame, const char *name, uint32 resizeMode, : BView(frame, name, resizeMode, flags | B_FRAME_EVENTS) { fSettings = settings; - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *titleView = new BStringView("title", B_TRANSLATE("PNG image translator")); @@ -70,7 +70,7 @@ PNGView::PNGView(const BRect &frame, const char *name, uint32 resizeMode, menuField->ResizeToPreferred(); fCopyrightView = new BTextView("PNG copyright"); - fCopyrightView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fCopyrightView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fCopyrightView->SetLowColor(fCopyrightView->ViewColor()); fCopyrightView->MakeEditable(false); fCopyrightView->SetWordWrap(false); diff --git a/src/add-ons/translators/ppm/PPMTranslator.cpp b/src/add-ons/translators/ppm/PPMTranslator.cpp index b81f384f6f..9301882515 100644 --- a/src/add-ons/translators/ppm/PPMTranslator.cpp +++ b/src/add-ons/translators/ppm/PPMTranslator.cpp @@ -451,7 +451,7 @@ public: uint32 flags) : BView(name, flags) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fTitle = new BStringView("title", B_TRANSLATE("PPM image translator")); diff --git a/src/add-ons/translators/raw/ConfigView.cpp b/src/add-ons/translators/raw/ConfigView.cpp index 1d4056484f..a58678019f 100644 --- a/src/add-ons/translators/raw/ConfigView.cpp +++ b/src/add-ons/translators/raw/ConfigView.cpp @@ -25,7 +25,7 @@ const char* kShortName2 = B_TRANSLATE_MARK("RAWTranslator Settings"); ConfigView::ConfigView(uint32 flags) : BView(kShortName2, flags) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *fTitle = new BStringView("title", B_TRANSLATE("RAW image translator")); fTitle->SetFont(be_bold_font); diff --git a/src/add-ons/translators/rtf/ConfigView.cpp b/src/add-ons/translators/rtf/ConfigView.cpp index 4d80f27a78..c0571aaa6b 100644 --- a/src/add-ons/translators/rtf/ConfigView.cpp +++ b/src/add-ons/translators/rtf/ConfigView.cpp @@ -20,7 +20,7 @@ ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) : BView(frame, B_TRANSLATE("RTF-Translator Settings"), resize, flags) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *titleView = new BStringView("title", B_TRANSLATE("Rich Text Format (RTF) translator")); diff --git a/src/add-ons/translators/sgi/SGIView.cpp b/src/add-ons/translators/sgi/SGIView.cpp index 905ba1b7f7..98d80e84eb 100644 --- a/src/add-ons/translators/sgi/SGIView.cpp +++ b/src/add-ons/translators/sgi/SGIView.cpp @@ -123,7 +123,7 @@ SGIView::SGIView(const char* name, uint32 flags, TranslatorSettings* settings) infoView->SetWordWrap(false); infoView->MakeEditable(false); infoView->MakeResizable(true); - infoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + infoView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) diff --git a/src/add-ons/translators/stxt/STXTView.cpp b/src/add-ons/translators/stxt/STXTView.cpp index a51114b34f..3247c86b05 100644 --- a/src/add-ons/translators/stxt/STXTView.cpp +++ b/src/add-ons/translators/stxt/STXTView.cpp @@ -29,7 +29,7 @@ STXTView::STXTView(const BRect &frame, const char *name, uint32 resizeMode, : BView(frame, name, resizeMode, flags) { fSettings = settings; - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *titleView = new BStringView("title", B_TRANSLATE("StyledEdit file translator")); diff --git a/src/add-ons/translators/tga/TGAView.cpp b/src/add-ons/translators/tga/TGAView.cpp index 6caf8bebf0..97c41b7cbe 100644 --- a/src/add-ons/translators/tga/TGAView.cpp +++ b/src/add-ons/translators/tga/TGAView.cpp @@ -47,7 +47,7 @@ TGAView::TGAView(const char *name, uint32 flags, TranslatorSettings *settings) BView(name, flags), fSettings(settings) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fTitle = new BStringView("title", B_TRANSLATE("TGA image translator")); fTitle->SetFont(be_bold_font); diff --git a/src/add-ons/translators/tiff/TIFFView.cpp b/src/add-ons/translators/tiff/TIFFView.cpp index 4c06cf107f..925cc720ff 100644 --- a/src/add-ons/translators/tiff/TIFFView.cpp +++ b/src/add-ons/translators/tiff/TIFFView.cpp @@ -76,8 +76,8 @@ TIFFView::TIFFView(const char* name, uint32 flags, { fSettings = settings; - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - SetLowColor(ViewColor()); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + SetLowUIColor(ViewUIColor()); fTitle = new BStringView("title", B_TRANSLATE("TIFF image translator")); fTitle->SetFont(be_bold_font); diff --git a/src/add-ons/translators/webp/ConfigView.cpp b/src/add-ons/translators/webp/ConfigView.cpp index f3328d10e7..45a1657aa2 100644 --- a/src/add-ons/translators/webp/ConfigView.cpp +++ b/src/add-ons/translators/webp/ConfigView.cpp @@ -55,7 +55,7 @@ ConfigView::ConfigView(TranslatorSettings* settings) : BGroupView(B_TRANSLATE("WebPTranslator Settings"), B_VERTICAL), fSettings(settings) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView* title = new BStringView("title", B_TRANSLATE("WebP image translator")); diff --git a/src/add-ons/translators/wonderbrush/WonderBrushView.cpp b/src/add-ons/translators/wonderbrush/WonderBrushView.cpp index 6a78bb8a77..448d4112a3 100644 --- a/src/add-ons/translators/wonderbrush/WonderBrushView.cpp +++ b/src/add-ons/translators/wonderbrush/WonderBrushView.cpp @@ -51,7 +51,7 @@ WonderBrushView::WonderBrushView(const BRect &frame, const char *name, : BView(frame, name, resize, flags), fSettings(settings) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BStringView *titleView = new BStringView("title", B_TRANSLATE("WonderBrush image translator")); diff --git a/src/bin/desklink/MediaReplicant.cpp b/src/bin/desklink/MediaReplicant.cpp index 2b8d18e9ce..6ce5f7c31d 100644 --- a/src/bin/desklink/MediaReplicant.cpp +++ b/src/bin/desklink/MediaReplicant.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -57,23 +58,17 @@ static const char* kReplicantName = "MediaReplicant"; static const char* kSettingsFile = "x-vnd.Haiku-desklink"; -class VolumeToolTip : public BToolTip { +class VolumeToolTip : public BTextToolTip { public: VolumeToolTip(int32 which = VOLUME_USE_MIXER) : + BTextToolTip(""), fWhich(which) { - fView = new BStringView("", ""); } virtual ~VolumeToolTip() { - delete fView; - } - - virtual BView* View() const - { - return fView; } virtual void AttachedToWindow() @@ -91,17 +86,18 @@ public: if (!Lock()) return; + BTextView* view = (BTextView*)View(); + if (fMuteMessage.Length() != 0) - fView->SetText(fMuteMessage.String()); + view->SetText(fMuteMessage.String()); else { MixerControl control; control.Connect(fWhich); BString text; text.SetToFormat(B_TRANSLATE("%g dB"), control.Volume()); - fView->SetText(text.String()); + view->SetText(text.String()); } - Unlock(); } @@ -111,7 +107,6 @@ public: } private: - BStringView* fView; int32 fWhich; BString fMuteMessage; }; @@ -211,9 +206,7 @@ MediaReplicant::Archive(BMessage* data, bool deep) const void MediaReplicant::AttachedToWindow() { - BView* parent = Parent(); - if (parent) - SetViewColor(parent->ViewColor()); + AdoptParentColors(); BView::AttachedToWindow(); } diff --git a/src/kits/media/DefaultMediaTheme.cpp b/src/kits/media/DefaultMediaTheme.cpp index 031e05aa72..529be6c566 100644 --- a/src/kits/media/DefaultMediaTheme.cpp +++ b/src/kits/media/DefaultMediaTheme.cpp @@ -176,7 +176,7 @@ DynamicScrollView::DynamicScrollView(const char *name, BView *target) fIsDocumentScroller(false) { fContentBounds.Set(-1, -1, -1, -1); - SetViewColor(fTarget->ViewColor()); + AdoptViewColors(fTarget); target->MoveTo(B_ORIGIN); AddChild(target); } @@ -359,7 +359,7 @@ DynamicScrollView::UpdateBars() GroupView::GroupView(BRect frame, const char *name) : BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); } @@ -513,8 +513,7 @@ TitleView::TitleView(BRect frame, const char *title) : BView(frame, title, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW) { fTitle = strdup(title); - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - SetLowColor(ViewColor()); + AdoptSystemColors(); } @@ -530,7 +529,7 @@ TitleView::Draw(BRect updateRect) BRect rect(Bounds()); SetDrawingMode(B_OP_COPY); - SetHighColor(240, 240, 240); + SetHighColor(tint_color(ViewColor(), B_LIGHTEN_2_TINT)); DrawString(fTitle, BPoint(rect.left + 1, rect.bottom - 8)); SetDrawingMode(B_OP_OVER); @@ -897,7 +896,7 @@ DefaultMediaTheme::MakeViewFor(BParameterGroup& group, const BRect* hintRect) if (parameterView == NULL) continue; - parameterView->SetViewColor(view->ViewColor()); + parameterView->AdoptViewColors(view); // ToDo: dunno why this is needed, but the controls // sometimes (!) have a white background without it diff --git a/src/preferences/appearance/APRView.cpp b/src/preferences/appearance/APRView.cpp index b1e587ad25..59a6a9d55a 100644 --- a/src/preferences/appearance/APRView.cpp +++ b/src/preferences/appearance/APRView.cpp @@ -1,11 +1,12 @@ /* - * Copyright 2002-2013 Haiku, Inc. All rights reserved. + * Copyright 2002-2015 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * DarkWyrm, darkwyrm@earthlink.net * Rene Gollent, rene@gollent.com * John Scipione, jscipione@gmail.com + * Joseph Groover */ @@ -27,7 +28,7 @@ #include "APRWindow.h" #include "defs.h" #include "ColorPreview.h" -#include "ColorSet.h" +#include "Colors.h" #include "ColorWhichItem.h" @@ -40,10 +41,9 @@ APRView::APRView(const char* name) : - BView(name, B_WILL_DRAW), - fDefaultSet(ColorSet::DefaultColorSet()) + BView(name, B_WILL_DRAW) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); #if 0 fDecorMenu = new BMenu("Window Style"); @@ -77,15 +77,14 @@ APRView::APRView(const char* name) fAttrList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST); fScrollView = new BScrollView("ScrollView", fAttrList, 0, false, true); - fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fScrollView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); int32 count = color_description_count(); for (int32 i = 0; i < count; i++) { const ColorDescription& description = *get_color_description(i); const char* text = B_TRANSLATE_NOCOLLECT(description.text); color_which which = description.which; - fAttrList->AddItem(new ColorWhichItem(text, which, - fCurrentSet.GetColor(which))); + fAttrList->AddItem(new ColorWhichItem(text, which, ui_color(which))); } BRect wellrect(0, 0, 50, 50); @@ -123,6 +122,7 @@ APRView::AttachedToWindow() fColorPreview->SetTarget(this); fAttrList->Select(0); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); } @@ -162,7 +162,7 @@ APRView::MessageReceived(BMessage *msg) break; fWhich = item->ColorWhich(); - rgb_color color = fCurrentSet.GetColor(fWhich); + rgb_color color = ui_color(fWhich); _SetCurrentColor(color); break; } @@ -177,24 +177,22 @@ APRView::MessageReceived(BMessage *msg) void APRView::LoadSettings() { - int32 count = color_description_count(); - for (int32 i = 0; i < count; i++) { - color_which which = get_color_description(i)->which; - fCurrentSet.SetColor(which, ui_color(which)); - } - - fPrevSet = fCurrentSet; + get_default_colors(&fDefaultColors); + get_current_colors(&fCurrentColors); + fPrevColors = fCurrentColors; } void APRView::SetDefaults() { - fCurrentSet = ColorSet::DefaultColorSet(); + _SetUIColors(fDefaultColors); + _UpdatePreviews(fDefaultColors); - _UpdateAllColors(); + // Use a default color that stands out to show errors clearly + rgb_color color = fDefaultColors.GetColor(ui_color_name(fWhich), + make_color(255, 0, 255)); - rgb_color color = fCurrentSet.GetColor(fWhich); fPicker->SetValue(color); fColorPreview->SetColor(color); fColorPreview->Invalidate(); @@ -206,11 +204,11 @@ APRView::SetDefaults() void APRView::Revert() { - fCurrentSet = fPrevSet; + _SetUIColors(fPrevColors); + _UpdatePreviews(fPrevColors); - _UpdateAllColors(); - - rgb_color color = fCurrentSet.GetColor(fWhich); + rgb_color color = fPrevColors.GetColor(ui_color_name(fWhich), + make_color(255, 0, 255)); fPicker->SetValue(color); fColorPreview->SetColor(color); fColorPreview->Invalidate(); @@ -222,34 +220,22 @@ APRView::Revert() bool APRView::IsDefaultable() { - for (int32 i = color_description_count() - 1; i >= 0; i--) { - color_which which = get_color_description(i)->which; - if (fCurrentSet.GetColor(which) != fDefaultSet.GetColor(which)) - return true; - } - - return false; + return !fDefaultColors.HasSameData(fCurrentColors); } bool APRView::IsRevertable() { - for (int32 i = color_description_count() - 1; i >= 0; i--) { - color_which which = get_color_description(i)->which; - if (fCurrentSet.GetColor(which) != fPrevSet.GetColor(which)) - return true; - } - - return false; + return !fPrevColors.HasSameData(fCurrentColors); } void APRView::_SetCurrentColor(rgb_color color) { - fCurrentSet.SetColor(fWhich, color); set_ui_color(fWhich, color); + fCurrentColors.SetColor(ui_color_name(fWhich), color); int32 currentIndex = fAttrList->CurrentSelection(); ColorWhichItem* item = (ColorWhichItem*)fAttrList->ItemAt(currentIndex); @@ -265,13 +251,26 @@ APRView::_SetCurrentColor(rgb_color color) void -APRView::_UpdateAllColors() +APRView::_SetUIColors(const BMessage& colors) { + set_ui_colors(&colors); + fCurrentColors = colors; +} + + +void +APRView::_UpdatePreviews(const BMessage& colors) +{ + rgb_color color; for (int32 i = color_description_count() - 1; i >= 0; i--) { - color_which which = get_color_description(i)->which; - rgb_color color = fCurrentSet.GetColor(which); - set_ui_color(which, color); - static_cast(fAttrList->ItemAt(i))->SetColor(color); + ColorWhichItem* item = static_cast(fAttrList->ItemAt(i)); + if (item == NULL) + continue; + + color = colors.GetColor(ui_color_name(get_color_description(i)->which), + make_color(255, 0, 255)); + + item->SetColor(color); fAttrList->InvalidateItem(i); } } diff --git a/src/preferences/appearance/APRView.h b/src/preferences/appearance/APRView.h index 6f1317850a..598d385b13 100644 --- a/src/preferences/appearance/APRView.h +++ b/src/preferences/appearance/APRView.h @@ -1,11 +1,12 @@ /* - * Copyright 2002-2012, Haiku. All rights reserved. + * Copyright 2002-2015, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * DarkWyrm (darkwyrm@earthlink.net) * Rene Gollent (rene@gollent.com) * Stephan Aßmus + * Joseph Groover */ #ifndef APR_VIEW_H_ #define APR_VIEW_H_ @@ -28,8 +29,6 @@ #include -#include "ColorSet.h" - class APRWindow; class ColorPreview; @@ -52,7 +51,8 @@ public: private: void _SetCurrentColor(rgb_color color); - void _UpdateAllColors(); + void _SetUIColors(const BMessage& colors); + void _UpdatePreviews(const BMessage& colors); private: BColorControl* fPicker; @@ -65,9 +65,9 @@ private: ColorPreview* fColorPreview; - ColorSet fCurrentSet; - ColorSet fPrevSet; - ColorSet fDefaultSet; + BMessage fPrevColors; + BMessage fDefaultColors; + BMessage fCurrentColors; }; #endif // APR_VIEW_H_ diff --git a/src/preferences/appearance/APRWindow.h b/src/preferences/appearance/APRWindow.h index 1907fc4964..5d1219e59b 100644 --- a/src/preferences/appearance/APRWindow.h +++ b/src/preferences/appearance/APRWindow.h @@ -22,7 +22,7 @@ class AntialiasingSettingsView; class FontView; class LookAndFeelSettingsView; - +#include class APRWindow : public BWindow { public: APRWindow(BRect frame); diff --git a/src/preferences/appearance/AntialiasingSettingsView.cpp b/src/preferences/appearance/AntialiasingSettingsView.cpp index c90b507474..fbe6dca751 100644 --- a/src/preferences/appearance/AntialiasingSettingsView.cpp +++ b/src/preferences/appearance/AntialiasingSettingsView.cpp @@ -26,6 +26,7 @@ #include #include + #include "APRWindow.h" #undef B_TRANSLATION_CONTEXT @@ -115,24 +116,17 @@ AntialiasingSettingsView::AntialiasingSettingsView(const char* name) #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING // subpixelAntialiasingDisabledLabel - BFont infoFont(*be_plain_font); - infoFont.SetFace(B_ITALIC_FACE); - rgb_color infoColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_DARKEN_4_TINT); // TODO: Replace with layout friendly constructor once available. - BRect textBounds = Bounds(); - BTextView* subpixelAntialiasingDisabledLabel = new BTextView( - textBounds, "unavailable label", textBounds, &infoFont, &infoColor, - B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT); - subpixelAntialiasingDisabledLabel->SetText(B_TRANSLATE( + fSubpixelAntialiasingDisabledLabel + = new BTextView("unavailable label"); + fSubpixelAntialiasingDisabledLabel->SetText(B_TRANSLATE( "Subpixel based anti-aliasing in combination with glyph hinting is not " "available in this build of Haiku to avoid possible patent issues. To " "enable this feature, you have to build Haiku yourself and enable " "certain options in the libfreetype configuration header.")); - subpixelAntialiasingDisabledLabel->SetViewColor( - ui_color(B_PANEL_BACKGROUND_COLOR)); - subpixelAntialiasingDisabledLabel->MakeEditable(false); - subpixelAntialiasingDisabledLabel->MakeSelectable(false); + fSubpixelAntialiasingDisabledLabel->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + fSubpixelAntialiasingDisabledLabel->MakeEditable(false); + fSubpixelAntialiasingDisabledLabel->MakeSelectable(false); #endif // !FT_CONFIG_OPTION_SUBPIXEL_RENDERING BLayoutBuilder::Grid<>(this, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) @@ -147,7 +141,7 @@ AntialiasingSettingsView::AntialiasingSettingsView(const char* name) #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING // hinting+subpixel unavailable info - .Add(subpixelAntialiasingDisabledLabel, 0, 3, 2) + .Add(fSubpixelAntialiasingDisabledLabel, 0, 3, 2) #else .Add(BSpaceLayoutItem::CreateGlue(), 0, 3, 2) #endif @@ -157,6 +151,7 @@ AntialiasingSettingsView::AntialiasingSettingsView(const char* name) _SetCurrentAntialiasing(); _SetCurrentHinting(); _SetCurrentAverageWeight(); + _UpdateColors(); } @@ -168,10 +163,10 @@ AntialiasingSettingsView::~AntialiasingSettingsView() void AntialiasingSettingsView::AttachedToWindow() { - if (Parent() != NULL) - SetViewColor(Parent()->ViewColor()); - else - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AdoptParentColors(); + + if (Parent() == NULL) + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fAntialiasingMenu->SetTargetForItems(this); fHintingMenu->SetTargetForItems(this); @@ -224,6 +219,12 @@ AntialiasingSettingsView::MessageReceived(BMessage *msg) Window()->PostMessage(kMsgUpdate); break; } + case B_COLORS_UPDATED: + { + if (msg->HasColor(ui_color_name(B_PANEL_BACKGROUND_COLOR))) + _UpdateColors(); + break; + } default: BView::MessageReceived(msg); } @@ -319,6 +320,23 @@ AntialiasingSettingsView::_SetCurrentAverageWeight() } +void +AntialiasingSettingsView::_UpdateColors() +{ +#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + rgb_color infoColor = disable_color(ui_color(B_PANEL_BACKGROUND_COLOR), + ui_color(B_PANEL_TEXT_COLOR)); + + BFont font; + uint32 mode = 0; + fSubpixelAntialiasingDisabledLabel->GetFontAndColor(&font, &mode); + font.SetFace(B_ITALIC_FACE); + fSubpixelAntialiasingDisabledLabel->SetFontAndColor(&font, mode, + &infoColor); +#endif +} + + void AntialiasingSettingsView::SetDefaults() { diff --git a/src/preferences/appearance/AntialiasingSettingsView.h b/src/preferences/appearance/AntialiasingSettingsView.h index 0813257369..ed7cb32a02 100644 --- a/src/preferences/appearance/AntialiasingSettingsView.h +++ b/src/preferences/appearance/AntialiasingSettingsView.h @@ -12,6 +12,7 @@ class BBox; class BMenuField; class BPopUpMenu; class BSlider; +class BTextView; class AntialiasingSettingsView : public BView { @@ -33,6 +34,7 @@ private: void _BuildHintingMenu(); void _SetCurrentHinting(); void _SetCurrentAverageWeight(); + void _UpdateColors(); protected: float fDivider; @@ -42,6 +44,7 @@ protected: BMenuField* fHintingMenuField; BPopUpMenu* fHintingMenu; BSlider* fAverageWeightControl; + BTextView* fSubpixelAntialiasingDisabledLabel; bool fSavedSubpixelAntialiasing; bool fCurrentSubpixelAntialiasing; diff --git a/src/preferences/appearance/ColorSet.h b/src/preferences/appearance/ColorSet.h deleted file mode 100644 index d65590a8e6..0000000000 --- a/src/preferences/appearance/ColorSet.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2001-2008, Haiku. - * Distributed under the terms of the MIT License. - * - * Authors: - * DarkWyrm - * Rene Gollent - */ -#ifndef COLOR_SET_H -#define COLOR_SET_H - - -#include -#include -#include -#include - -#include - - -typedef struct { - color_which which; - const char* text; -} ColorDescription; - - -const ColorDescription* get_color_description(int32 index); -int32 color_description_count(void); - - -/*! - \class ColorSet ColorSet.h - \brief Encapsulates GUI system colors -*/ -class ColorSet : public BLocker { - public: - ColorSet(); - ColorSet(const ColorSet &cs); - ColorSet & operator=(const ColorSet &cs); - - rgb_color GetColor(int32 which); - void SetColor(color_which which, rgb_color value); - - static ColorSet DefaultColorSet(void); - - inline bool operator==(const ColorSet &other) - { - return fColors == other.fColors; - } - - inline bool operator!=(const ColorSet &other) - { - return fColors != other.fColors; - } - - private: - std::map fColors; -}; - - -#endif // COLOR_SET_H diff --git a/src/preferences/appearance/ColorSet.cpp b/src/preferences/appearance/Colors.cpp similarity index 71% rename from src/preferences/appearance/ColorSet.cpp rename to src/preferences/appearance/Colors.cpp index 1260aeba38..88dd2ef956 100644 --- a/src/preferences/appearance/ColorSet.cpp +++ b/src/preferences/appearance/Colors.cpp @@ -1,11 +1,12 @@ /* - * Copyright 2001-2009, Haiku. + * Copyright 2001-2015, Haiku. * Distributed under the terms of the MIT License. * * Authors: * DarkWyrm * Stephan Aßmus * Rene Gollent + * Joseph Groover */ @@ -20,7 +21,7 @@ #include #include #include -#include "ColorSet.h" +#include "Colors.h" #undef B_TRANSLATION_CONTEXT @@ -41,6 +42,10 @@ static ColorDescription sColorDescriptionTable[] = { { B_NAVIGATION_PULSE_COLOR, B_TRANSLATE_MARK("Navigation pulse") }, { B_SHINE_COLOR, B_TRANSLATE_MARK("Shine") }, { B_SHADOW_COLOR, B_TRANSLATE_MARK("Shadow") }, + { B_LINK_TEXT_COLOR, B_TRANSLATE_MARK("Link text") }, + { B_LINK_HOVER_COLOR, B_TRANSLATE_MARK("Link hover") }, + { B_LINK_VISITED_COLOR, B_TRANSLATE_MARK("Link visited") }, + { B_LINK_ACTIVE_COLOR, B_TRANSLATE_MARK("Link active") }, { B_MENU_BACKGROUND_COLOR, B_TRANSLATE_MARK("Menu background") }, { B_MENU_SELECTED_BACKGROUND_COLOR, B_TRANSLATE_MARK("Selected menu item background") }, @@ -91,70 +96,29 @@ color_description_count(void) } -// #pragma mark - - - -ColorSet::ColorSet() -{ -} - - -/*! - \brief Copy constructor which does a massive number of assignments - \param cs Color set to copy from -*/ -ColorSet::ColorSet(const ColorSet &cs) -{ - *this = cs; -} - - -/*! - \brief Overloaded assignment operator which does a massive number of - assignments. - \param cs Color set to copy from - \return The new values assigned to the color set -*/ -ColorSet& -ColorSet::operator=(const ColorSet &cs) -{ - fColors = cs.fColors; - return *this; -} - - -/*! - \brief Assigns the default system colors to the passed ColorSet object - \param set The ColorSet object to set to defaults -*/ -ColorSet -ColorSet::DefaultColorSet(void) -{ - ColorSet set; - - for (int i = 0; i < sColorDescriptionCount; i++) { - color_which which = get_color_description(i)->which; - set.fColors[which] = - BPrivate::kDefaultColors[color_which_to_index(which)]; - } - return set; -} - - -/*! - \brief Assigns a value to a named color member - \param string name of the color to receive the value - \param value An rgb_color which is the new value of the member -*/ void -ColorSet::SetColor(color_which which, rgb_color value) +get_default_colors(BMessage* message) { - fColors[which] = value; + if (message == NULL) + return; + + for (int32 index = 0; index < kColorWhichCount; ++index) { + color_which which = index_to_color_which(index); + message->AddColor(ui_color_name(which), + BPrivate::kDefaultColors[index]); + } } -rgb_color -ColorSet::GetColor(int32 which) +void +get_current_colors(BMessage* message) { - return fColors[(color_which)which]; + if (message == NULL) + return; + + for (int32 index = 0; index < kColorWhichCount; ++index) { + color_which which = index_to_color_which(index); + message->AddColor(ui_color_name(which), ui_color(which)); + } } + diff --git a/src/preferences/appearance/Colors.h b/src/preferences/appearance/Colors.h new file mode 100644 index 0000000000..5d0e2babb3 --- /dev/null +++ b/src/preferences/appearance/Colors.h @@ -0,0 +1,29 @@ +/* + * Copyright 2001-2015, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Rene Gollent + * Joseph Groover + */ +#ifndef COLORS_H +#define COLORS_H + + +#include + + +typedef struct { + color_which which; + const char* text; +} ColorDescription; + + +const ColorDescription* get_color_description(int32 index); +int32 color_description_count(void); +void get_default_colors(BMessage* storage); +void get_current_colors(BMessage* storage); + + +#endif // COLORS_H diff --git a/src/preferences/appearance/CurView.cpp b/src/preferences/appearance/CurView.cpp index b13021c3d1..a5dd1eb40c 100644 --- a/src/preferences/appearance/CurView.cpp +++ b/src/preferences/appearance/CurView.cpp @@ -51,7 +51,7 @@ CurView::CurView(const BRect &frame, const char *name, int32 resize, int32 flags) :BView(frame,name,resize,flags), settings(B_SIMPLE_DATA) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); cursorset=new CursorSet("Default"); @@ -110,7 +110,7 @@ CurView::CurView(const BRect &frame, const char *name, int32 resize, int32 flags scrollview=new BScrollView("ScrollView",attrlist, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true); AddChild(scrollview); - scrollview->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + scrollview->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); attrlist->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN)); @@ -413,7 +413,7 @@ BitmapView::BitmapView(const BPoint &pt,BMessage *message, const BHandler *handl { SetFont(be_plain_font); bitmap=NULL; - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); SetDrawingMode(B_OP_ALPHA); drawrect=Bounds().InsetByCopy(5,5); } diff --git a/src/preferences/appearance/FontMenu.cpp b/src/preferences/appearance/FontMenu.cpp index 9ec4771375..458ea4c635 100644 --- a/src/preferences/appearance/FontMenu.cpp +++ b/src/preferences/appearance/FontMenu.cpp @@ -61,7 +61,6 @@ font.SetFamilyAndStyle(info.f_family, info.f_style); font.SetSize(info.font_size); SetFont(&font); - SetViewColor(info.background_color); InvalidateLayout(); // font style menus diff --git a/src/preferences/appearance/FontView.cpp b/src/preferences/appearance/FontView.cpp index 74d78e0309..fea39f5f8d 100644 --- a/src/preferences/appearance/FontView.cpp +++ b/src/preferences/appearance/FontView.cpp @@ -64,7 +64,7 @@ FontView::FontView(const char* name) : BView(name, B_WILL_DRAW ) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fPlainView = new FontSelectionView("plain", B_TRANSLATE("Plain font:")); fBoldView = new FontSelectionView("bold", B_TRANSLATE("Bold font:")); diff --git a/src/preferences/appearance/Jamfile b/src/preferences/appearance/Jamfile index a2345dfeb2..e6fcb43b4d 100644 --- a/src/preferences/appearance/Jamfile +++ b/src/preferences/appearance/Jamfile @@ -18,7 +18,7 @@ Preference Appearance : APRView.cpp APRWindow.cpp ColorPreview.cpp - ColorSet.cpp + Colors.cpp ColorWhichItem.cpp # These are currently disabled while everything else is being worked on @@ -41,7 +41,7 @@ DoCatalogs Appearance : APRView.cpp APRWindow.cpp ColorPreview.cpp - ColorSet.cpp + Colors.cpp ColorWhichItem.cpp LookAndFeelSettingsView.cpp FontView.cpp diff --git a/src/preferences/appearance/LookAndFeelSettingsView.cpp b/src/preferences/appearance/LookAndFeelSettingsView.cpp index a3f57129b0..07ae697067 100644 --- a/src/preferences/appearance/LookAndFeelSettingsView.cpp +++ b/src/preferences/appearance/LookAndFeelSettingsView.cpp @@ -132,10 +132,10 @@ LookAndFeelSettingsView::~LookAndFeelSettingsView() void LookAndFeelSettingsView::AttachedToWindow() { - if (Parent() != NULL) - SetViewColor(Parent()->ViewColor()); - else - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AdoptParentColors(); + + if (Parent() == NULL) + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fDecorMenu->SetTargetForItems(this); fDecorInfoButton->SetTarget(this); @@ -325,6 +325,8 @@ LookAndFeelSettingsView::IsRevertable() void LookAndFeelSettingsView::Revert() { - _SetDecor(fSavedDecor); - _SetDoubleScrollBarArrows(fSavedDoubleArrowsValue); + if (IsRevertable()) { + _SetDecor(fSavedDecor); + _SetDoubleScrollBarArrows(fSavedDoubleArrowsValue); + } } diff --git a/src/preferences/appearance/MenuView.cpp b/src/preferences/appearance/MenuView.cpp index c843b2462e..bbce4fa79a 100644 --- a/src/preferences/appearance/MenuView.cpp +++ b/src/preferences/appearance/MenuView.cpp @@ -23,7 +23,7 @@ MenuView::MenuView(BRect frame, const char *name, int32 resize, int32 flags) : BView(frame, name, resize, flags) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); get_menu_info(&menuinfo); revertinfo = menuinfo; diff --git a/src/preferences/bluetooth/BluetoothDeviceView.cpp b/src/preferences/bluetooth/BluetoothDeviceView.cpp index cb8203edee..633adc3768 100644 --- a/src/preferences/bluetooth/BluetoothDeviceView.cpp +++ b/src/preferences/bluetooth/BluetoothDeviceView.cpp @@ -67,7 +67,7 @@ BluetoothDeviceView::BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice, fIcon = new BView(BRect(0, 0, 32 - 1, 32 - 1), "Icon", B_FOLLOW_ALL, B_WILL_DRAW); - fIcon->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fIcon->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); SetBluetoothDevice(bDevice); diff --git a/src/preferences/bluetooth/BluetoothSettingsView.cpp b/src/preferences/bluetooth/BluetoothSettingsView.cpp index 54a1864094..0e9a6a06c9 100644 --- a/src/preferences/bluetooth/BluetoothSettingsView.cpp +++ b/src/preferences/bluetooth/BluetoothSettingsView.cpp @@ -131,7 +131,7 @@ BluetoothSettingsView::AttachedToWindow() if (Parent() != NULL) SetViewColor(Parent()->ViewColor()); else - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fPolicyMenu->SetTargetForItems(this); fClassMenu->SetTargetForItems(this); diff --git a/src/preferences/bluetooth/InquiryPanel.cpp b/src/preferences/bluetooth/InquiryPanel.cpp index 7f6560e303..99b6d1f3bf 100644 --- a/src/preferences/bluetooth/InquiryPanel.cpp +++ b/src/preferences/bluetooth/InquiryPanel.cpp @@ -111,7 +111,7 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice) fLocalDevice = LocalDevice::GetLocalDevice(); fMessage = new BTextView("description", B_WILL_DRAW); - fMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fMessage->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fMessage->SetLowColor(fMessage->ViewColor()); fMessage->MakeEditable(false); fMessage->MakeSelectable(false); @@ -127,7 +127,7 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice) fRemoteList->SetSelectionMessage(new BMessage(kMsgSelected)); fScrollView = new BScrollView("ScrollView", fRemoteList, 0, false, true); - fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fScrollView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); if (fLocalDevice != NULL) { fMessage->SetText(B_TRANSLATE( diff --git a/src/preferences/bluetooth/RemoteDevicesView.cpp b/src/preferences/bluetooth/RemoteDevicesView.cpp index e4ebf54560..0a1e6a39e2 100644 --- a/src/preferences/bluetooth/RemoteDevicesView.cpp +++ b/src/preferences/bluetooth/RemoteDevicesView.cpp @@ -41,7 +41,7 @@ using namespace Bluetooth; RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags) : BView(name, flags) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); addButton = new BButton("add", B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddDevices)); @@ -66,7 +66,7 @@ RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags) fDeviceList = new BListView("DeviceList", B_SINGLE_SELECTION_LIST); fScrollView = new BScrollView("ScrollView", fDeviceList, 0, false, true); - fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fScrollView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); SetLayout(new BGroupLayout(B_VERTICAL)); diff --git a/src/preferences/datatranslations/DataTranslationsWindow.cpp b/src/preferences/datatranslations/DataTranslationsWindow.cpp index c1ce98299c..6382a1188b 100644 --- a/src/preferences/datatranslations/DataTranslationsWindow.cpp +++ b/src/preferences/datatranslations/DataTranslationsWindow.cpp @@ -36,6 +36,7 @@ #include #include + #include "DataTranslations.h" #include "DataTranslationsSettings.h" #include "TranslatorListView.h" @@ -166,7 +167,7 @@ DataTranslationsWindow::_ShowConfigView(int32 id) if (ret != B_OK) return ret; - fConfigView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fConfigView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); // force config views to all have the same color fRightBox->AddChild(fConfigView); @@ -192,17 +193,18 @@ DataTranslationsWindow::_ShowInfoView() } - BTextView* view = new BTextView("info text"); - view->MakeEditable(false); - view->MakeSelectable(false); - view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - view->SetText(B_TRANSLATE( + fInfoText = new BTextView("info text"); + fInfoText->MakeEditable(false); + fInfoText->MakeSelectable(false); + fInfoText->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + fInfoText->SetText(B_TRANSLATE( "Use this control panel to set default values for translators, " "to be used when no other settings are specified by an application.")); + rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); + fInfoText->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); BGroupView* group = new BGroupView(B_VERTICAL); - group->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - group->AddChild(view); + group->AddChild(fInfoText); float spacing = be_control_look->DefaultItemSpacing(); group->GroupLayout()->SetInsets(spacing, spacing, spacing, spacing); fRightBox->AddChild(group); @@ -213,6 +215,7 @@ DataTranslationsWindow::_ShowInfoView() void DataTranslationsWindow::_SetupViews() { + fInfoText = NULL; fConfigView = NULL; // This is NULL until a translator is // selected from the listview @@ -356,6 +359,18 @@ DataTranslationsWindow::MessageReceived(BMessage* message) break; } + case B_COLORS_UPDATED: + { + if (fInfoText == NULL + || fInfoText->Parent() == NULL) + break; + + rgb_color color; + if (message->FindColor(ui_color_name(B_PANEL_TEXT_COLOR), &color) == B_OK) + fInfoText->SetFontAndColor(be_plain_font, B_FONT_ALL, &color); + break; + } + case B_TRANSLATOR_ADDED: { int32 index = 0, id; diff --git a/src/preferences/datatranslations/DataTranslationsWindow.h b/src/preferences/datatranslations/DataTranslationsWindow.h index c4d7b1bdb4..fa2c0cbd7d 100644 --- a/src/preferences/datatranslations/DataTranslationsWindow.h +++ b/src/preferences/datatranslations/DataTranslationsWindow.h @@ -22,6 +22,7 @@ class BTranslatorReleaseDelegate; +class BTextView; class DataTranslationsWindow : public BWindow { @@ -48,6 +49,7 @@ private: BView* fConfigView; IconView* fIconView; BButton* fButton; + BTextView* fInfoText; }; diff --git a/src/preferences/datatranslations/Jamfile b/src/preferences/datatranslations/Jamfile index 8c2ef905db..adc12d532c 100644 --- a/src/preferences/datatranslations/Jamfile +++ b/src/preferences/datatranslations/Jamfile @@ -2,7 +2,7 @@ SubDir HAIKU_TOP src preferences datatranslations ; UseLibraryHeaders lp_solve linprog alm ; -UsePrivateHeaders shared ; +UsePrivateHeaders interface shared ; Preference DataTranslations : DataTranslations.cpp diff --git a/src/preferences/filetypes/ApplicationTypesWindow.cpp b/src/preferences/filetypes/ApplicationTypesWindow.cpp index c776f33410..0afb8632f1 100644 --- a/src/preferences/filetypes/ApplicationTypesWindow.cpp +++ b/src/preferences/filetypes/ApplicationTypesWindow.cpp @@ -218,7 +218,7 @@ ApplicationTypesWindow::ApplicationTypesWindow(const BMessage& settings) fDescriptionLabel = new StringView(B_TRANSLATE("Description:"), NULL); fDescriptionLabel->LabelView()->SetExplicitAlignment(labelAlignment); fDescriptionView = new BTextView("description"); - fDescriptionView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fDescriptionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fDescriptionView->SetLowColor(fDescriptionView->ViewColor()); fDescriptionView->MakeEditable(false); diff --git a/src/preferences/filetypes/AttributeWindow.cpp b/src/preferences/filetypes/AttributeWindow.cpp index 693d79e309..da958f7501 100644 --- a/src/preferences/filetypes/AttributeWindow.cpp +++ b/src/preferences/filetypes/AttributeWindow.cpp @@ -129,7 +129,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, typeMenuField->SetAlignment(B_ALIGN_RIGHT); // we must set the color manually when adding a menuField directly // into a window. - typeMenuField->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + typeMenuField->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); typeMenuField->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fVisibleCheckBox = new BCheckBox("visible", B_TRANSLATE("Visible"), diff --git a/src/preferences/filetypes/IconView.cpp b/src/preferences/filetypes/IconView.cpp index b95781c040..12bf32e989 100644 --- a/src/preferences/filetypes/IconView.cpp +++ b/src/preferences/filetypes/IconView.cpp @@ -544,10 +544,7 @@ IconView::~IconView() void IconView::AttachedToWindow() { - if (Parent()) - SetViewColor(Parent()->ViewColor()); - else - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AdoptParentColors(); fTarget = this; diff --git a/src/preferences/fonts/FontView.cpp b/src/preferences/fonts/FontView.cpp index 0634fe49e1..9208bd6999 100644 --- a/src/preferences/fonts/FontView.cpp +++ b/src/preferences/fonts/FontView.cpp @@ -52,7 +52,7 @@ add_font_selection_view(BGridLayout* layout, FontSelectionView* view, FontView::FontView() : BView("Fonts", B_WILL_DRAW ) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fPlainView = new FontSelectionView("plain", B_TRANSLATE("Plain font:")); fBoldView = new FontSelectionView("bold", B_TRANSLATE("Bold font:")); diff --git a/src/preferences/joysticks/CalibWin.cpp b/src/preferences/joysticks/CalibWin.cpp index e144d3c321..1ecd17e6d0 100644 --- a/src/preferences/joysticks/CalibWin.cpp +++ b/src/preferences/joysticks/CalibWin.cpp @@ -54,7 +54,7 @@ CalibWin::CalibWin(BRect frame,const char *title, window_look look, fView = new BView(Bounds(),"View3", B_FOLLOW_NONE,B_WILL_DRAW); - fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); // Adding object fBox->AddChild(fStringView3); diff --git a/src/preferences/joysticks/JoyWin.cpp b/src/preferences/joysticks/JoyWin.cpp index f1e137f807..8fd867fc09 100644 --- a/src/preferences/joysticks/JoyWin.cpp +++ b/src/preferences/joysticks/JoyWin.cpp @@ -88,7 +88,7 @@ JoyWin::JoyWin(BRect frame, const char *title) B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE, B_PLAIN_BORDER); - box->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + box->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); // Add listViews with their scrolls box->AddChild(new BScrollView("PortScroll", fGamePortL, diff --git a/src/preferences/joysticks/MessageWin.cpp b/src/preferences/joysticks/MessageWin.cpp index c3d7e896e7..da74ee1b07 100644 --- a/src/preferences/joysticks/MessageWin.cpp +++ b/src/preferences/joysticks/MessageWin.cpp @@ -21,7 +21,7 @@ MessageWin::MessageWin(BRect parentFrame, const char *title, : BWindow(parentFrame ,title ,look ,feel, flags, workspace) { fBox = new BBox(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER); - fBox->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fBox->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fBox->SetLowColor(fBox->ViewColor()); // Rects for the text view @@ -32,7 +32,7 @@ MessageWin::MessageWin(BRect parentFrame, const char *title, fText = new BTextView(outside, "message", insider, B_FOLLOW_NONE, B_WILL_DRAW); fText->MakeEditable(false); - fText->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fText->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fText->SetLowColor(fText->ViewColor()); fBox->AddChild(fText); diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp b/src/preferences/keymap/KeyboardLayoutView.cpp index 0eec89afb6..74e901abb8 100644 --- a/src/preferences/keymap/KeyboardLayoutView.cpp +++ b/src/preferences/keymap/KeyboardLayoutView.cpp @@ -765,6 +765,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key, { rgb_color base = key->dark ? kDarkColor : kBrightColor; rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color keyLabelColor = make_color(0, 0, 0, 255); key_kind keyKind = kNormalKey; int32 deadKey = 0; bool secondDeadKey = false; @@ -795,7 +796,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key, _GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text)); be_control_look->DrawLabel(view, text, rect, updateRect, - base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE)); + base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE), &keyLabelColor); } else if (key->shape == kEnterKeyShape) { BRect topLeft = rect; BRect topRight = rect; @@ -875,7 +876,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key, // draw the button label be_control_look->DrawLabel(view, text, rect, updateRect, - base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE)); + base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE), &keyLabelColor); // reset the clipping region view->ConstrainClippingRegion(NULL); diff --git a/src/preferences/locale/FormatSettingsView.cpp b/src/preferences/locale/FormatSettingsView.cpp index 8de1d675ab..826ff96c51 100644 --- a/src/preferences/locale/FormatSettingsView.cpp +++ b/src/preferences/locale/FormatSettingsView.cpp @@ -227,6 +227,8 @@ FormatSettingsView::FormatSettingsView() .Add(BSpaceLayoutItem::CreateGlue(), 2, 1) .View()); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + BLayoutBuilder::Group<>(this, B_VERTICAL) .Add(fUseLanguageStringsCheckBox) .Add(fDateBox) diff --git a/src/preferences/mail/AutoConfigView.cpp b/src/preferences/mail/AutoConfigView.cpp index 347df84546..c9ec5454ae 100644 --- a/src/preferences/mail/AutoConfigView.cpp +++ b/src/preferences/mail/AutoConfigView.cpp @@ -85,6 +85,13 @@ AutoConfigView::AutoConfigView(AutoConfig &config) void AutoConfigView::AttachedToWindow() { + // Resize the view to fit the contents properly + BRect rect = Bounds(); + float newHeight = fNameView->Frame().bottom + 20 + 2; + newHeight += InnerFrame().top; + ResizeTo(rect.Width(), newHeight); + + AdoptParentColors(); fEmailView->SetTarget(this); fEmailView->MakeFocus(true); } @@ -275,6 +282,8 @@ ServerSettingsView::ServerSettingsView(const account_info &info) fOutboundEncrItemStart(NULL), fImageID(-1) { + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + fInboundAccount = true; fOutboundAccount = true; diff --git a/src/preferences/mail/AutoConfigWindow.cpp b/src/preferences/mail/AutoConfigWindow.cpp index c5fe997f49..753e485478 100644 --- a/src/preferences/mail/AutoConfigWindow.cpp +++ b/src/preferences/mail/AutoConfigWindow.cpp @@ -28,6 +28,9 @@ #define B_TRANSLATION_CONTEXT "AutoConfigWindow" +const float kSpacing = 10; + + AutoConfigWindow::AutoConfigWindow(BRect rect, ConfigWindow *parent) : BWindow(rect, B_TRANSLATE("Create new account"), B_TITLED_WINDOW_LOOK, @@ -61,6 +64,10 @@ AutoConfigWindow::AutoConfigWindow(BRect rect, ConfigWindow *parent) .Add(fBackButton) .Add(fNextButton); + // determine the proper height + float newHeight = fMainView->Frame().bottom + buttonHeight + kSpacing * 2; + ResizeBy(0, newHeight - Bounds().Height()); + // Add a shortcut to close the window using Command-W AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); } diff --git a/src/preferences/mail/ConfigWindow.cpp b/src/preferences/mail/ConfigWindow.cpp index 4acbd1e4c1..1d46ec9d32 100644 --- a/src/preferences/mail/ConfigWindow.cpp +++ b/src/preferences/mail/ConfigWindow.cpp @@ -184,7 +184,7 @@ class BitmapView : public BView { virtual void AttachedToWindow() { - SetViewColor(Parent()->ViewColor()); + AdoptParentColors(); } virtual void Draw(BRect updateRect) @@ -229,7 +229,7 @@ ConfigWindow::ConfigWindow() fConfigView = new BView(NULL, 0); fConfigView->SetLayout(new BGroupLayout(B_VERTICAL)); fConfigView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); - fConfigView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fConfigView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BScrollView* scroller = new BScrollView(NULL, fAccountsListView, 0, false, true); @@ -370,26 +370,34 @@ ConfigWindow::_BuildHowToView() } } - BTextView* text = new BTextView(NULL, B_WILL_DRAW); - text->SetAlignment(B_ALIGN_CENTER); - text->SetText(B_TRANSLATE( + fHowToTextView = new BTextView(NULL, B_WILL_DRAW); + fHowToTextView->SetAlignment(B_ALIGN_CENTER); + fHowToTextView->SetText(B_TRANSLATE( "Create a new account with the Add button.\n\n" "Remove an account with the Remove button on the selected item.\n\n" "Select an item in the list to change its settings.")); - text->MakeEditable(false); - text->MakeSelectable(false); - float fontFactor = be_plain_font->Size() / 12.0f; - text->SetExplicitPreferredSize(BSize(300 * fontFactor,400 * fontFactor)); + + fHowToTextView->MakeEditable(false); + fHowToTextView->MakeSelectable(false); + + BFont font(be_plain_font); + float fontFactor = font.Size() / 12.0f; + + fHowToTextView->SetExplicitPreferredSize( + BSize(300 * fontFactor,400 * fontFactor)); + + rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); + fHowToTextView->SetFontAndColor(&font, B_FONT_ALL, &textColor); BLayoutBuilder::Group<>(groupView, B_VERTICAL) .AddGlue() - .Add(text) + .Add(fHowToTextView) .AddGlue(); if (bitmapView != NULL) groupView->GetLayout()->AddView(1, bitmapView); - text->SetViewColor(groupView->ViewColor()); + fHowToTextView->AdoptSystemColors(); return groupView; } @@ -517,6 +525,17 @@ ConfigWindow::MessageReceived(BMessage *msg) AutoConfigWindow *autoConfigWindow = NULL; switch (msg->what) { + case B_COLORS_UPDATED: + { + rgb_color textColor; + if (msg->FindColor(ui_color_name(B_PANEL_TEXT_COLOR), &textColor) + == B_OK) { + BFont font; + fHowToTextView->SetFontAndColor(&font, 0, &textColor); + } + break; + } + case kMsgAccountsRightClicked: { BPoint point; diff --git a/src/preferences/mail/ConfigWindow.h b/src/preferences/mail/ConfigWindow.h index 84336e0243..5b7bf88d1e 100644 --- a/src/preferences/mail/ConfigWindow.h +++ b/src/preferences/mail/ConfigWindow.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2012, Haiku Inc. All rights reserved. + * Copyright 2004-2015, Haiku Inc. All rights reserved. * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved. * Copyright 2011, Clemens Zeidler * @@ -23,6 +23,7 @@ class BListView; class BButton; class BMenuField; class BMailSettings; +class BTextView; class CenterContainer; @@ -90,6 +91,7 @@ private: BCheckBox* fCheckMailCheckBox; BTextControl* fIntervalControl; BMenuField* fStatusModeField; + BTextView* fHowToTextView; bool fSaveSettings; BObjectList fAccounts; diff --git a/src/preferences/mail/Jamfile b/src/preferences/mail/Jamfile index 2c1250cc33..1aa95086fc 100644 --- a/src/preferences/mail/Jamfile +++ b/src/preferences/mail/Jamfile @@ -1,7 +1,7 @@ SubDir HAIKU_TOP src preferences mail ; UsePublicHeaders [ FDirName add-ons mail_daemon ] ; -UsePrivateHeaders mail ; +UsePrivateHeaders interface mail ; SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ; diff --git a/src/preferences/media/MediaWindow.cpp b/src/preferences/media/MediaWindow.cpp index b1f2d7b168..0e9a9d48ca 100644 --- a/src/preferences/media/MediaWindow.cpp +++ b/src/preferences/media/MediaWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2012, Haiku, Inc. + * Copyright 2003-2015, Haiku, Inc. * Distributed under the terms of the MIT license. * * Authors: @@ -397,7 +397,7 @@ MediaWindow::_InitWindow() fContentLayout = new BCardLayout(); new BView("content view", 0, fContentLayout); - fContentLayout->Owner()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fContentLayout->Owner()->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fContentLayout->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fAudioView = new AudioSettingsView(); diff --git a/src/preferences/mouse/MouseView.cpp b/src/preferences/mouse/MouseView.cpp index 025b3f6994..4a28bf5c20 100644 --- a/src/preferences/mouse/MouseView.cpp +++ b/src/preferences/mouse/MouseView.cpp @@ -141,10 +141,7 @@ MouseView::GetPreferredSize(float* _width, float* _height) void MouseView::AttachedToWindow() { - if (Parent() != NULL) - SetViewColor(Parent()->ViewColor()); - else - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AdoptParentColors(); UpdateFromSettings(); _CreateButtonsPicture(); diff --git a/src/preferences/network/DialUpAddOn/DialUpView.cpp b/src/preferences/network/DialUpAddOn/DialUpView.cpp index 6210b9a955..7f7c4b3122 100644 --- a/src/preferences/network/DialUpAddOn/DialUpView.cpp +++ b/src/preferences/network/DialUpAddOn/DialUpView.cpp @@ -115,7 +115,7 @@ DialUpView::DialUpView(BRect frame) { BRect bounds = Bounds(); // for caching - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); // add messenger to us so add-ons can contact us BMessenger messenger(this); diff --git a/src/preferences/network/DialUpAddOn/GeneralAddon.cpp b/src/preferences/network/DialUpAddOn/GeneralAddon.cpp index 91f25a96cd..be54a6bf03 100644 --- a/src/preferences/network/DialUpAddOn/GeneralAddon.cpp +++ b/src/preferences/network/DialUpAddOn/GeneralAddon.cpp @@ -431,7 +431,7 @@ GeneralView::GeneralView(GeneralAddon *addon, BRect frame) // B_FOLLOW_NONE, 0); // BControl automatically sets the view color when attached (we want that) fAuthenticationView = new BView(rect, "authenticationView", B_FOLLOW_NONE, 0); - fAuthenticationView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fAuthenticationView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); rect = fAuthenticationView->Bounds(); rect.bottom = rect.top + 20; fUsername = new BTextControl(rect, "username", kLabelName, NULL, NULL); diff --git a/src/preferences/network/DialUpAddOn/TextRequestDialog.cpp b/src/preferences/network/DialUpAddOn/TextRequestDialog.cpp index 514e7bc8c9..d1285f6dc9 100644 --- a/src/preferences/network/DialUpAddOn/TextRequestDialog.cpp +++ b/src/preferences/network/DialUpAddOn/TextRequestDialog.cpp @@ -50,7 +50,7 @@ TextRequestDialog::TextRequestDialog(const char *title, const char *information, { BRect rect = Bounds(); BView *backgroundView = new BView(rect, "background", B_FOLLOW_ALL_SIDES, 0); - backgroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + backgroundView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); rect.InsetBy(5, 5); rect.bottom = rect.top; // init @@ -60,7 +60,7 @@ TextRequestDialog::TextRequestDialog(const char *title, const char *information, textRect.OffsetTo(0, 0); fTextView = new BTextView(rect, "TextView", textRect, B_FOLLOW_NONE, B_WILL_DRAW); - fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fTextView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fTextView->MakeSelectable(false); fTextView->MakeEditable(false); fTextView->SetText(information); diff --git a/src/preferences/network/NetworkWindow.cpp b/src/preferences/network/NetworkWindow.cpp index d51f5f9b98..56458c2fe1 100644 --- a/src/preferences/network/NetworkWindow.cpp +++ b/src/preferences/network/NetworkWindow.cpp @@ -130,7 +130,7 @@ NetworkWindow::NetworkWindow() fAddOnShellView = new BView("add-on shell", 0, new BGroupLayout(B_VERTICAL)); - fAddOnShellView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fAddOnShellView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fInterfaceView = new InterfaceView(); diff --git a/src/preferences/network/ServiceView.cpp b/src/preferences/network/ServiceView.cpp index efa045352a..4b4dc01212 100644 --- a/src/preferences/network/ServiceView.cpp +++ b/src/preferences/network/ServiceView.cpp @@ -41,7 +41,7 @@ ServiceView::ServiceView(const char* name, const char* executable, BTextView* descriptionView = new BTextView("description"); descriptionView->SetText(description); - descriptionView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + descriptionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); descriptionView->MakeEditable(false); fEnableButton = new BButton("toggler", B_TRANSLATE("Enable"), diff --git a/src/preferences/screen/MonitorView.cpp b/src/preferences/screen/MonitorView.cpp index bf15d9f266..b390d41806 100644 --- a/src/preferences/screen/MonitorView.cpp +++ b/src/preferences/screen/MonitorView.cpp @@ -47,10 +47,7 @@ void MonitorView::AttachedToWindow() { SetViewColor(B_TRANSPARENT_COLOR); - if (Parent()) - fBackgroundColor = Parent()->ViewColor(); - else - fBackgroundColor = ui_color(B_PANEL_BACKGROUND_COLOR); + fBackgroundColor = ui_color(B_PANEL_BACKGROUND_COLOR); _UpdateDPI(); } @@ -156,6 +153,12 @@ void MonitorView::MessageReceived(BMessage* message) { switch (message->what) { + case B_COLORS_UPDATED: + { + message->FindColor(ui_color_name(B_PANEL_BACKGROUND_COLOR), + &fBackgroundColor); + break; + } case UPDATE_DESKTOP_MSG: { int32 width, height; diff --git a/src/preferences/screen/RefreshWindow.cpp b/src/preferences/screen/RefreshWindow.cpp index 7b1df327c1..da1b47521a 100644 --- a/src/preferences/screen/RefreshWindow.cpp +++ b/src/preferences/screen/RefreshWindow.cpp @@ -35,7 +35,7 @@ RefreshWindow::RefreshWindow(BPoint position, float current, float min, float ma max = floorf(max); BView* topView = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW); - topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + topView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); AddChild(topView); BRect rect = Bounds().InsetByCopy(8, 8); diff --git a/src/preferences/screen/ScreenSettings.cpp b/src/preferences/screen/ScreenSettings.cpp index 5e2e97f389..9f776c06eb 100644 --- a/src/preferences/screen/ScreenSettings.cpp +++ b/src/preferences/screen/ScreenSettings.cpp @@ -21,7 +21,8 @@ static const char* kSettingsFileName = "Screen_data"; ScreenSettings::ScreenSettings() { - fWindowFrame.Set(-1, -1, 450, 250); + fWindowFrame.Set(0, 0, 450, 250); + BPoint offset; BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { @@ -29,8 +30,10 @@ ScreenSettings::ScreenSettings() BFile file(path.Path(), B_READ_ONLY); if (file.InitCheck() == B_OK) - file.Read(&fWindowFrame, sizeof(BRect)); + file.Read(&offset, sizeof(BPoint)); } + + fWindowFrame.OffsetBy(offset); } @@ -42,9 +45,11 @@ ScreenSettings::~ScreenSettings() path.Append(kSettingsFileName); + BPoint offset = fWindowFrame.LeftTop(); + BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); if (file.InitCheck() == B_OK) - file.Write(&fWindowFrame, sizeof(BRect)); + file.Write(&offset, sizeof(BPoint)); } diff --git a/src/preferences/screensaver/PasswordWindow.cpp b/src/preferences/screensaver/PasswordWindow.cpp index 46b43c2597..51c72b5033 100644 --- a/src/preferences/screensaver/PasswordWindow.cpp +++ b/src/preferences/screensaver/PasswordWindow.cpp @@ -57,7 +57,7 @@ PasswordWindow::_Setup() float spacing = be_control_look->DefaultItemSpacing(); BView* topView = new BView("topView", B_WILL_DRAW); - topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + topView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); topView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); BBox* networkBox = new BBox("networkBox"); diff --git a/src/preferences/screensaver/PreviewView.cpp b/src/preferences/screensaver/PreviewView.cpp index 986f2f49f9..8301089a0e 100644 --- a/src/preferences/screensaver/PreviewView.cpp +++ b/src/preferences/screensaver/PreviewView.cpp @@ -61,7 +61,7 @@ PreviewView::PreviewView(const char* name) fSaverView(NULL), fNoPreview(NULL) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BGroupLayout* layout = new BGroupLayout(B_VERTICAL); // We draw the "monitor" around the preview, hence the strange insets. diff --git a/src/preferences/screensaver/ScreenCornerSelector.cpp b/src/preferences/screensaver/ScreenCornerSelector.cpp index 17ac75e376..f403ab91ad 100644 --- a/src/preferences/screensaver/ScreenCornerSelector.cpp +++ b/src/preferences/screensaver/ScreenCornerSelector.cpp @@ -35,7 +35,7 @@ ScreenCornerSelector::ScreenCornerSelector(BRect frame, const char* name, fCurrentCorner(NO_CORNER), fPreviousCorner(-1) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); } diff --git a/src/preferences/screensaver/ScreenSaverWindow.cpp b/src/preferences/screensaver/ScreenSaverWindow.cpp index 8bd3e6a652..b69990859e 100644 --- a/src/preferences/screensaver/ScreenSaverWindow.cpp +++ b/src/preferences/screensaver/ScreenSaverWindow.cpp @@ -119,6 +119,7 @@ public: void UpdateStatus(); private: + void _UpdateColors(); ScreenSaverSettings& fSettings; uint32 fTurnOffScreenFlags; @@ -129,6 +130,9 @@ private: BCheckBox* fTurnOffCheckBox; TimeSlider* fTurnOffSlider; + BTextView* fFadeNeverText; + BTextView* fFadeNowText; + BCheckBox* fPasswordCheckBox; TimeSlider* fPasswordSlider; BButton* fPasswordButton; @@ -208,7 +212,7 @@ TimeSlider::TimeSlider(const char* name, uint32 changedMessage, BSlider(name, B_TRANSLATE("30 seconds"), new BMessage(changedMessage), 0, kTimeUnitCount - 1, B_HORIZONTAL, B_TRIANGLE_THUMB) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); SetModificationMessage(new BMessage(updateMessage)); SetBarThickness(10); } @@ -268,7 +272,7 @@ FadeView::FadeView(const char* name, ScreenSaverSettings& settings) BView(name, B_WILL_DRAW), fSettings(settings) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); font_height fontHeight; be_plain_font->GetHeight(&fontHeight); @@ -290,13 +294,14 @@ FadeView::FadeView(const char* name, ScreenSaverSettings& settings) kMsgRunSliderUpdate); // Turn Off - rgb_color textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_DISABLED_LABEL_TINT); + rgb_color textColor = disable_color(ui_color(B_PANEL_TEXT_COLOR), + ViewColor()); + fTurnOffNotSupported = new BTextView("not_supported", be_plain_font, &textColor, B_WILL_DRAW); fTurnOffNotSupported->SetExplicitMinSize(BSize(B_SIZE_UNSET, 3 + textHeight * 3)); - fTurnOffNotSupported->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fTurnOffNotSupported->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fTurnOffNotSupported->MakeEditable(false); fTurnOffNotSupported->MakeSelectable(false); fTurnOffNotSupported->SetText( @@ -331,23 +336,23 @@ FadeView::FadeView(const char* name, ScreenSaverSettings& settings) fFadeNow = new ScreenCornerSelector(monitorRect, "FadeNow", new BMessage(kMsgFadeCornerChanged), B_FOLLOW_NONE); - BTextView* fadeNowText = new BTextView("FadeNowText", B_WILL_DRAW); - fadeNowText->SetExplicitMinSize(BSize(B_SIZE_UNSET, + fFadeNowText = new BTextView("FadeNowText", B_WILL_DRAW); + fFadeNowText->SetExplicitMinSize(BSize(B_SIZE_UNSET, 4 + textHeight * 4)); - fadeNowText->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - fadeNowText->MakeEditable(false); - fadeNowText->MakeSelectable(false); - fadeNowText->SetText(B_TRANSLATE("Fade now when mouse is here")); + fFadeNowText->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + fFadeNowText->MakeEditable(false); + fFadeNowText->MakeSelectable(false); + fFadeNowText->SetText(B_TRANSLATE("Fade now when mouse is here")); fFadeNever = new ScreenCornerSelector(monitorRect, "FadeNever", new BMessage(kMsgNeverFadeCornerChanged), B_FOLLOW_NONE); - BTextView* fadeNeverText = new BTextView("FadeNeverText", B_WILL_DRAW); - fadeNeverText->SetExplicitMinSize(BSize(B_SIZE_UNSET, + fFadeNeverText = new BTextView("FadeNeverText", B_WILL_DRAW); + fFadeNeverText->SetExplicitMinSize(BSize(B_SIZE_UNSET, 4 + textHeight * 4)); - fadeNeverText->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - fadeNeverText->MakeEditable(false); - fadeNeverText->MakeSelectable(false); - fadeNeverText->SetText(B_TRANSLATE("Don't fade when mouse is here")); + fFadeNeverText->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + fFadeNeverText->MakeEditable(false); + fFadeNeverText->MakeSelectable(false); + fFadeNeverText->SetText(B_TRANSLATE("Don't fade when mouse is here")); box->AddChild(BLayoutBuilder::Group<>(B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING, 0, B_USE_DEFAULT_SPACING, @@ -371,12 +376,12 @@ FadeView::FadeView(const char* name, ScreenSaverSettings& settings) .AddGroup(B_HORIZONTAL) .Add(fFadeNow) .AddGroup(B_VERTICAL, 0) - .Add(fadeNowText) + .Add(fFadeNowText) .AddGlue() .End() .Add(fFadeNever) .AddGroup(B_VERTICAL, 0) - .Add(fadeNeverText) + .Add(fFadeNeverText) .AddGlue() .End() .End() @@ -388,6 +393,7 @@ FadeView::FadeView(const char* name, ScreenSaverSettings& settings) B_USE_WINDOW_SPACING, 0) .Add(box) .End(); + } @@ -412,6 +418,7 @@ FadeView::AttachedToWindow() fPasswordCheckBox->SetValue(fSettings.LockEnable()); fPasswordSlider->SetTime(fSettings.PasswordTime()); + _UpdateColors(); UpdateTurnOffScreen(); UpdateStatus(); } @@ -421,6 +428,9 @@ void FadeView::MessageReceived(BMessage *message) { switch (message->what) { + case B_COLORS_UPDATED: + _UpdateColors(); + break; case kMsgRunSliderChanged: case kMsgRunSliderUpdate: if (fRunSlider->Value() > fTurnOffSlider->Value()) @@ -530,6 +540,15 @@ FadeView::UpdateStatus() } +void +FadeView::_UpdateColors() +{ + rgb_color color = ui_color(B_PANEL_TEXT_COLOR); + fFadeNeverText->SetFontAndColor(be_plain_font, 0, &color); + fFadeNowText->SetFontAndColor(be_plain_font, 0, &color); +} + + // #pragma mark - ModulesView @@ -546,7 +565,7 @@ ModulesView::ModulesView(const char* name, ScreenSaverSettings& settings) fPreviewView(new PreviewView("preview")), fScreenSaverTestTeam(-1) { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fScreenSaversListView->SetSelectionMessage( new BMessage(kMsgSaverSelected)); @@ -825,7 +844,7 @@ ModulesView::_OpenSaver() #endif fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW); - fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fSettingsView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fSettingsBox->AddChild(fSettingsView); BScreenSaver* saver = ScreenSaver(); @@ -928,7 +947,7 @@ ScreenSaverWindow::ScreenSaverWindow() // Create the topmost background view BView* topView = new BView("topView", B_WILL_DRAW); - topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + topView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); topView->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT)); topView->SetExplicitMinSize(BSize(fMinWidth, fMinHeight)); diff --git a/src/preferences/time/AnalogClock.cpp b/src/preferences/time/AnalogClock.cpp index 4f1c0d0178..5b6d34eef9 100644 --- a/src/preferences/time/AnalogClock.cpp +++ b/src/preferences/time/AnalogClock.cpp @@ -250,7 +250,7 @@ TAnalogClock::DrawClock() BRect bounds = Bounds(); // clear background - rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color background = ViewColor(); SetHighColor(background); FillRect(bounds); diff --git a/src/preferences/time/BaseView.cpp b/src/preferences/time/BaseView.cpp index eec15e44ec..3e096a3045 100644 --- a/src/preferences/time/BaseView.cpp +++ b/src/preferences/time/BaseView.cpp @@ -41,7 +41,8 @@ TTimeBaseView::Pulse() void TTimeBaseView::AttachedToWindow() { - SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + SetLowUIColor(ViewUIColor()); } diff --git a/src/preferences/time/ClockView.cpp b/src/preferences/time/ClockView.cpp index a67d2198e9..b287a4dfdf 100644 --- a/src/preferences/time/ClockView.cpp +++ b/src/preferences/time/ClockView.cpp @@ -80,8 +80,7 @@ ClockView::~ClockView() void ClockView::AttachedToWindow() { - if (Parent()) - SetViewColor(Parent()->ViewColor()); + AdoptParentColors(); fShowClock->SetTarget(this); fShowSeconds->SetTarget(this); diff --git a/src/preferences/time/DateTimeEdit.cpp b/src/preferences/time/DateTimeEdit.cpp index 0614a2bb30..24fb1c4d2f 100644 --- a/src/preferences/time/DateTimeEdit.cpp +++ b/src/preferences/time/DateTimeEdit.cpp @@ -95,9 +95,12 @@ TTimeEdit::DrawSection(uint32 index, BRect bounds, bool hasFocus) { if (fFieldPositions == NULL || index * 2 + 1 >= (uint32)fFieldPosCount) return; - SetLowColor(ViewColor()); + if (hasFocus) - SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); + SetLowColor(mix_color(ui_color(B_CONTROL_HIGHLIGHT_COLOR), + ViewColor(), 192)); + else + SetLowColor(ViewColor()); BString field; fText.CopyCharsInto(field, fFieldPositions[index * 2], @@ -106,7 +109,7 @@ TTimeEdit::DrawSection(uint32 index, BRect bounds, bool hasFocus) BPoint point(bounds.LeftBottom()); point.y -= bounds.Height() / 2.0 - 6.0; point.x += (bounds.Width() - StringWidth(field)) / 2; - SetHighColor(0, 0, 0, 255); + SetHighUIColor(B_PANEL_TEXT_COLOR); FillRect(bounds, B_SOLID_LOW); DrawString(field, point); } @@ -125,7 +128,7 @@ TTimeEdit::DrawSeparator(uint32 index, BRect bounds) BPoint point(bounds.LeftBottom()); point.y -= bounds.Height() / 2.0 - 6.0; point.x += (bounds.Width() - StringWidth(field)) / 2; - SetHighColor(0, 0, 0, 255); + SetHighUIColor(B_PANEL_TEXT_COLOR); DrawString(field, point); } @@ -471,9 +474,11 @@ TDateEdit::DrawSection(uint32 index, BRect bounds, bool hasFocus) if (fFieldPositions == NULL || index * 2 + 1 >= (uint32)fFieldPosCount) return; - SetLowColor(ViewColor()); if (hasFocus) - SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); + SetLowColor(mix_color(ui_color(B_CONTROL_HIGHLIGHT_COLOR), + ViewColor(), 192)); + else + SetLowColor(ViewColor()); BString field; fText.CopyCharsInto(field, fFieldPositions[index * 2], @@ -482,7 +487,7 @@ TDateEdit::DrawSection(uint32 index, BRect bounds, bool hasFocus) BPoint point(bounds.LeftBottom()); point.y -= bounds.Height() / 2.0 - 6.0; point.x += (bounds.Width() - StringWidth(field)) / 2; - SetHighColor(0, 0, 0, 255); + SetHighUIColor(B_PANEL_TEXT_COLOR); FillRect(bounds, B_SOLID_LOW); DrawString(field, point); } @@ -504,7 +509,7 @@ TDateEdit::DrawSeparator(uint32 index, BRect bounds) BPoint point(bounds.LeftBottom()); point.y -= bounds.Height() / 2.0 - 6.0; point.x += (bounds.Width() - StringWidth(field)) / 2; - SetHighColor(0, 0, 0, 255); + SetHighUIColor(B_PANEL_TEXT_COLOR); DrawString(field, point); } diff --git a/src/preferences/time/DateTimeView.cpp b/src/preferences/time/DateTimeView.cpp index 487ca4f8b9..abc7557f5d 100644 --- a/src/preferences/time/DateTimeView.cpp +++ b/src/preferences/time/DateTimeView.cpp @@ -65,8 +65,7 @@ DateTimeView::~DateTimeView() void DateTimeView::AttachedToWindow() { - if (Parent()) - SetViewColor(Parent()->ViewColor()); + AdoptParentColors(); if (!fInitialized) { fInitialized = true; diff --git a/src/preferences/time/SectionEdit.cpp b/src/preferences/time/SectionEdit.cpp index a00461daba..b04daab5e1 100644 --- a/src/preferences/time/SectionEdit.cpp +++ b/src/preferences/time/SectionEdit.cpp @@ -41,8 +41,7 @@ TSectionEdit::~TSectionEdit() void TSectionEdit::AttachedToWindow() { - if (Parent()) - SetViewColor(Parent()->ViewColor()); + AdoptParentColors(); } diff --git a/src/preferences/time/TZDisplay.cpp b/src/preferences/time/TZDisplay.cpp index 1981ac27ef..1df7a4e444 100644 --- a/src/preferences/time/TZDisplay.cpp +++ b/src/preferences/time/TZDisplay.cpp @@ -35,8 +35,7 @@ TTZDisplay::~TTZDisplay() void TTZDisplay::AttachedToWindow() { - if (Parent()) - SetViewColor(Parent()->ViewColor()); + AdoptParentColors(); } diff --git a/src/preferences/time/ZoneView.cpp b/src/preferences/time/ZoneView.cpp index 6e20785d10..2b85e67322 100644 --- a/src/preferences/time/ZoneView.cpp +++ b/src/preferences/time/ZoneView.cpp @@ -116,8 +116,7 @@ void TimeZoneView::AttachedToWindow() { BView::AttachedToWindow(); - if (Parent()) - SetViewColor(Parent()->ViewColor()); + AdoptParentColors(); if (!fInitialized) { fInitialized = true;