Revision: hrev43251 Commit: e11b156da96c5b5f9c00913c7eda6f6695ec16d1 URL: http://cgit.haiku-os.org/haiku/commit/?id=e11b156 Author: Philippe Saint-Pierre <stpere@xxxxxxxxx> Date: Sun Nov 13 01:34:12 2011 UTC Ticket: https://dev.haiku-os.org/ticket/3331 Fix for Defaults button issues in Appearance preflet * Implement isDefaultable() and SetDefaults() for Antialiasing tab; * The default color set was out of sync with the actual colors, it now gets the actual colors rather than hardcoding them; * Some hardcoded values for defaults related to antialiasing were differents from actual default values stated in AppServer; * Revert now works for Antialiasing settings also. Fix #3331 ............................................................................ src/preferences/appearance/APRView.cpp | 7 +++- .../appearance/AntialiasingSettingsView.cpp | 32 +++++++++++++-- src/preferences/appearance/ColorSet.cpp | 33 ++++------------ 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/preferences/appearance/APRView.cpp b/src/preferences/appearance/APRView.cpp index aa72b63..8dbb5f1 100644 --- a/src/preferences/appearance/APRView.cpp +++ b/src/preferences/appearance/APRView.cpp @@ -208,7 +208,12 @@ APRView::LoadSettings() bool APRView::IsDefaultable() { - return fCurrentSet != fDefaultSet; + for (int32 i = 0; i < color_description_count(); i++) { + color_which which = get_color_description(i)->which; + if (fCurrentSet.GetColor(which) != fDefaultSet.GetColor(which)) + return true; + } + return false; } diff --git a/src/preferences/appearance/AntialiasingSettingsView.cpp b/src/preferences/appearance/AntialiasingSettingsView.cpp index 3513e72..b691224 100644 --- a/src/preferences/appearance/AntialiasingSettingsView.cpp +++ b/src/preferences/appearance/AntialiasingSettingsView.cpp @@ -56,6 +56,10 @@ enum { HINTING_MODE_MONOSPACED_ONLY }; +static const uint8 kDefaultHintingMode = HINTING_MODE_ON; +static const unsigned char kDefaultAverageWeight = 120; +static const bool kDefaultSubpixelAntialiasing = false; + extern void set_subpixel_antialiasing(bool subpix); extern status_t get_subpixel_antialiasing(bool* subpix); extern void set_hinting_mode(uint8 hinting); @@ -72,15 +76,15 @@ AntialiasingSettingsView::AntialiasingSettingsView(const char* name) { // collect the current system settings if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK) - fCurrentSubpixelAntialiasing = false; + fCurrentSubpixelAntialiasing = kDefaultSubpixelAntialiasing; fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing; if (get_hinting_mode(&fCurrentHinting) != B_OK) - fCurrentHinting = HINTING_MODE_ON; + fCurrentHinting = kDefaultHintingMode; fSavedHinting = fCurrentHinting; if (get_average_weight(&fCurrentAverageWeight) != B_OK) - fCurrentAverageWeight = 100; + fCurrentAverageWeight = kDefaultAverageWeight; fSavedAverageWeight = fCurrentAverageWeight; // create the controls @@ -188,6 +192,8 @@ AntialiasingSettingsView::MessageReceived(BMessage *msg) if (msg->FindBool("antialiasing", &subpixelAntialiasing) != B_OK || subpixelAntialiasing == fCurrentSubpixelAntialiasing) break; + + fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing; fCurrentSubpixelAntialiasing = subpixelAntialiasing; fAverageWeightControl->SetEnabled(fCurrentSubpixelAntialiasing); @@ -203,6 +209,7 @@ AntialiasingSettingsView::MessageReceived(BMessage *msg) || hinting == fCurrentHinting) break; + fSavedHinting = fCurrentHinting; fCurrentHinting = hinting; set_hinting_mode(fCurrentHinting); @@ -215,6 +222,7 @@ AntialiasingSettingsView::MessageReceived(BMessage *msg) if (averageWeight == fCurrentAverageWeight) break; + fSavedAverageWeight = fCurrentAverageWeight; fCurrentAverageWeight = averageWeight; set_average_weight(fCurrentAverageWeight); @@ -320,13 +328,29 @@ AntialiasingSettingsView::_SetCurrentAverageWeight() void AntialiasingSettingsView::SetDefaults() { + if (!IsDefaultable()) + return; + + fCurrentSubpixelAntialiasing = kDefaultSubpixelAntialiasing; + fCurrentHinting = kDefaultHintingMode; + fCurrentAverageWeight = kDefaultAverageWeight; + + set_subpixel_antialiasing(fCurrentSubpixelAntialiasing); + set_hinting_mode(fCurrentHinting); + set_average_weight(fCurrentAverageWeight); + + _SetCurrentAntialiasing(); + _SetCurrentHinting(); + _SetCurrentAverageWeight(); } bool AntialiasingSettingsView::IsDefaultable() { - return false; + return fCurrentSubpixelAntialiasing != kDefaultSubpixelAntialiasing + || fCurrentHinting != kDefaultHintingMode + || fCurrentAverageWeight != kDefaultAverageWeight; } diff --git a/src/preferences/appearance/ColorSet.cpp b/src/preferences/appearance/ColorSet.cpp index 653eba5..03256c0 100644 --- a/src/preferences/appearance/ColorSet.cpp +++ b/src/preferences/appearance/ColorSet.cpp @@ -10,12 +10,14 @@ #include <stdio.h> #include <Catalog.h> +#include <DefaultColors.h> #include <Directory.h> #include <Entry.h> #include <File.h> #include <InterfaceDefs.h> #include <Locale.h> #include <Message.h> +#include <ServerReadOnlyMemory.h> #include <String.h> #include "ColorSet.h" @@ -109,31 +111,12 @@ ColorSet ColorSet::DefaultColorSet(void) { ColorSet set; - set.fColors[B_PANEL_BACKGROUND_COLOR] = make_color(216, 216, 216); - set.fColors[B_PANEL_TEXT_COLOR] = make_color(0, 0, 0); - set.fColors[B_DOCUMENT_BACKGROUND_COLOR] = make_color(255,255, 255); - set.fColors[B_DOCUMENT_TEXT_COLOR] = make_color(0, 0, 0); - set.fColors[B_CONTROL_BACKGROUND_COLOR] = make_color(245, 245, 245); - set.fColors[B_CONTROL_TEXT_COLOR] = make_color(0, 0, 0); - set.fColors[B_CONTROL_BORDER_COLOR] = make_color(0, 0, 0); - set.fColors[B_CONTROL_HIGHLIGHT_COLOR] = make_color(102, 152, 203); - set.fColors[B_NAVIGATION_BASE_COLOR] = make_color(0, 0, 229); - set.fColors[B_NAVIGATION_PULSE_COLOR] = make_color(0, 0, 0); - set.fColors[B_SHINE_COLOR] = make_color(255, 255, 255); - set.fColors[B_SHADOW_COLOR] = make_color(0, 0, 0); - set.fColors[B_MENU_BACKGROUND_COLOR] = make_color(216, 216, 216); - set.fColors[B_MENU_SELECTED_BACKGROUND_COLOR] = make_color(115, 120, 184); - set.fColors[B_MENU_ITEM_TEXT_COLOR] = make_color(0, 0, 0); - set.fColors[B_MENU_SELECTED_ITEM_TEXT_COLOR] = make_color(255, 255, 255); - set.fColors[B_MENU_SELECTED_BORDER_COLOR] = make_color(0, 0, 0); - set.fColors[B_TOOL_TIP_BACKGROUND_COLOR] = make_color(255, 255, 0); - set.fColors[B_TOOL_TIP_TEXT_COLOR] = make_color(0, 0, 0); - set.fColors[B_SUCCESS_COLOR] = make_color(0, 255, 0); - set.fColors[B_FAILURE_COLOR] = make_color(255, 0, 0); - set.fColors[B_WINDOW_TAB_COLOR] = make_color(255, 203, 0); - set.fColors[B_WINDOW_TEXT_COLOR] = make_color(0, 0, 0); - set.fColors[B_WINDOW_INACTIVE_TAB_COLOR] = make_color(232, 232, 232); - set.fColors[B_WINDOW_INACTIVE_TEXT_COLOR] = make_color(80, 80, 80); + + 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; }