* Made the color chooser only take up as much space as needed, ie. the list

view will now grow with the window.
* fDecorMenu will no longer be set.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29802 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-03-30 13:47:52 +00:00
parent ebe98045d7
commit ed33219ac8
+47 -31
View File
@@ -1,11 +1,12 @@
/* /*
* Copyright 2002-2008, Haiku. All rights reserved. * Copyright 2002-2009, Haiku. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* DarkWyrm ([email protected]) * DarkWyrm ([email protected])
* Rene Gollent ([email protected]) * Rene Gollent ([email protected])
*/ */
#include "APRView.h" #include "APRView.h"
#include <Alert.h> #include <Alert.h>
@@ -44,7 +45,8 @@ APRView::APRView(const char *name, uint32 flags)
fDecorMenu(NULL) fDecorMenu(NULL)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
#if 0
fDecorMenu = new BMenu("Window Style"); fDecorMenu = new BMenu("Window Style");
int32 decorCount = BPrivate::count_decorators(); int32 decorCount = BPrivate::count_decorators();
if (decorCount > 1) { if (decorCount > 1) {
@@ -68,7 +70,8 @@ APRView::APRView(const char *name, uint32 flags)
if (marked) if (marked)
marked->SetMarked(true); marked->SetMarked(true);
} }
#endif
// Set up list of color attributes // Set up list of color attributes
fAttrList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST); fAttrList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST);
@@ -92,8 +95,6 @@ APRView::APRView(const char *name, uint32 flags)
SetLayout(new BGroupLayout(B_VERTICAL)); SetLayout(new BGroupLayout(B_VERTICAL));
// TODO: Make list view and scroller use all the additional height
// available!
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(fScrollView) .Add(fScrollView)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(BSpaceLayoutItem::CreateVerticalStrut(5))
@@ -105,15 +106,19 @@ APRView::APRView(const char *name, uint32 flags)
.SetInsets(10, 10, 10, 10) .SetInsets(10, 10, 10, 10)
); );
fColorWell->Parent()->SetExplicitMaxSize(
BSize(B_SIZE_UNSET, fPicker->Bounds().Height()));
fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN)); fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
} }
APRView::~APRView(void)
APRView::~APRView()
{ {
} }
void void
APRView::AttachedToWindow(void) APRView::AttachedToWindow()
{ {
fPicker->SetTarget(this); fPicker->SetTarget(this);
fAttrList->SetTarget(this); fAttrList->SetTarget(this);
@@ -126,20 +131,23 @@ APRView::AttachedToWindow(void)
fAttrList->Select(0); fAttrList->Select(0);
} }
void void
APRView::MessageReceived(BMessage *msg) APRView::MessageReceived(BMessage *msg)
{ {
if (msg->WasDropped()) { if (msg->WasDropped()) {
rgb_color *color; rgb_color *color;
ssize_t size; ssize_t size;
if (msg->FindData("RGBColor", (type_code)'RGBC', (const void**)&color, &size) == B_OK) { if (msg->FindData("RGBColor", (type_code)'RGBC', (const void**)&color,
&size) == B_OK) {
SetCurrentColor(*color); SetCurrentColor(*color);
} }
} }
switch(msg->what) { switch (msg->what) {
case DECORATOR_CHANGED: { case DECORATOR_CHANGED:
{
int32 index = fDecorMenu->IndexOf(fDecorMenu->FindMarked()); int32 index = fDecorMenu->IndexOf(fDecorMenu->FindMarked());
#ifdef HAIKU_TARGET_PLATFORM_HAIKU #ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (index >= 0) if (index >= 0)
@@ -147,48 +155,50 @@ APRView::MessageReceived(BMessage *msg)
#endif #endif
break; break;
} }
case UPDATE_COLOR: { case UPDATE_COLOR:
{
// Received from the color fPicker when its color changes // Received from the color fPicker when its color changes
rgb_color color = fPicker->ValueAsColor(); rgb_color color = fPicker->ValueAsColor();
SetCurrentColor(color); SetCurrentColor(color);
Window()->PostMessage(kMsgUpdate); Window()->PostMessage(kMsgUpdate);
break; break;
} }
case ATTRIBUTE_CHOSEN: { case ATTRIBUTE_CHOSEN:
{
// Received when the user chooses a GUI fAttribute from the list // Received when the user chooses a GUI fAttribute from the list
ColorWhichItem *item = (ColorWhichItem*) ColorWhichItem *item = (ColorWhichItem*)
fAttrList->ItemAt(fAttrList->CurrentSelection()); fAttrList->ItemAt(fAttrList->CurrentSelection());
if (item == NULL) if (item == NULL)
break; break;
fWhich = item->ColorWhich(); fWhich = item->ColorWhich();
rgb_color color = fCurrentSet.GetColor(fWhich); rgb_color color = fCurrentSet.GetColor(fWhich);
SetCurrentColor(color); SetCurrentColor(color);
Window()->PostMessage(kMsgUpdate); Window()->PostMessage(kMsgUpdate);
break; break;
} }
case REVERT_SETTINGS: { case REVERT_SETTINGS:
{
fCurrentSet = fPrevSet; fCurrentSet = fPrevSet;
UpdateControls(); UpdateControls();
UpdateAllColors(); UpdateAllColors();
Window()->PostMessage(kMsgUpdate); Window()->PostMessage(kMsgUpdate);
break; break;
} }
case DEFAULT_SETTINGS: { case DEFAULT_SETTINGS:
{
fCurrentSet = ColorSet::DefaultColorSet(); fCurrentSet = ColorSet::DefaultColorSet();
UpdateControls(); UpdateControls();
UpdateAllColors(); UpdateAllColors();
BMenuItem *item = fDecorMenu->FindItem("Default"); BMenuItem *item = fDecorMenu->FindItem("Default");
if (item) if (item) {
{
item->SetMarked(true); item->SetMarked(true);
#ifdef HAIKU_TARGET_PLATFORM_HAIKU #ifdef HAIKU_TARGET_PLATFORM_HAIKU
BPrivate::set_decorator(fDecorMenu->IndexOf(item)); BPrivate::set_decorator(fDecorMenu->IndexOf(item));
@@ -203,7 +213,9 @@ APRView::MessageReceived(BMessage *msg)
} }
} }
void APRView::LoadSettings(void)
void
APRView::LoadSettings()
{ {
for (int32 i = 0; i < color_description_count(); i++) { for (int32 i = 0; i < color_description_count(); i++) {
color_which which = get_color_description(i)->which; color_which which = get_color_description(i)->which;
@@ -213,12 +225,16 @@ void APRView::LoadSettings(void)
fPrevSet = fCurrentSet; fPrevSet = fCurrentSet;
} }
bool APRView::IsDefaultable(void)
bool
APRView::IsDefaultable()
{ {
return fCurrentSet != fDefaultSet; return fCurrentSet != fDefaultSet;
} }
void APRView::UpdateAllColors(void)
void
APRView::UpdateAllColors()
{ {
for (int32 i = 0; i < color_description_count(); i++) { for (int32 i = 0; i < color_description_count(); i++) {
color_which which = get_color_description(i)->which; color_which which = get_color_description(i)->which;
@@ -228,7 +244,7 @@ void APRView::UpdateAllColors(void)
} }
void void
APRView::SetCurrentColor(rgb_color color) APRView::SetCurrentColor(rgb_color color)
{ {
fCurrentSet.SetColor(fWhich, color); fCurrentSet.SetColor(fWhich, color);
@@ -237,7 +253,7 @@ APRView::SetCurrentColor(rgb_color color)
} }
void void
APRView::UpdateControls() APRView::UpdateControls()
{ {
rgb_color color = fCurrentSet.GetColor(fWhich); rgb_color color = fCurrentSet.GetColor(fWhich);