* 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:
@@ -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>
|
||||||
@@ -45,6 +46,7 @@ APRView::APRView(const char *name, uint32 flags)
|
|||||||
{
|
{
|
||||||
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,6 +70,7 @@ 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,6 +131,7 @@ APRView::AttachedToWindow(void)
|
|||||||
fAttrList->Select(0);
|
fAttrList->Select(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
APRView::MessageReceived(BMessage *msg)
|
APRView::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
@@ -133,13 +139,15 @@ APRView::MessageReceived(BMessage *msg)
|
|||||||
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,7 +155,8 @@ 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);
|
||||||
@@ -155,12 +164,12 @@ APRView::MessageReceived(BMessage *msg)
|
|||||||
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;
|
||||||
|
|
||||||
@@ -171,7 +180,8 @@ APRView::MessageReceived(BMessage *msg)
|
|||||||
Window()->PostMessage(kMsgUpdate);
|
Window()->PostMessage(kMsgUpdate);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REVERT_SETTINGS: {
|
case REVERT_SETTINGS:
|
||||||
|
{
|
||||||
fCurrentSet = fPrevSet;
|
fCurrentSet = fPrevSet;
|
||||||
|
|
||||||
UpdateControls();
|
UpdateControls();
|
||||||
@@ -180,15 +190,15 @@ APRView::MessageReceived(BMessage *msg)
|
|||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user