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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user