- 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,6 +53,14 @@ static const uint32 kSpaceBarSwitchColor = 'SBsc';
|
|||||||
static const float kItemExtraSpacing = 2.0f;
|
static const float kItemExtraSpacing = 2.0f;
|
||||||
static const float kIndentSpacing = 12.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
|
static void
|
||||||
send_bool_notices(uint32 what, const char *name, bool value)
|
send_bool_notices(uint32 what, const char *name, bool value)
|
||||||
@@ -1145,15 +1153,19 @@ SpaceBarSettingsView::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
case kSpaceBarColorChanged:
|
case kSpaceBarColorChanged:
|
||||||
{
|
{
|
||||||
|
rgb_color color = fColorControl->ValueAsColor();
|
||||||
|
color.alpha = kSpaceBarAlpha;
|
||||||
|
//alpha is ignored by BColorControl but is checked in equalities
|
||||||
|
|
||||||
switch (fCurrentColor) {
|
switch (fCurrentColor) {
|
||||||
case 0:
|
case 0:
|
||||||
settings.SetUsedSpaceColor(fColorControl->ValueAsColor());
|
settings.SetUsedSpaceColor(color);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
settings.SetFreeSpaceColor(fColorControl->ValueAsColor());
|
settings.SetFreeSpaceColor(color);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
settings.SetWarningSpaceColor(fColorControl->ValueAsColor());
|
settings.SetWarningSpaceColor(color);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1183,12 +1195,12 @@ SpaceBarSettingsView::SetDefaults()
|
|||||||
send_bool_notices(kShowVolumeSpaceBar, "ShowVolumeSpaceBar", false);
|
send_bool_notices(kShowVolumeSpaceBar, "ShowVolumeSpaceBar", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.UsedSpaceColor() != Color(0, 203, 0, 192)
|
if (settings.UsedSpaceColor() != kDefaultUsedSpaceColor
|
||||||
|| settings.FreeSpaceColor() != Color(255, 255, 255, 192)
|
|| settings.FreeSpaceColor() != kDefaultFreeSpaceColor
|
||||||
|| settings.WarningSpaceColor() != Color(203, 0, 0, 192)) {
|
|| settings.WarningSpaceColor() != kDefaultWarningSpaceColor) {
|
||||||
settings.SetUsedSpaceColor(Color(0, 203, 0, 192));
|
settings.SetUsedSpaceColor(kDefaultUsedSpaceColor);
|
||||||
settings.SetFreeSpaceColor(Color(255, 255, 255, 192));
|
settings.SetFreeSpaceColor(kDefaultFreeSpaceColor);
|
||||||
settings.SetWarningSpaceColor(Color(203, 0, 0, 192));
|
settings.SetWarningSpaceColor(kDefaultWarningSpaceColor);
|
||||||
tracker->SendNotices(kSpaceBarColorChanged);
|
tracker->SendNotices(kSpaceBarColorChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1202,9 +1214,9 @@ SpaceBarSettingsView::IsDefaultable() const
|
|||||||
TrackerSettings settings;
|
TrackerSettings settings;
|
||||||
|
|
||||||
return settings.ShowVolumeSpaceBar() != false
|
return settings.ShowVolumeSpaceBar() != false
|
||||||
|| settings.UsedSpaceColor() != Color(0, 203, 0, 192)
|
|| settings.UsedSpaceColor() != kDefaultUsedSpaceColor
|
||||||
|| settings.FreeSpaceColor() != Color(255, 255, 255, 192)
|
|| settings.FreeSpaceColor() != kDefaultFreeSpaceColor
|
||||||
|| settings.WarningSpaceColor() != Color(203, 0, 0, 192);
|
|| settings.WarningSpaceColor() != kDefaultWarningSpaceColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1273,7 +1285,7 @@ SpaceBarSettingsView::IsRevertable() const
|
|||||||
{
|
{
|
||||||
TrackerSettings settings;
|
TrackerSettings settings;
|
||||||
|
|
||||||
return fSpaceBarShow != (fSpaceBarShowCheckBox->Value() == B_CONTROL_ON)
|
return fSpaceBarShow != settings.ShowVolumeSpaceBar()
|
||||||
|| fUsedSpaceColor != settings.UsedSpaceColor()
|
|| fUsedSpaceColor != settings.UsedSpaceColor()
|
||||||
|| fFreeSpaceColor != settings.FreeSpaceColor()
|
|| fFreeSpaceColor != settings.FreeSpaceColor()
|
||||||
|| fWarningSpaceColor != settings.WarningSpaceColor();
|
|| fWarningSpaceColor != settings.WarningSpaceColor();
|
||||||
|
|||||||
@@ -107,19 +107,12 @@ rgb_color ValueToColor(int32 value)
|
|||||||
color.green = static_cast<uchar>((value >> 8L) & 0xff);
|
color.green = static_cast<uchar>((value >> 8L) & 0xff);
|
||||||
color.blue = static_cast<uchar>(value & 0xff);
|
color.blue = static_cast<uchar>(value & 0xff);
|
||||||
|
|
||||||
// zero alpha is invalid
|
|
||||||
if (color.alpha == 0)
|
|
||||||
color.alpha = 192;
|
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32 ColorToValue(rgb_color color)
|
int32 ColorToValue(rgb_color color)
|
||||||
{
|
{
|
||||||
// zero alpha is invalid
|
|
||||||
if (color.alpha == 0)
|
|
||||||
color.alpha = 192;
|
|
||||||
|
|
||||||
return color.alpha << 24L
|
return color.alpha << 24L
|
||||||
| color.red << 16L
|
| color.red << 16L
|
||||||
| color.green << 8L
|
| color.green << 8L
|
||||||
@@ -174,7 +167,7 @@ TTrackerState::LoadSettingsIfNeeded()
|
|||||||
Add(fMountSharedVolumesOntoDesktop =
|
Add(fMountSharedVolumesOntoDesktop =
|
||||||
new BooleanValueSetting("MountSharedVolumesOntoDesktop", true));
|
new BooleanValueSetting("MountSharedVolumesOntoDesktop", true));
|
||||||
Add(fIntegrateNonBootBeOSDesktops = new BooleanValueSetting
|
Add(fIntegrateNonBootBeOSDesktops = new BooleanValueSetting
|
||||||
("IntegrateNonBootBeOSDesktops", true));
|
("IntegrateNonBootBeOSDesktops", false));
|
||||||
Add(fIntegrateAllNonBootDesktops = new BooleanValueSetting
|
Add(fIntegrateAllNonBootDesktops = new BooleanValueSetting
|
||||||
("IntegrateAllNonBootDesktops", false));
|
("IntegrateAllNonBootDesktops", false));
|
||||||
Add(fEjectWhenUnmounting = new BooleanValueSetting("EjectWhenUnmounting", true));
|
Add(fEjectWhenUnmounting = new BooleanValueSetting("EjectWhenUnmounting", true));
|
||||||
@@ -343,8 +336,6 @@ TrackerSettings::UsedSpaceColor()
|
|||||||
void
|
void
|
||||||
TrackerSettings::SetUsedSpaceColor(rgb_color color)
|
TrackerSettings::SetUsedSpaceColor(rgb_color color)
|
||||||
{
|
{
|
||||||
if (color.alpha == 0)
|
|
||||||
color.alpha = 192;
|
|
||||||
gTrackerState.fUsedSpaceColor->ValueChanged(ColorToValue(color));
|
gTrackerState.fUsedSpaceColor->ValueChanged(ColorToValue(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,8 +350,6 @@ TrackerSettings::FreeSpaceColor()
|
|||||||
void
|
void
|
||||||
TrackerSettings::SetFreeSpaceColor(rgb_color color)
|
TrackerSettings::SetFreeSpaceColor(rgb_color color)
|
||||||
{
|
{
|
||||||
if (color.alpha == 0)
|
|
||||||
color.alpha = 192;
|
|
||||||
gTrackerState.fFreeSpaceColor->ValueChanged(ColorToValue(color));
|
gTrackerState.fFreeSpaceColor->ValueChanged(ColorToValue(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,8 +364,6 @@ TrackerSettings::WarningSpaceColor()
|
|||||||
void
|
void
|
||||||
TrackerSettings::SetWarningSpaceColor(rgb_color color)
|
TrackerSettings::SetWarningSpaceColor(rgb_color color)
|
||||||
{
|
{
|
||||||
if (color.alpha == 0)
|
|
||||||
color.alpha = 192;
|
|
||||||
gTrackerState.fWarningSpaceColor->ValueChanged(ColorToValue(color));
|
gTrackerState.fWarningSpaceColor->ValueChanged(ColorToValue(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -203,6 +203,8 @@ TrackerSettingsWindow::Show()
|
|||||||
|
|
||||||
fSettingsTypeListView->Invalidate();
|
fSettingsTypeListView->Invalidate();
|
||||||
|
|
||||||
|
_UpdateButtons();
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
_inherited::Show();
|
_inherited::Show();
|
||||||
@@ -238,6 +240,16 @@ TrackerSettingsWindow::_SettingsFrame()
|
|||||||
|
|
||||||
void
|
void
|
||||||
TrackerSettingsWindow::_HandleChangedContents()
|
TrackerSettingsWindow::_HandleChangedContents()
|
||||||
|
{
|
||||||
|
fSettingsTypeListView->Invalidate();
|
||||||
|
_UpdateButtons();
|
||||||
|
|
||||||
|
TrackerSettings().SaveSettings(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TrackerSettingsWindow::_UpdateButtons()
|
||||||
{
|
{
|
||||||
int32 itemCount = fSettingsTypeListView->CountItems();
|
int32 itemCount = fSettingsTypeListView->CountItems();
|
||||||
|
|
||||||
@@ -249,11 +261,8 @@ TrackerSettingsWindow::_HandleChangedContents()
|
|||||||
revertable |= _ViewAt(i)->IsRevertable();
|
revertable |= _ViewAt(i)->IsRevertable();
|
||||||
}
|
}
|
||||||
|
|
||||||
fSettingsTypeListView->Invalidate();
|
|
||||||
fDefaultsButton->SetEnabled(defaultable);
|
fDefaultsButton->SetEnabled(defaultable);
|
||||||
fRevertButton->SetEnabled(revertable);
|
fRevertButton->SetEnabled(revertable);
|
||||||
|
|
||||||
TrackerSettings().SaveSettings(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ class TrackerSettingsWindow : public BWindow {
|
|||||||
void _HandlePressedDefaultsButton();
|
void _HandlePressedDefaultsButton();
|
||||||
void _HandlePressedRevertButton();
|
void _HandlePressedRevertButton();
|
||||||
void _HandleChangedSettingsView();
|
void _HandleChangedSettingsView();
|
||||||
|
void _UpdateButtons();
|
||||||
|
|
||||||
BListView *fSettingsTypeListView;
|
BListView *fSettingsTypeListView;
|
||||||
BBox *fSettingsContainerBox;
|
BBox *fSettingsContainerBox;
|
||||||
|
|||||||
Reference in New Issue
Block a user