* Fixed a little bug that caused unnecessary mode changes when pressing Revert.

* Fixed compilation under R5.
* Made Revert more user-friendly by also allowing to revert settings to the previously active state after having pressed Apply. This only works if you didn't make new changes in the meantime. In that case, only the new changes will be reverted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20031 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Waldemar Kornewald
2007-02-01 21:36:50 +00:00
parent 24a0bfcb01
commit a40498e2b2
3 changed files with 38 additions and 10 deletions
+8
View File
@@ -17,6 +17,14 @@
#include <Screen.h> #include <Screen.h>
#ifndef __HAIKU__
inline bool operator!=(const rgb_color& x, const rgb_color& y)
{
return (x.red!=y.red || x.blue!=y.blue || x.green!=y.green);
}
#endif
MonitorView::MonitorView(BRect rect, char *name, int32 width, int32 height) MonitorView::MonitorView(BRect rect, char *name, int32 width, int32 height)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW), : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
fWidth(width), fWidth(width),
+1 -1
View File
@@ -219,7 +219,7 @@ ScreenMode::Revert()
return B_OK; return B_OK;
screen_mode current; screen_mode current;
if (Get(current) && fOriginal == current) if (Get(current) == B_OK && fOriginal == current)
return B_OK; return B_OK;
BScreen screen(fWindow); BScreen screen(fWindow);
+29 -9
View File
@@ -801,8 +801,11 @@ ScreenWindow::MessageReceived(BMessage* message)
case POP_RESOLUTION_MSG: case POP_RESOLUTION_MSG:
{ {
int32 oldWidth = fSelected.width, oldHeight = fSelected.height;
message->FindInt32("width", &fSelected.width); message->FindInt32("width", &fSelected.width);
message->FindInt32("height", &fSelected.height); message->FindInt32("height", &fSelected.height);
if (fSelected.width == oldWidth && fSelected.height == oldHeight)
break;
CheckColorMenu(); CheckColorMenu();
CheckRefreshMenu(); CheckRefreshMenu();
@@ -810,29 +813,44 @@ ScreenWindow::MessageReceived(BMessage* message)
UpdateMonitorView(); UpdateMonitorView();
UpdateRefreshControl(); UpdateRefreshControl();
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
CheckApplyEnabled(); CheckApplyEnabled();
break; break;
} }
case POP_COLORS_MSG: case POP_COLORS_MSG:
{ {
color_space old = fSelected.space;
message->FindInt32("space", (int32 *)&fSelected.space); message->FindInt32("space", (int32 *)&fSelected.space);
if (fSelected.space == old)
break;
BString string; BString string;
string << fSelected.BitsPerPixel() << " Bits/Pixel"; string << fSelected.BitsPerPixel() << " Bits/Pixel";
fColorsMenu->Superitem()->SetLabel(string.String()); fColorsMenu->Superitem()->SetLabel(string.String());
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
CheckApplyEnabled(); CheckApplyEnabled();
break; break;
} }
case POP_REFRESH_MSG: case POP_REFRESH_MSG:
{
float old = fSelected.refresh;
message->FindFloat("refresh", &fSelected.refresh); message->FindFloat("refresh", &fSelected.refresh);
fOtherRefresh->SetLabel("Other" B_UTF8_ELLIPSIS); fOtherRefresh->SetLabel("Other" B_UTF8_ELLIPSIS);
// revert "Other…" label - it might have had a refresh rate prefix // revert "Other…" label - it might have had a refresh rate prefix
if (fSelected.refresh == old)
break;
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
CheckApplyEnabled(); CheckApplyEnabled();
break; break;
}
case POP_OTHER_REFRESH_MSG: case POP_OTHER_REFRESH_MSG:
{ {
@@ -856,8 +874,13 @@ ScreenWindow::MessageReceived(BMessage* message)
{ {
// user pressed "done" in "Other…" refresh dialog; // user pressed "done" in "Other…" refresh dialog;
// select the refresh rate chosen // select the refresh rate chosen
float old = fSelected.refresh;
message->FindFloat("refresh", &fSelected.refresh); message->FindFloat("refresh", &fSelected.refresh);
if (fSelected.refresh != old)
break;
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
UpdateRefreshControl(); UpdateRefreshControl();
CheckApplyEnabled(); CheckApplyEnabled();
break; break;
@@ -909,6 +932,8 @@ ScreenWindow::MessageReceived(BMessage* message)
fSelected.use_laptop_panel = false; fSelected.use_laptop_panel = false;
fSelected.tv_standard = 0; fSelected.tv_standard = 0;
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
UpdateControls(); UpdateControls();
break; break;
} }
@@ -959,7 +984,6 @@ ScreenWindow::MessageReceived(BMessage* message)
fChangingAllWorkspaces = false; fChangingAllWorkspaces = false;
} }
fScreenMode.UpdateOriginalMode();
UpdateActiveMode(); UpdateActiveMode();
break; break;
} }
@@ -1005,20 +1029,16 @@ ScreenWindow::_WriteVesaModeFile(const screen_mode& mode) const
bool bool
ScreenWindow::CanApply() const ScreenWindow::CanApply() const
{ {
if (fAllWorkspacesItem->IsMarked()) return fAllWorkspacesItem->IsMarked() || fSelected != fOriginal
return true; || fSelected != fActive;
return fSelected != fActive;
} }
bool bool
ScreenWindow::CanRevert() const ScreenWindow::CanRevert() const
{ {
if (fActive != fOriginal) return (fActive != fOriginal && !fAllWorkspacesItem->IsMarked())
return true; || fSelected != fActive;
return CanApply();
} }