Use layout management for all of the window. Can be improved by making
the listview use all the available additional size. But works far better than before. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28708 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,18 +6,19 @@
|
|||||||
* DarkWyrm ([email protected])
|
* DarkWyrm ([email protected])
|
||||||
* Rene Gollent ([email protected])
|
* Rene Gollent ([email protected])
|
||||||
*/
|
*/
|
||||||
#include <OS.h>
|
#include "APRView.h"
|
||||||
#include <Directory.h>
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Messenger.h>
|
#include <Directory.h>
|
||||||
#include <storage/Path.h>
|
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <Messenger.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <SpaceLayoutItem.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <InterfaceDefs.h>
|
|
||||||
|
|
||||||
#include "APRView.h"
|
|
||||||
#include "APRWindow.h"
|
#include "APRWindow.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "ColorWell.h"
|
#include "ColorWell.h"
|
||||||
@@ -37,17 +38,13 @@ namespace BPrivate
|
|||||||
status_t get_decorator_preview(const int32 &index, BBitmap *bitmap);
|
status_t get_decorator_preview(const int32 &index, BBitmap *bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags)
|
APRView::APRView(const char *name, uint32 flags)
|
||||||
: BView(frame,name,resize,flags),
|
: BView(name, flags),
|
||||||
fDefaultSet(ColorSet::DefaultColorSet()),
|
fDefaultSet(ColorSet::DefaultColorSet()),
|
||||||
fDecorMenu(NULL)
|
fDecorMenu(NULL)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
BRect rect(Bounds().InsetByCopy(kBorderSpace,kBorderSpace));
|
|
||||||
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
|
||||||
|
|
||||||
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) {
|
||||||
@@ -57,75 +54,58 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags
|
|||||||
if (name.CountChars() < 1)
|
if (name.CountChars() < 1)
|
||||||
continue;
|
continue;
|
||||||
fDecorMenu->AddItem(new BMenuItem(name.String(),
|
fDecorMenu->AddItem(new BMenuItem(name.String(),
|
||||||
new BMessage(DECORATOR_CHANGED)));
|
new BMessage(DECORATOR_CHANGED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
BMenuField *field = new BMenuField(rect, "menufield", "Window Style",
|
BMenuField *field = new BMenuField("Window Style", fDecorMenu);
|
||||||
fDecorMenu, B_FOLLOW_RIGHT |
|
// TODO: use this menu field.
|
||||||
B_FOLLOW_TOP);
|
|
||||||
AddChild(field);
|
|
||||||
field->SetDivider(be_plain_font->StringWidth("Window style: ") + 5);
|
|
||||||
field->ResizeToPreferred();
|
|
||||||
field->MoveTo(Bounds().right - field->Bounds().Width(), 10);
|
|
||||||
rect = Bounds().InsetByCopy(10,10);
|
|
||||||
rect.OffsetTo(10, field->Frame().bottom + 10);
|
|
||||||
}
|
}
|
||||||
BMenuItem *marked = fDecorMenu->ItemAt(BPrivate::get_decorator());
|
BMenuItem *marked = fDecorMenu->ItemAt(BPrivate::get_decorator());
|
||||||
if (marked)
|
if (marked)
|
||||||
marked->SetMarked(true);
|
marked->SetMarked(true);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
marked = fDecorMenu->FindItem("Default");
|
marked = fDecorMenu->FindItem("Default");
|
||||||
if (marked)
|
if (marked)
|
||||||
marked->SetMarked(true);
|
marked->SetMarked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
// Set up list of color attributes
|
||||||
|
fAttrList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST);
|
||||||
|
|
||||||
// Set up list of color fAttributes
|
fScrollView = new BScrollView("ScrollView", fAttrList, 0, false, true);
|
||||||
rect.right -= B_V_SCROLL_BAR_WIDTH;
|
|
||||||
rect.bottom = rect.top + 75;
|
|
||||||
fAttrList = new BListView(rect,"AttributeList", B_SINGLE_SELECTION_LIST,
|
|
||||||
B_FOLLOW_ALL_SIDES);
|
|
||||||
|
|
||||||
fScrollView = new BScrollView("ScrollView",fAttrList, B_FOLLOW_ALL_SIDES,
|
|
||||||
0, false, true);
|
|
||||||
AddChild(fScrollView);
|
|
||||||
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
|
|
||||||
|
|
||||||
for (int32 i = 0; i < color_description_count(); i++) {
|
for (int32 i = 0; i < color_description_count(); i++) {
|
||||||
const ColorDescription& description = *get_color_description(i);
|
const ColorDescription& description = *get_color_description(i);
|
||||||
const char* text = description.text;
|
const char* text = description.text;
|
||||||
color_which which = description.which;
|
color_which which = description.which;
|
||||||
fAttrList->AddItem(new ColorWhichItem(text, which));
|
fAttrList->AddItem(new ColorWhichItem(text, which));
|
||||||
}
|
}
|
||||||
|
|
||||||
rect = fScrollView->Frame();
|
|
||||||
BRect wellrect(0, 0, 50, 50);
|
BRect wellrect(0, 0, 50, 50);
|
||||||
wellrect.OffsetBy(rect.left, rect.bottom + kBorderSpace);
|
fColorWell = new ColorWell(wellrect, new BMessage(COLOR_DROPPED), 0);
|
||||||
fColorWell = new ColorWell(wellrect, new BMessage(COLOR_DROPPED),
|
fColorWell->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER,
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
B_ALIGN_BOTTOM));
|
||||||
AddChild(fColorWell);
|
|
||||||
|
fPicker = new BColorControl(B_ORIGIN, B_CELLS_32x8, 8.0,
|
||||||
fPicker = new BColorControl(BPoint(wellrect.right + kBorderSpace, wellrect.top),
|
"picker", new BMessage(UPDATE_COLOR));
|
||||||
B_CELLS_32x8, 8.0, "fPicker", new BMessage(UPDATE_COLOR));
|
|
||||||
fPicker->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
AddChild(fPicker);
|
|
||||||
|
// TODO: Make list view and scroller use all the additional height
|
||||||
// bottom align ColorWell and ColorPicker
|
// available!
|
||||||
float bottom = Bounds().bottom - kBorderSpace;
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
float colorWellBottom = fColorWell->Frame().bottom;
|
.Add(fScrollView)
|
||||||
float pickerBottom = fPicker->Frame().bottom;
|
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
|
||||||
float delta = bottom - max_c(colorWellBottom, pickerBottom);
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
||||||
fColorWell->MoveBy(0, delta);
|
.Add(fColorWell)
|
||||||
fPicker->MoveBy(0, delta);
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
|
||||||
fScrollView->ResizeBy(0, delta);
|
.Add(fPicker)
|
||||||
// since this view is not attached to a window yet,
|
)
|
||||||
// we have to resize the fScrollView children too
|
.SetInsets(10, 10, 10, 10)
|
||||||
fScrollView->ScrollBar(B_VERTICAL)->ResizeBy(0, delta);
|
);
|
||||||
fAttrList->ResizeBy(0, delta);
|
|
||||||
|
fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
APRView::~APRView(void)
|
APRView::~APRView(void)
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ class APRWindow;
|
|||||||
class APRView : public BView
|
class APRView : public BView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
APRView(const BRect &frame, const char *name, int32 resize,
|
APRView(const char *name, uint32 flags);
|
||||||
int32 flags);
|
|
||||||
~APRView(void);
|
~APRView(void);
|
||||||
void AttachedToWindow(void);
|
void AttachedToWindow(void);
|
||||||
void MessageReceived(BMessage *msg);
|
void MessageReceived(BMessage *msg);
|
||||||
|
|||||||
@@ -5,11 +5,14 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* DarkWyrm ([email protected])
|
* DarkWyrm ([email protected])
|
||||||
*/
|
*/
|
||||||
|
#include "APRWindow.h"
|
||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
|
#include <SpaceLayoutItem.h>
|
||||||
#include <TabView.h>
|
#include <TabView.h>
|
||||||
#include "APRWindow.h"
|
|
||||||
#include "APRView.h"
|
#include "APRView.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
@@ -17,56 +20,40 @@ static const uint32 kMsgSetDefaults = 'dflt';
|
|||||||
static const uint32 kMsgRevert = 'rvrt';
|
static const uint32 kMsgRevert = 'rvrt';
|
||||||
|
|
||||||
APRWindow::APRWindow(BRect frame)
|
APRWindow::APRWindow(BRect frame)
|
||||||
: BWindow(frame, "Appearance", B_TITLED_WINDOW, B_NOT_ZOOMABLE,
|
: BWindow(frame, "Appearance", B_TITLED_WINDOW,
|
||||||
B_ALL_WORKSPACES)
|
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS,
|
||||||
|
B_ALL_WORKSPACES)
|
||||||
{
|
{
|
||||||
BRect rect = Bounds();
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
BView* view = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW);
|
|
||||||
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
AddChild(view);
|
|
||||||
|
|
||||||
rect.left = 10;
|
fDefaultsButton = new BButton("defaults", "Defaults",
|
||||||
rect.top = rect.bottom - 10;
|
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
|
||||||
fDefaultsButton = new BButton(rect, "defaults", "Defaults",
|
|
||||||
new BMessage(kMsgSetDefaults), B_FOLLOW_LEFT
|
|
||||||
| B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
|
||||||
fDefaultsButton->ResizeToPreferred();
|
|
||||||
fDefaultsButton->SetEnabled(false);
|
|
||||||
float buttonHeight = fDefaultsButton->Bounds().Height();
|
|
||||||
fDefaultsButton->MoveBy(0, -buttonHeight);
|
|
||||||
view->AddChild(fDefaultsButton);
|
|
||||||
|
|
||||||
rect = fDefaultsButton->Frame();
|
fRevertButton = new BButton("revert", "Revert",
|
||||||
rect.OffsetBy(fDefaultsButton->Bounds().Width() + 10, 0);
|
new BMessage(kMsgRevert), B_WILL_DRAW);
|
||||||
|
|
||||||
fRevertButton = new BButton(rect, "revert", "Revert",
|
BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
|
||||||
new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
|
||||||
fRevertButton->ResizeToPreferred();
|
|
||||||
fRevertButton->SetEnabled(false);
|
|
||||||
view->AddChild(fRevertButton);
|
|
||||||
|
|
||||||
rect = Bounds();
|
fAntialiasingSettings = new AntialiasingSettingsView("Antialiasing");
|
||||||
rect.top += 5;
|
fColorsView = new APRView("Colors", B_WILL_DRAW);
|
||||||
rect.bottom -= 20 + buttonHeight;
|
|
||||||
rect.left += 5;
|
|
||||||
BTabView *tabView = new BTabView(rect, "tabview", B_WIDTH_FROM_LABEL);
|
|
||||||
|
|
||||||
rect = tabView->ContainerView()->Bounds().InsetByCopy(5, 8);
|
|
||||||
|
|
||||||
fAntialiasingSettings = new AntialiasingSettingsView(rect, "Antialiasing");
|
|
||||||
fColorsView = new APRView(rect, "Colors", B_FOLLOW_ALL, B_WILL_DRAW);
|
|
||||||
|
|
||||||
tabView->AddTab(fColorsView);
|
tabView->AddTab(fColorsView);
|
||||||
tabView->AddTab(fAntialiasingSettings);
|
tabView->AddTab(fAntialiasingSettings);
|
||||||
|
|
||||||
view->AddChild(tabView);
|
|
||||||
fColorsView->ResizeToPreferred();
|
|
||||||
fAntialiasingSettings->ResizeToPreferred();
|
|
||||||
|
|
||||||
fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
|
fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
|
||||||
|| fAntialiasingSettings->IsDefaultable());
|
|| fAntialiasingSettings->IsDefaultable());
|
||||||
fDefaultsButton->SetTarget(this);
|
fRevertButton->SetEnabled(false);
|
||||||
fRevertButton->SetTarget(this);
|
|
||||||
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
|
.Add(tabView)
|
||||||
|
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
|
||||||
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
||||||
|
.Add(fRevertButton)
|
||||||
|
.AddGlue()
|
||||||
|
.Add(fDefaultsButton)
|
||||||
|
)
|
||||||
|
.SetInsets(5, 5, 5, 5)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ extern status_t get_average_weight(unsigned char* averageWeight);
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
AntialiasingSettingsView::AntialiasingSettingsView(BRect rect, const char* name)
|
AntialiasingSettingsView::AntialiasingSettingsView(const char* name)
|
||||||
: BView(rect, name, B_FOLLOW_ALL, B_SUPPORTS_LAYOUT)
|
: BView(name, 0)
|
||||||
{
|
{
|
||||||
// collect the current system settings
|
// collect the current system settings
|
||||||
if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK)
|
if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK)
|
||||||
@@ -141,11 +141,6 @@ AntialiasingSettingsView::AntialiasingSettingsView(BRect rect, const char* name)
|
|||||||
_SetCurrentAntialiasing();
|
_SetCurrentAntialiasing();
|
||||||
_SetCurrentHinting();
|
_SetCurrentHinting();
|
||||||
_SetCurrentAverageWeight();
|
_SetCurrentAverageWeight();
|
||||||
|
|
||||||
// TODO: Remove once these two lines once the entire window uses
|
|
||||||
// layout management.
|
|
||||||
MoveTo(rect.LeftTop());
|
|
||||||
ResizeTo(rect.Width(), rect.Height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ class BSlider;
|
|||||||
|
|
||||||
class AntialiasingSettingsView : public BView {
|
class AntialiasingSettingsView : public BView {
|
||||||
public:
|
public:
|
||||||
AntialiasingSettingsView(BRect rect,
|
AntialiasingSettingsView(const char* name);
|
||||||
const char* name);
|
|
||||||
virtual ~AntialiasingSettingsView();
|
virtual ~AntialiasingSettingsView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
|||||||
Reference in New Issue
Block a user