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
This commit is contained in:
Philippe Saint-Pierre
2011-11-12 20:34:12 -05:00
parent 91affb2da4
commit e11b156da9
3 changed files with 42 additions and 30 deletions
+6 -1
View File
@@ -208,7 +208,12 @@ APRView::LoadSettings()
bool bool
APRView::IsDefaultable() 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;
} }
@@ -56,6 +56,10 @@ enum {
HINTING_MODE_MONOSPACED_ONLY 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 void set_subpixel_antialiasing(bool subpix);
extern status_t get_subpixel_antialiasing(bool* subpix); extern status_t get_subpixel_antialiasing(bool* subpix);
extern void set_hinting_mode(uint8 hinting); extern void set_hinting_mode(uint8 hinting);
@@ -72,15 +76,15 @@ AntialiasingSettingsView::AntialiasingSettingsView(const char* name)
{ {
// collect the current system settings // collect the current system settings
if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK) if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK)
fCurrentSubpixelAntialiasing = false; fCurrentSubpixelAntialiasing = kDefaultSubpixelAntialiasing;
fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing; fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing;
if (get_hinting_mode(&fCurrentHinting) != B_OK) if (get_hinting_mode(&fCurrentHinting) != B_OK)
fCurrentHinting = HINTING_MODE_ON; fCurrentHinting = kDefaultHintingMode;
fSavedHinting = fCurrentHinting; fSavedHinting = fCurrentHinting;
if (get_average_weight(&fCurrentAverageWeight) != B_OK) if (get_average_weight(&fCurrentAverageWeight) != B_OK)
fCurrentAverageWeight = 100; fCurrentAverageWeight = kDefaultAverageWeight;
fSavedAverageWeight = fCurrentAverageWeight; fSavedAverageWeight = fCurrentAverageWeight;
// create the controls // create the controls
@@ -188,6 +192,8 @@ AntialiasingSettingsView::MessageReceived(BMessage *msg)
if (msg->FindBool("antialiasing", &subpixelAntialiasing) != B_OK if (msg->FindBool("antialiasing", &subpixelAntialiasing) != B_OK
|| subpixelAntialiasing == fCurrentSubpixelAntialiasing) || subpixelAntialiasing == fCurrentSubpixelAntialiasing)
break; break;
fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing;
fCurrentSubpixelAntialiasing = subpixelAntialiasing; fCurrentSubpixelAntialiasing = subpixelAntialiasing;
fAverageWeightControl->SetEnabled(fCurrentSubpixelAntialiasing); fAverageWeightControl->SetEnabled(fCurrentSubpixelAntialiasing);
@@ -203,6 +209,7 @@ AntialiasingSettingsView::MessageReceived(BMessage *msg)
|| hinting == fCurrentHinting) || hinting == fCurrentHinting)
break; break;
fSavedHinting = fCurrentHinting;
fCurrentHinting = hinting; fCurrentHinting = hinting;
set_hinting_mode(fCurrentHinting); set_hinting_mode(fCurrentHinting);
@@ -215,6 +222,7 @@ AntialiasingSettingsView::MessageReceived(BMessage *msg)
if (averageWeight == fCurrentAverageWeight) if (averageWeight == fCurrentAverageWeight)
break; break;
fSavedAverageWeight = fCurrentAverageWeight;
fCurrentAverageWeight = averageWeight; fCurrentAverageWeight = averageWeight;
set_average_weight(fCurrentAverageWeight); set_average_weight(fCurrentAverageWeight);
@@ -320,13 +328,29 @@ AntialiasingSettingsView::_SetCurrentAverageWeight()
void void
AntialiasingSettingsView::SetDefaults() 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 bool
AntialiasingSettingsView::IsDefaultable() AntialiasingSettingsView::IsDefaultable()
{ {
return false; return fCurrentSubpixelAntialiasing != kDefaultSubpixelAntialiasing
|| fCurrentHinting != kDefaultHintingMode
|| fCurrentAverageWeight != kDefaultAverageWeight;
} }
+8 -25
View File
@@ -10,12 +10,14 @@
#include <stdio.h> #include <stdio.h>
#include <Catalog.h> #include <Catalog.h>
#include <DefaultColors.h>
#include <Directory.h> #include <Directory.h>
#include <Entry.h> #include <Entry.h>
#include <File.h> #include <File.h>
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
#include <Locale.h> #include <Locale.h>
#include <Message.h> #include <Message.h>
#include <ServerReadOnlyMemory.h>
#include <String.h> #include <String.h>
#include "ColorSet.h" #include "ColorSet.h"
@@ -109,31 +111,12 @@ ColorSet
ColorSet::DefaultColorSet(void) ColorSet::DefaultColorSet(void)
{ {
ColorSet set; ColorSet set;
set.fColors[B_PANEL_BACKGROUND_COLOR] = make_color(216, 216, 216);
set.fColors[B_PANEL_TEXT_COLOR] = make_color(0, 0, 0); for (int i = 0; i < sColorDescriptionCount; i++) {
set.fColors[B_DOCUMENT_BACKGROUND_COLOR] = make_color(255,255, 255); color_which which = get_color_description(i)->which;
set.fColors[B_DOCUMENT_TEXT_COLOR] = make_color(0, 0, 0); set.fColors[which] =
set.fColors[B_CONTROL_BACKGROUND_COLOR] = make_color(245, 245, 245); BPrivate::kDefaultColors[color_which_to_index(which)];
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);
return set; return set;
} }