* If the user selected color space is not available for the selected resolution,
_CheckColorMenu() now selects the closest item available - if you switch back the resolution to one that supports the original color space, it will be restored. This fixes bug #2995. * I also reverted r24674 as I remembered why I did that in the first place (advertizing 24 bit modes as 32 bit), and it was a pretty stupid idea to solve it like this, I must admit. * Instead, the color space menu now only shows spaces that are actually supported by the card at all. One could think about hiding 24 bit in case both 24 bit, and 32 bit are available, but I didn't do that yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32179 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -121,17 +121,8 @@ screen_mode::operator==(const screen_mode &other) const
|
|||||||
bool
|
bool
|
||||||
screen_mode::operator!=(const screen_mode &other) const
|
screen_mode::operator!=(const screen_mode &other) const
|
||||||
{
|
{
|
||||||
// make no difference between 24 and 32 bit modes
|
|
||||||
color_space thisSpace = space;
|
|
||||||
if (thisSpace == B_RGB24)
|
|
||||||
thisSpace = B_RGB32;
|
|
||||||
|
|
||||||
color_space otherSpace = other.space;
|
|
||||||
if (otherSpace == B_RGB24)
|
|
||||||
otherSpace = B_RGB32;
|
|
||||||
|
|
||||||
return width != other.width || height != other.height
|
return width != other.width || height != other.height
|
||||||
|| thisSpace != otherSpace || refresh != other.refresh
|
|| space != other.space || refresh != other.refresh
|
||||||
|| combine != other.combine
|
|| combine != other.combine
|
||||||
|| swap_displays != other.swap_displays
|
|| swap_displays != other.swap_displays
|
||||||
|| use_laptop_panel != other.use_laptop_panel
|
|| use_laptop_panel != other.use_laptop_panel
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ static const struct {
|
|||||||
{ B_CMAP8, 8, "8 Bits/Pixel, 256 Colors" },
|
{ B_CMAP8, 8, "8 Bits/Pixel, 256 Colors" },
|
||||||
{ B_RGB15, 15, "15 Bits/Pixel, 32768 Colors" },
|
{ B_RGB15, 15, "15 Bits/Pixel, 32768 Colors" },
|
||||||
{ B_RGB16, 16, "16 Bits/Pixel, 65536 Colors" },
|
{ B_RGB16, 16, "16 Bits/Pixel, 65536 Colors" },
|
||||||
|
{ B_RGB24, 24, "24 Bits/Pixel, 16 Million Colors" },
|
||||||
{ B_RGB32, 32, "32 Bits/Pixel, 16 Million Colors" }
|
{ B_RGB32, 32, "32 Bits/Pixel, 16 Million Colors" }
|
||||||
};
|
};
|
||||||
static const int32 kColorSpaceCount
|
static const int32 kColorSpaceCount
|
||||||
@@ -175,6 +176,7 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
|
|||||||
fIsVesa = true;
|
fIsVesa = true;
|
||||||
|
|
||||||
_UpdateOriginal();
|
_UpdateOriginal();
|
||||||
|
_BuildSupportedColorSpaces();
|
||||||
fActive = fSelected = fOriginal;
|
fActive = fSelected = fOriginal;
|
||||||
|
|
||||||
fSettings = settings;
|
fSettings = settings;
|
||||||
@@ -282,11 +284,18 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
|
|||||||
fColorsMenu = new BPopUpMenu("colors", true, false);
|
fColorsMenu = new BPopUpMenu("colors", true, false);
|
||||||
|
|
||||||
for (int32 i = 0; i < kColorSpaceCount; i++) {
|
for (int32 i = 0; i < kColorSpaceCount; i++) {
|
||||||
|
if ((fSupportedColorSpaces & (1 << i)) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
BMessage *message = new BMessage(POP_COLORS_MSG);
|
BMessage *message = new BMessage(POP_COLORS_MSG);
|
||||||
message->AddInt32("bits_per_pixel", kColorSpaces[i].bits_per_pixel);
|
message->AddInt32("bits_per_pixel", kColorSpaces[i].bits_per_pixel);
|
||||||
message->AddInt32("space", kColorSpaces[i].space);
|
message->AddInt32("space", kColorSpaces[i].space);
|
||||||
|
|
||||||
fColorsMenu->AddItem(new BMenuItem(kColorSpaces[i].label, message));
|
BMenuItem* item = new BMenuItem(kColorSpaces[i].label, message);
|
||||||
|
if (kColorSpaces[i].space == screen.ColorSpace())
|
||||||
|
fUserSelectedColorSpace = item;
|
||||||
|
|
||||||
|
fColorsMenu->AddItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
rect.OffsetTo(B_ORIGIN);
|
rect.OffsetTo(B_ORIGIN);
|
||||||
@@ -511,7 +520,7 @@ ScreenWindow::QuitRequested()
|
|||||||
|
|
||||||
|
|
||||||
/*! Update resolution list according to combine mode
|
/*! Update resolution list according to combine mode
|
||||||
(some resolution may not be combinable due to memory restrictions)
|
(some resolutions may not be combinable due to memory restrictions).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ScreenWindow::_CheckResolutionMenu()
|
ScreenWindow::_CheckResolutionMenu()
|
||||||
@@ -542,7 +551,13 @@ ScreenWindow::_CheckResolutionMenu()
|
|||||||
void
|
void
|
||||||
ScreenWindow::_CheckColorMenu()
|
ScreenWindow::_CheckColorMenu()
|
||||||
{
|
{
|
||||||
|
int32 supportsAnything = false;
|
||||||
|
int32 index = 0;
|
||||||
|
|
||||||
for (int32 i = 0; i < kColorSpaceCount; i++) {
|
for (int32 i = 0; i < kColorSpaceCount; i++) {
|
||||||
|
if ((fSupportedColorSpaces & (1 << i)) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
bool supported = false;
|
bool supported = false;
|
||||||
|
|
||||||
for (int32 j = 0; j < fScreenMode.CountModes(); j++) {
|
for (int32 j = 0; j < fScreenMode.CountModes(); j++) {
|
||||||
@@ -550,20 +565,72 @@ ScreenWindow::_CheckColorMenu()
|
|||||||
|
|
||||||
if (fSelected.width == mode.width
|
if (fSelected.width == mode.width
|
||||||
&& fSelected.height == mode.height
|
&& fSelected.height == mode.height
|
||||||
&& (kColorSpaces[i].space == mode.space
|
&& kColorSpaces[i].space == mode.space
|
||||||
// advertize 24 bit mode as 32 bit to avoid confusion
|
|
||||||
|| (kColorSpaces[i].space == B_RGB32
|
|
||||||
&& mode.space == B_RGB24))
|
|
||||||
&& fSelected.combine == mode.combine) {
|
&& fSelected.combine == mode.combine) {
|
||||||
|
supportsAnything = true;
|
||||||
supported = true;
|
supported = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BMenuItem* item = fColorsMenu->ItemAt(i);
|
BMenuItem* item = fColorsMenu->ItemAt(index++);
|
||||||
if (item)
|
if (item)
|
||||||
item->SetEnabled(supported);
|
item->SetEnabled(supported);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fColorsField->SetEnabled(supportsAnything);
|
||||||
|
|
||||||
|
if (!supportsAnything)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Make sure a valid item is selected
|
||||||
|
|
||||||
|
BMenuItem* item = fColorsMenu->FindMarked();
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
if (item != fUserSelectedColorSpace) {
|
||||||
|
if (fUserSelectedColorSpace != NULL
|
||||||
|
&& fUserSelectedColorSpace->IsEnabled()) {
|
||||||
|
fUserSelectedColorSpace->SetMarked(true);
|
||||||
|
item = fUserSelectedColorSpace;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item != NULL && !item->IsEnabled()) {
|
||||||
|
// find the next best item
|
||||||
|
int32 index = fColorsMenu->IndexOf(item);
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
for (int32 i = index + 1; i < fColorsMenu->CountItems(); i++) {
|
||||||
|
item = fColorsMenu->ItemAt(i);
|
||||||
|
if (item->IsEnabled()) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
// search backwards as well
|
||||||
|
for (int32 i = index - 1; i >= 0; i--) {
|
||||||
|
item = fColorsMenu->ItemAt(i);
|
||||||
|
if (item->IsEnabled())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
item->SetMarked(true);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
// Update selected space
|
||||||
|
|
||||||
|
BMessage* message = item->Message();
|
||||||
|
int32 space;
|
||||||
|
if (message->FindInt32("space", &space) == B_OK) {
|
||||||
|
fSelected.space = (color_space)space;
|
||||||
|
_UpdateColorLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -694,28 +761,22 @@ ScreenWindow::_UpdateControls()
|
|||||||
|
|
||||||
item = fColorsMenu->ItemAt(0);
|
item = fColorsMenu->ItemAt(0);
|
||||||
|
|
||||||
for (int32 i = kColorSpaceCount; i-- > 0;) {
|
for (int32 i = 0, index = 0; i < kColorSpaceCount; i++) {
|
||||||
if (kColorSpaces[i].space == fSelected.space
|
if ((fSupportedColorSpaces & (1 << i)) == 0)
|
||||||
|| (kColorSpaces[i].space == B_RGB32
|
continue;
|
||||||
&& fSelected.space == B_RGB24)) {
|
|
||||||
item = fColorsMenu->ItemAt(i);
|
if (kColorSpaces[i].space == fSelected.space) {
|
||||||
|
item = fColorsMenu->ItemAt(index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item && !item->IsMarked())
|
if (item && !item->IsMarked())
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
|
|
||||||
string.Truncate(0);
|
_UpdateColorLabel();
|
||||||
uint32 bitsPerPixel = fSelected.BitsPerPixel();
|
|
||||||
// advertize 24 bit mode as 32 bit to avoid confusion
|
|
||||||
if (bitsPerPixel == 24)
|
|
||||||
bitsPerPixel = 32;
|
|
||||||
|
|
||||||
string << bitsPerPixel << " Bits/Pixel";
|
|
||||||
if (string != fColorsMenu->Superitem()->Label())
|
|
||||||
fColorsMenu->Superitem()->SetLabel(string.String());
|
|
||||||
|
|
||||||
_UpdateMonitorView();
|
_UpdateMonitorView();
|
||||||
_UpdateRefreshControl();
|
_UpdateRefreshControl();
|
||||||
|
|
||||||
@@ -857,11 +918,17 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case POP_COLORS_MSG:
|
case POP_COLORS_MSG:
|
||||||
{
|
{
|
||||||
message->FindInt32("space", (int32 *)&fSelected.space);
|
int32 space;
|
||||||
|
if (message->FindInt32("space", &space) != B_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
BString string;
|
int32 index;
|
||||||
string << fSelected.BitsPerPixel() << " Bits/Pixel";
|
if (message->FindInt32("index", &index) == B_OK
|
||||||
fColorsMenu->Superitem()->SetLabel(string.String());
|
&& fColorsMenu->ItemAt(index) != NULL)
|
||||||
|
fUserSelectedColorSpace = fColorsMenu->ItemAt(index);
|
||||||
|
|
||||||
|
fSelected.space = (color_space)space;
|
||||||
|
_UpdateColorLabel();
|
||||||
|
|
||||||
_CheckApplyEnabled();
|
_CheckApplyEnabled();
|
||||||
break;
|
break;
|
||||||
@@ -871,7 +938,7 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
{
|
{
|
||||||
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 a refresh rate prefix
|
||||||
|
|
||||||
_CheckApplyEnabled();
|
_CheckApplyEnabled();
|
||||||
break;
|
break;
|
||||||
@@ -1063,6 +1130,22 @@ ScreenWindow::_GetColumnRowButton(bool columns, bool plus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScreenWindow::_BuildSupportedColorSpaces()
|
||||||
|
{
|
||||||
|
fSupportedColorSpaces = 0;
|
||||||
|
|
||||||
|
for (int32 i = 0; i < kColorSpaceCount; i++) {
|
||||||
|
for (int32 j = 0; j < fScreenMode.CountModes(); j++) {
|
||||||
|
if (fScreenMode.ModeAt(j).space == kColorSpaces[i].space) {
|
||||||
|
fSupportedColorSpaces |= 1 << i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenWindow::_CheckApplyEnabled()
|
ScreenWindow::_CheckApplyEnabled()
|
||||||
{
|
{
|
||||||
@@ -1141,6 +1224,15 @@ ScreenWindow::_UpdateMonitor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScreenWindow::_UpdateColorLabel()
|
||||||
|
{
|
||||||
|
BString string;
|
||||||
|
string << fSelected.BitsPerPixel() << " Bits/Pixel";
|
||||||
|
fColorsMenu->Superitem()->SetLabel(string.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenWindow::_Apply()
|
ScreenWindow::_Apply()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class ScreenWindow : public BWindow {
|
|||||||
BButton* _CreateColumnRowButton(bool columns, bool plus);
|
BButton* _CreateColumnRowButton(bool columns, bool plus);
|
||||||
BButton* _GetColumnRowButton(bool columns, bool plus);
|
BButton* _GetColumnRowButton(bool columns, bool plus);
|
||||||
|
|
||||||
|
void _BuildSupportedColorSpaces();
|
||||||
|
|
||||||
void _CheckApplyEnabled();
|
void _CheckApplyEnabled();
|
||||||
void _CheckResolutionMenu();
|
void _CheckResolutionMenu();
|
||||||
void _CheckColorMenu();
|
void _CheckColorMenu();
|
||||||
@@ -54,12 +56,14 @@ class ScreenWindow : public BWindow {
|
|||||||
void _UpdateControls();
|
void _UpdateControls();
|
||||||
void _UpdateOriginal();
|
void _UpdateOriginal();
|
||||||
void _UpdateMonitor();
|
void _UpdateMonitor();
|
||||||
|
void _UpdateColorLabel();
|
||||||
|
|
||||||
void _Apply();
|
void _Apply();
|
||||||
|
|
||||||
status_t _WriteVesaModeFile(const screen_mode& mode) const;
|
status_t _WriteVesaModeFile(const screen_mode& mode) const;
|
||||||
bool _IsVesa() const { return fIsVesa; }
|
bool _IsVesa() const { return fIsVesa; }
|
||||||
|
|
||||||
|
private:
|
||||||
ScreenSettings* fSettings;
|
ScreenSettings* fSettings;
|
||||||
bool fIsVesa;
|
bool fIsVesa;
|
||||||
bool fBootWorkspaceApplied;
|
bool fBootWorkspaceApplied;
|
||||||
@@ -72,6 +76,9 @@ class ScreenWindow : public BWindow {
|
|||||||
BTextControl* fRowsControl;
|
BTextControl* fRowsControl;
|
||||||
BButton* fWorkspacesButtons[4];
|
BButton* fWorkspacesButtons[4];
|
||||||
|
|
||||||
|
uint32 fSupportedColorSpaces;
|
||||||
|
BMenuItem* fUserSelectedColorSpace;
|
||||||
|
|
||||||
BPopUpMenu* fResolutionMenu;
|
BPopUpMenu* fResolutionMenu;
|
||||||
BMenuField* fResolutionField;
|
BMenuField* fResolutionField;
|
||||||
BPopUpMenu* fColorsMenu;
|
BPopUpMenu* fColorsMenu;
|
||||||
|
|||||||
Reference in New Issue
Block a user