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])
|
||||
* Rene Gollent ([email protected])
|
||||
*/
|
||||
#include <OS.h>
|
||||
#include <Directory.h>
|
||||
#include "APRView.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Messenger.h>
|
||||
#include <storage/Path.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <Messenger.h>
|
||||
#include <Path.h>
|
||||
#include <SpaceLayoutItem.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <InterfaceDefs.h>
|
||||
|
||||
#include "APRView.h"
|
||||
#include "APRWindow.h"
|
||||
#include "defs.h"
|
||||
#include "ColorWell.h"
|
||||
@@ -37,17 +38,13 @@ namespace BPrivate
|
||||
status_t get_decorator_preview(const int32 &index, BBitmap *bitmap);
|
||||
}
|
||||
|
||||
APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags)
|
||||
: BView(frame,name,resize,flags),
|
||||
APRView::APRView(const char *name, uint32 flags)
|
||||
: BView(name, flags),
|
||||
fDefaultSet(ColorSet::DefaultColorSet()),
|
||||
fDecorMenu(NULL)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
BRect rect(Bounds().InsetByCopy(kBorderSpace,kBorderSpace));
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
|
||||
fDecorMenu = new BMenu("Window Style");
|
||||
int32 decorCount = BPrivate::count_decorators();
|
||||
if (decorCount > 1) {
|
||||
@@ -57,75 +54,58 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags
|
||||
if (name.CountChars() < 1)
|
||||
continue;
|
||||
fDecorMenu->AddItem(new BMenuItem(name.String(),
|
||||
new BMessage(DECORATOR_CHANGED)));
|
||||
new BMessage(DECORATOR_CHANGED)));
|
||||
}
|
||||
|
||||
BMenuField *field = new BMenuField(rect, "menufield", "Window Style",
|
||||
fDecorMenu, B_FOLLOW_RIGHT |
|
||||
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);
|
||||
BMenuField *field = new BMenuField("Window Style", fDecorMenu);
|
||||
// TODO: use this menu field.
|
||||
}
|
||||
BMenuItem *marked = fDecorMenu->ItemAt(BPrivate::get_decorator());
|
||||
if (marked)
|
||||
marked->SetMarked(true);
|
||||
else
|
||||
{
|
||||
else {
|
||||
marked = fDecorMenu->FindItem("Default");
|
||||
if (marked)
|
||||
marked->SetMarked(true);
|
||||
}
|
||||
|
||||
#endif
|
||||
// Set up list of color attributes
|
||||
fAttrList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST);
|
||||
|
||||
// Set up list of color fAttributes
|
||||
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 = new BScrollView("ScrollView", fAttrList, 0, false, true);
|
||||
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
|
||||
|
||||
for (int32 i = 0; i < color_description_count(); i++) {
|
||||
const ColorDescription& description = *get_color_description(i);
|
||||
const char* text = description.text;
|
||||
color_which which = description.which;
|
||||
fAttrList->AddItem(new ColorWhichItem(text, which));
|
||||
}
|
||||
|
||||
rect = fScrollView->Frame();
|
||||
|
||||
BRect wellrect(0, 0, 50, 50);
|
||||
wellrect.OffsetBy(rect.left, rect.bottom + kBorderSpace);
|
||||
fColorWell = new ColorWell(wellrect, new BMessage(COLOR_DROPPED),
|
||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
AddChild(fColorWell);
|
||||
|
||||
fPicker = new BColorControl(BPoint(wellrect.right + kBorderSpace, wellrect.top),
|
||||
B_CELLS_32x8, 8.0, "fPicker", new BMessage(UPDATE_COLOR));
|
||||
fPicker->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
AddChild(fPicker);
|
||||
|
||||
// bottom align ColorWell and ColorPicker
|
||||
float bottom = Bounds().bottom - kBorderSpace;
|
||||
float colorWellBottom = fColorWell->Frame().bottom;
|
||||
float pickerBottom = fPicker->Frame().bottom;
|
||||
float delta = bottom - max_c(colorWellBottom, pickerBottom);
|
||||
fColorWell->MoveBy(0, delta);
|
||||
fPicker->MoveBy(0, delta);
|
||||
fScrollView->ResizeBy(0, delta);
|
||||
// since this view is not attached to a window yet,
|
||||
// we have to resize the fScrollView children too
|
||||
fScrollView->ScrollBar(B_VERTICAL)->ResizeBy(0, delta);
|
||||
fAttrList->ResizeBy(0, delta);
|
||||
fColorWell = new ColorWell(wellrect, new BMessage(COLOR_DROPPED), 0);
|
||||
fColorWell->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER,
|
||||
B_ALIGN_BOTTOM));
|
||||
|
||||
fPicker = new BColorControl(B_ORIGIN, B_CELLS_32x8, 8.0,
|
||||
"picker", new BMessage(UPDATE_COLOR));
|
||||
|
||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||
|
||||
// TODO: Make list view and scroller use all the additional height
|
||||
// available!
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||
.Add(fScrollView)
|
||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
||||
.Add(fColorWell)
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
|
||||
.Add(fPicker)
|
||||
)
|
||||
.SetInsets(10, 10, 10, 10)
|
||||
);
|
||||
|
||||
fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
|
||||
}
|
||||
|
||||
APRView::~APRView(void)
|
||||
|
||||
@@ -33,8 +33,7 @@ class APRWindow;
|
||||
class APRView : public BView
|
||||
{
|
||||
public:
|
||||
APRView(const BRect &frame, const char *name, int32 resize,
|
||||
int32 flags);
|
||||
APRView(const char *name, uint32 flags);
|
||||
~APRView(void);
|
||||
void AttachedToWindow(void);
|
||||
void MessageReceived(BMessage *msg);
|
||||
|
||||
@@ -5,11 +5,14 @@
|
||||
* Authors:
|
||||
* DarkWyrm ([email protected])
|
||||
*/
|
||||
#include "APRWindow.h"
|
||||
|
||||
#include <Button.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <Messenger.h>
|
||||
#include <SpaceLayoutItem.h>
|
||||
#include <TabView.h>
|
||||
#include "APRWindow.h"
|
||||
|
||||
#include "APRView.h"
|
||||
#include "defs.h"
|
||||
|
||||
@@ -17,56 +20,40 @@ static const uint32 kMsgSetDefaults = 'dflt';
|
||||
static const uint32 kMsgRevert = 'rvrt';
|
||||
|
||||
APRWindow::APRWindow(BRect frame)
|
||||
: BWindow(frame, "Appearance", B_TITLED_WINDOW, B_NOT_ZOOMABLE,
|
||||
B_ALL_WORKSPACES)
|
||||
: BWindow(frame, "Appearance", B_TITLED_WINDOW,
|
||||
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS,
|
||||
B_ALL_WORKSPACES)
|
||||
{
|
||||
BRect rect = Bounds();
|
||||
BView* view = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(view);
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
|
||||
rect.left = 10;
|
||||
rect.top = rect.bottom - 10;
|
||||
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);
|
||||
fDefaultsButton = new BButton("defaults", "Defaults",
|
||||
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
|
||||
|
||||
rect = fDefaultsButton->Frame();
|
||||
rect.OffsetBy(fDefaultsButton->Bounds().Width() + 10, 0);
|
||||
fRevertButton = new BButton("revert", "Revert",
|
||||
new BMessage(kMsgRevert), B_WILL_DRAW);
|
||||
|
||||
fRevertButton = new BButton(rect, "revert", "Revert",
|
||||
new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
||||
fRevertButton->ResizeToPreferred();
|
||||
fRevertButton->SetEnabled(false);
|
||||
view->AddChild(fRevertButton);
|
||||
BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
|
||||
|
||||
rect = Bounds();
|
||||
rect.top += 5;
|
||||
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);
|
||||
fAntialiasingSettings = new AntialiasingSettingsView("Antialiasing");
|
||||
fColorsView = new APRView("Colors", B_WILL_DRAW);
|
||||
|
||||
tabView->AddTab(fColorsView);
|
||||
tabView->AddTab(fAntialiasingSettings);
|
||||
|
||||
view->AddChild(tabView);
|
||||
fColorsView->ResizeToPreferred();
|
||||
fAntialiasingSettings->ResizeToPreferred();
|
||||
|
||||
fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
|
||||
|| fAntialiasingSettings->IsDefaultable());
|
||||
fDefaultsButton->SetTarget(this);
|
||||
fRevertButton->SetTarget(this);
|
||||
fRevertButton->SetEnabled(false);
|
||||
|
||||
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 -
|
||||
|
||||
|
||||
AntialiasingSettingsView::AntialiasingSettingsView(BRect rect, const char* name)
|
||||
: BView(rect, name, B_FOLLOW_ALL, B_SUPPORTS_LAYOUT)
|
||||
AntialiasingSettingsView::AntialiasingSettingsView(const char* name)
|
||||
: BView(name, 0)
|
||||
{
|
||||
// collect the current system settings
|
||||
if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK)
|
||||
@@ -141,11 +141,6 @@ AntialiasingSettingsView::AntialiasingSettingsView(BRect rect, const char* name)
|
||||
_SetCurrentAntialiasing();
|
||||
_SetCurrentHinting();
|
||||
_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 {
|
||||
public:
|
||||
AntialiasingSettingsView(BRect rect,
|
||||
const char* name);
|
||||
AntialiasingSettingsView(const char* name);
|
||||
virtual ~AntialiasingSettingsView();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
|
||||
Reference in New Issue
Block a user