- Revert button's first update didn't work since revert data is stored in the Show() method.
- Default data is defined in two places, and was inconsistent. - Color comparisons could be done with the wrong alpha. note: BColorControl's behavior wrt alpha might differ from R5's. This fixes part of #254 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24008 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -53,7 +53,15 @@ static const uint32 kSpaceBarSwitchColor = 'SBsc';
|
||||
static const float kItemExtraSpacing = 2.0f;
|
||||
static const float kIndentSpacing = 12.0f;
|
||||
|
||||
//TODO: defaults should be set in one place only (TrackerSettings.cpp) while
|
||||
// being accessible from here.
|
||||
// What about adding DefaultValue(), IsDefault() etc... methods to xxxValueSetting ?
|
||||
static const uint8 kSpaceBarAlpha = 192;
|
||||
static const rgb_color kDefaultUsedSpaceColor = {0, 203, 0, kSpaceBarAlpha};
|
||||
static const rgb_color kDefaultFreeSpaceColor = {255, 255, 255, kSpaceBarAlpha};
|
||||
static const rgb_color kDefaultWarningSpaceColor = {203, 0, 0, kSpaceBarAlpha};
|
||||
|
||||
|
||||
static void
|
||||
send_bool_notices(uint32 what, const char *name, bool value)
|
||||
{
|
||||
@@ -1145,15 +1153,19 @@ SpaceBarSettingsView::MessageReceived(BMessage *message)
|
||||
|
||||
case kSpaceBarColorChanged:
|
||||
{
|
||||
rgb_color color = fColorControl->ValueAsColor();
|
||||
color.alpha = kSpaceBarAlpha;
|
||||
//alpha is ignored by BColorControl but is checked in equalities
|
||||
|
||||
switch (fCurrentColor) {
|
||||
case 0:
|
||||
settings.SetUsedSpaceColor(fColorControl->ValueAsColor());
|
||||
settings.SetUsedSpaceColor(color);
|
||||
break;
|
||||
case 1:
|
||||
settings.SetFreeSpaceColor(fColorControl->ValueAsColor());
|
||||
settings.SetFreeSpaceColor(color);
|
||||
break;
|
||||
case 2:
|
||||
settings.SetWarningSpaceColor(fColorControl->ValueAsColor());
|
||||
settings.SetWarningSpaceColor(color);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1183,12 +1195,12 @@ SpaceBarSettingsView::SetDefaults()
|
||||
send_bool_notices(kShowVolumeSpaceBar, "ShowVolumeSpaceBar", false);
|
||||
}
|
||||
|
||||
if (settings.UsedSpaceColor() != Color(0, 203, 0, 192)
|
||||
|| settings.FreeSpaceColor() != Color(255, 255, 255, 192)
|
||||
|| settings.WarningSpaceColor() != Color(203, 0, 0, 192)) {
|
||||
settings.SetUsedSpaceColor(Color(0, 203, 0, 192));
|
||||
settings.SetFreeSpaceColor(Color(255, 255, 255, 192));
|
||||
settings.SetWarningSpaceColor(Color(203, 0, 0, 192));
|
||||
if (settings.UsedSpaceColor() != kDefaultUsedSpaceColor
|
||||
|| settings.FreeSpaceColor() != kDefaultFreeSpaceColor
|
||||
|| settings.WarningSpaceColor() != kDefaultWarningSpaceColor) {
|
||||
settings.SetUsedSpaceColor(kDefaultUsedSpaceColor);
|
||||
settings.SetFreeSpaceColor(kDefaultFreeSpaceColor);
|
||||
settings.SetWarningSpaceColor(kDefaultWarningSpaceColor);
|
||||
tracker->SendNotices(kSpaceBarColorChanged);
|
||||
}
|
||||
|
||||
@@ -1202,9 +1214,9 @@ SpaceBarSettingsView::IsDefaultable() const
|
||||
TrackerSettings settings;
|
||||
|
||||
return settings.ShowVolumeSpaceBar() != false
|
||||
|| settings.UsedSpaceColor() != Color(0, 203, 0, 192)
|
||||
|| settings.FreeSpaceColor() != Color(255, 255, 255, 192)
|
||||
|| settings.WarningSpaceColor() != Color(203, 0, 0, 192);
|
||||
|| settings.UsedSpaceColor() != kDefaultUsedSpaceColor
|
||||
|| settings.FreeSpaceColor() != kDefaultFreeSpaceColor
|
||||
|| settings.WarningSpaceColor() != kDefaultWarningSpaceColor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1273,7 +1285,7 @@ SpaceBarSettingsView::IsRevertable() const
|
||||
{
|
||||
TrackerSettings settings;
|
||||
|
||||
return fSpaceBarShow != (fSpaceBarShowCheckBox->Value() == B_CONTROL_ON)
|
||||
return fSpaceBarShow != settings.ShowVolumeSpaceBar()
|
||||
|| fUsedSpaceColor != settings.UsedSpaceColor()
|
||||
|| fFreeSpaceColor != settings.FreeSpaceColor()
|
||||
|| fWarningSpaceColor != settings.WarningSpaceColor();
|
||||
|
||||
@@ -107,19 +107,12 @@ rgb_color ValueToColor(int32 value)
|
||||
color.green = static_cast<uchar>((value >> 8L) & 0xff);
|
||||
color.blue = static_cast<uchar>(value & 0xff);
|
||||
|
||||
// zero alpha is invalid
|
||||
if (color.alpha == 0)
|
||||
color.alpha = 192;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
int32 ColorToValue(rgb_color color)
|
||||
{
|
||||
// zero alpha is invalid
|
||||
if (color.alpha == 0)
|
||||
color.alpha = 192;
|
||||
|
||||
return color.alpha << 24L
|
||||
| color.red << 16L
|
||||
| color.green << 8L
|
||||
@@ -174,7 +167,7 @@ TTrackerState::LoadSettingsIfNeeded()
|
||||
Add(fMountSharedVolumesOntoDesktop =
|
||||
new BooleanValueSetting("MountSharedVolumesOntoDesktop", true));
|
||||
Add(fIntegrateNonBootBeOSDesktops = new BooleanValueSetting
|
||||
("IntegrateNonBootBeOSDesktops", true));
|
||||
("IntegrateNonBootBeOSDesktops", false));
|
||||
Add(fIntegrateAllNonBootDesktops = new BooleanValueSetting
|
||||
("IntegrateAllNonBootDesktops", false));
|
||||
Add(fEjectWhenUnmounting = new BooleanValueSetting("EjectWhenUnmounting", true));
|
||||
@@ -343,8 +336,6 @@ TrackerSettings::UsedSpaceColor()
|
||||
void
|
||||
TrackerSettings::SetUsedSpaceColor(rgb_color color)
|
||||
{
|
||||
if (color.alpha == 0)
|
||||
color.alpha = 192;
|
||||
gTrackerState.fUsedSpaceColor->ValueChanged(ColorToValue(color));
|
||||
}
|
||||
|
||||
@@ -359,8 +350,6 @@ TrackerSettings::FreeSpaceColor()
|
||||
void
|
||||
TrackerSettings::SetFreeSpaceColor(rgb_color color)
|
||||
{
|
||||
if (color.alpha == 0)
|
||||
color.alpha = 192;
|
||||
gTrackerState.fFreeSpaceColor->ValueChanged(ColorToValue(color));
|
||||
}
|
||||
|
||||
@@ -375,8 +364,6 @@ TrackerSettings::WarningSpaceColor()
|
||||
void
|
||||
TrackerSettings::SetWarningSpaceColor(rgb_color color)
|
||||
{
|
||||
if (color.alpha == 0)
|
||||
color.alpha = 192;
|
||||
gTrackerState.fWarningSpaceColor->ValueChanged(ColorToValue(color));
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,8 @@ TrackerSettingsWindow::Show()
|
||||
|
||||
fSettingsTypeListView->Invalidate();
|
||||
|
||||
_UpdateButtons();
|
||||
|
||||
Unlock();
|
||||
}
|
||||
_inherited::Show();
|
||||
@@ -238,6 +240,16 @@ TrackerSettingsWindow::_SettingsFrame()
|
||||
|
||||
void
|
||||
TrackerSettingsWindow::_HandleChangedContents()
|
||||
{
|
||||
fSettingsTypeListView->Invalidate();
|
||||
_UpdateButtons();
|
||||
|
||||
TrackerSettings().SaveSettings(false);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackerSettingsWindow::_UpdateButtons()
|
||||
{
|
||||
int32 itemCount = fSettingsTypeListView->CountItems();
|
||||
|
||||
@@ -248,12 +260,9 @@ TrackerSettingsWindow::_HandleChangedContents()
|
||||
defaultable |= _ViewAt(i)->IsDefaultable();
|
||||
revertable |= _ViewAt(i)->IsRevertable();
|
||||
}
|
||||
|
||||
fSettingsTypeListView->Invalidate();
|
||||
|
||||
fDefaultsButton->SetEnabled(defaultable);
|
||||
fRevertButton->SetEnabled(revertable);
|
||||
|
||||
TrackerSettings().SaveSettings(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ class TrackerSettingsWindow : public BWindow {
|
||||
void _HandlePressedDefaultsButton();
|
||||
void _HandlePressedRevertButton();
|
||||
void _HandleChangedSettingsView();
|
||||
void _UpdateButtons();
|
||||
|
||||
BListView *fSettingsTypeListView;
|
||||
BBox *fSettingsContainerBox;
|
||||
|
||||
Reference in New Issue
Block a user