* Apply patch from Takashi Murai: use layouting for Tracker settings window/views.
Slight modifications to the patch:
Put back passing the view names (eventhough it seem useless atm).
One or two small indenting issues.
Implemented your todo (listview width adapts to the longest item).
Thanks a lot.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37978 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -44,6 +44,8 @@ All rights reserved.
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <ControlLook.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <MenuField.h>
|
||||
#include <ColorControl.h>
|
||||
@@ -83,8 +85,9 @@ send_bool_notices(uint32 what, const char *name, bool value)
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "libtracker"
|
||||
|
||||
SettingsView::SettingsView(BRect rect, const char *name)
|
||||
: BView(rect, name, B_FOLLOW_ALL, 0)
|
||||
SettingsView::SettingsView(const char* name)
|
||||
:
|
||||
BGroupView(name)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -165,62 +168,48 @@ SettingsView::IsRevertable() const
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
DesktopSettingsView::DesktopSettingsView(BRect rect)
|
||||
: SettingsView(rect, "DesktopSettingsView")
|
||||
DesktopSettingsView::DesktopSettingsView()
|
||||
:
|
||||
SettingsView("DesktopSettingsView")
|
||||
{
|
||||
rect.OffsetTo(B_ORIGIN);
|
||||
fShowDisksIconRadioButton = new BRadioButton(rect, "",
|
||||
fShowDisksIconRadioButton = new BRadioButton("",
|
||||
B_TRANSLATE("Show Disks icon"),
|
||||
new BMessage(kShowDisksIconChanged));
|
||||
fShowDisksIconRadioButton->ResizeToPreferred();
|
||||
AddChild(fShowDisksIconRadioButton);
|
||||
|
||||
const float itemSpacing = fShowDisksIconRadioButton->Bounds().Height() + kItemExtraSpacing;
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fMountVolumesOntoDesktopRadioButton = new BRadioButton(rect, "",
|
||||
fMountVolumesOntoDesktopRadioButton = new BRadioButton("",
|
||||
B_TRANSLATE("Show volumes on Desktop"),
|
||||
new BMessage(kVolumesOnDesktopChanged));
|
||||
AddChild(fMountVolumesOntoDesktopRadioButton);
|
||||
fMountVolumesOntoDesktopRadioButton->ResizeToPreferred();
|
||||
|
||||
rect.OffsetBy(20, itemSpacing);
|
||||
|
||||
fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox(rect, "",
|
||||
fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("Show shared volumes on Desktop"),
|
||||
new BMessage(kVolumesOnDesktopChanged));
|
||||
AddChild(fMountSharedVolumesOntoDesktopCheckBox);
|
||||
fMountSharedVolumesOntoDesktopCheckBox->ResizeToPreferred();
|
||||
|
||||
rect.OffsetBy(-20, itemSpacing);
|
||||
|
||||
rect = Bounds();
|
||||
rect.top = rect.bottom;
|
||||
fMountButton = new BButton(rect, "",
|
||||
fMountButton = new BButton("",
|
||||
B_TRANSLATE("Mount settings" B_UTF8_ELLIPSIS),
|
||||
new BMessage(kRunAutomounterSettings), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fMountButton->ResizeToPreferred();
|
||||
fMountButton->MoveBy(0, -fMountButton->Bounds().Height());
|
||||
AddChild(fMountButton);
|
||||
new BMessage(kRunAutomounterSettings));
|
||||
|
||||
const float spacing = be_control_look->DefaultItemSpacing();
|
||||
|
||||
BGroupLayoutBuilder(this)
|
||||
.AddGroup(B_VERTICAL)
|
||||
.Add(fShowDisksIconRadioButton)
|
||||
.Add(fMountVolumesOntoDesktopRadioButton)
|
||||
.AddGroup(B_VERTICAL)
|
||||
.Add(fMountSharedVolumesOntoDesktopCheckBox)
|
||||
.SetInsets(20, 0, 0, 0)
|
||||
.End()
|
||||
.AddGlue()
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.Add(fMountButton)
|
||||
.AddGlue()
|
||||
.End()
|
||||
.End()
|
||||
.SetInsets(spacing, spacing, spacing, spacing);
|
||||
|
||||
fMountButton->SetTarget(be_app);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
if (_width != NULL) {
|
||||
*_width = fMountSharedVolumesOntoDesktopCheckBox->Frame().right;
|
||||
}
|
||||
|
||||
if (_height != NULL) {
|
||||
*_height = fMountSharedVolumesOntoDesktopCheckBox->Frame().bottom + 8
|
||||
+ fMountButton->Bounds().Height();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettingsView::AttachedToWindow()
|
||||
{
|
||||
@@ -414,67 +403,54 @@ DesktopSettingsView::IsRevertable() const
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
WindowsSettingsView::WindowsSettingsView(BRect rect)
|
||||
: SettingsView(rect, "WindowsSettingsView")
|
||||
WindowsSettingsView::WindowsSettingsView()
|
||||
:
|
||||
SettingsView("WindowsSettingsView")
|
||||
{
|
||||
rect.OffsetTo(B_ORIGIN);
|
||||
fShowFullPathInTitleBarCheckBox = new BCheckBox(rect, "",
|
||||
fShowFullPathInTitleBarCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("Show folder location in title tab"),
|
||||
new BMessage(kWindowsShowFullPathChanged));
|
||||
fShowFullPathInTitleBarCheckBox->ResizeToPreferred();
|
||||
AddChild(fShowFullPathInTitleBarCheckBox);
|
||||
|
||||
const float itemSpacing = fShowFullPathInTitleBarCheckBox->Bounds().Height() + kItemExtraSpacing;
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fSingleWindowBrowseCheckBox = new BCheckBox(rect, "",
|
||||
fSingleWindowBrowseCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("Single window navigation"),
|
||||
new BMessage(kSingleWindowBrowseChanged));
|
||||
fSingleWindowBrowseCheckBox->ResizeToPreferred();
|
||||
AddChild(fSingleWindowBrowseCheckBox);
|
||||
|
||||
rect.OffsetBy(20, itemSpacing);
|
||||
|
||||
fShowNavigatorCheckBox = new BCheckBox(rect, "",
|
||||
fShowNavigatorCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("Show navigator"),
|
||||
new BMessage(kShowNavigatorChanged));
|
||||
fShowNavigatorCheckBox->ResizeToPreferred();
|
||||
AddChild(fShowNavigatorCheckBox);
|
||||
|
||||
rect.OffsetBy(-20, itemSpacing);
|
||||
|
||||
fOutlineSelectionCheckBox = new BCheckBox(rect, "",
|
||||
fOutlineSelectionCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("Outline selection rectangle only"),
|
||||
new BMessage(kTransparentSelectionChanged));
|
||||
fOutlineSelectionCheckBox->ResizeToPreferred();
|
||||
AddChild(fOutlineSelectionCheckBox);
|
||||
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fSortFolderNamesFirstCheckBox = new BCheckBox(rect, "",
|
||||
fSortFolderNamesFirstCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("List folders first"),
|
||||
new BMessage(kSortFolderNamesFirstChanged));
|
||||
fSortFolderNamesFirstCheckBox->ResizeToPreferred();
|
||||
AddChild(fSortFolderNamesFirstCheckBox);
|
||||
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fTypeAheadFilteringCheckBox = new BCheckBox(rect, "",
|
||||
fTypeAheadFilteringCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("Enable type-ahead filtering"),
|
||||
new BMessage(kTypeAheadFilteringChanged));
|
||||
fTypeAheadFilteringCheckBox->ResizeToPreferred();
|
||||
AddChild(fTypeAheadFilteringCheckBox);
|
||||
}
|
||||
|
||||
const float spacing = be_control_look->DefaultItemSpacing();
|
||||
|
||||
void
|
||||
WindowsSettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
if (_width != NULL)
|
||||
*_width = fOutlineSelectionCheckBox->Frame().right;
|
||||
|
||||
if (_height != NULL)
|
||||
*_height = fSortFolderNamesFirstCheckBox->Frame().bottom;
|
||||
BGroupLayoutBuilder(this)
|
||||
.AddGroup(B_VERTICAL)
|
||||
.AddGroup(B_VERTICAL)
|
||||
.Add(fShowFullPathInTitleBarCheckBox)
|
||||
.Add(fSingleWindowBrowseCheckBox)
|
||||
.End()
|
||||
.AddGroup(B_VERTICAL)
|
||||
.Add(fShowNavigatorCheckBox)
|
||||
.SetInsets(20, 0, 0, 0)
|
||||
.End()
|
||||
.AddGroup(B_VERTICAL)
|
||||
.Add(fOutlineSelectionCheckBox)
|
||||
.Add(fSortFolderNamesFirstCheckBox)
|
||||
.Add(fTypeAheadFilteringCheckBox)
|
||||
.End()
|
||||
.AddGlue()
|
||||
.End()
|
||||
.SetInsets(spacing, spacing, spacing, spacing);
|
||||
}
|
||||
|
||||
|
||||
@@ -719,23 +695,18 @@ WindowsSettingsView::IsRevertable() const
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
||||
: SettingsView(rect, "SpaceBarSettingsView")
|
||||
SpaceBarSettingsView::SpaceBarSettingsView()
|
||||
:
|
||||
SettingsView("SpaceBarSettingsView")
|
||||
{
|
||||
rect.OffsetTo(B_ORIGIN);
|
||||
fSpaceBarShowCheckBox = new BCheckBox(rect, "",
|
||||
fSpaceBarShowCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("Show space bars on volumes"),
|
||||
new BMessage(kUpdateVolumeSpaceBar));
|
||||
fSpaceBarShowCheckBox->ResizeToPreferred();
|
||||
AddChild(fSpaceBarShowCheckBox);
|
||||
|
||||
rect = fSpaceBarShowCheckBox->Frame();
|
||||
rect.OffsetBy(0, fSpaceBarShowCheckBox->Bounds().Height() + kItemExtraSpacing);
|
||||
|
||||
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING);
|
||||
BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING);
|
||||
menu->SetFont(be_plain_font);
|
||||
|
||||
BMenuItem *item;
|
||||
BMenuItem* item;
|
||||
menu->AddItem(item = new BMenuItem(
|
||||
B_TRANSLATE("Used space color"),
|
||||
new BMessage(kSpaceBarSwitchColor)));
|
||||
@@ -748,19 +719,25 @@ SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
||||
B_TRANSLATE("Warning space color"),
|
||||
new BMessage(kSpaceBarSwitchColor)));
|
||||
|
||||
BBox *box = new BBox(rect);
|
||||
box->SetLabel(fColorPicker = new BMenuField(rect, NULL, NULL, menu));
|
||||
AddChild(box);
|
||||
BBox* box = new BBox("box");
|
||||
box->SetLabel(fColorPicker = new BMenuField("menu", NULL, menu));
|
||||
|
||||
fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height()
|
||||
+ 8 + kItemExtraSpacing),
|
||||
B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged));
|
||||
fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
|
||||
fColorControl->ResizeToPreferred();
|
||||
box->AddChild(fColorControl);
|
||||
|
||||
box->ResizeTo(fColorControl->Bounds().Width() + 16,
|
||||
fColorControl->Frame().bottom + 8);
|
||||
const float spacing = be_control_look->DefaultItemSpacing();
|
||||
|
||||
BGroupLayoutBuilder(this)
|
||||
.AddGroup(B_VERTICAL)
|
||||
.Add(fSpaceBarShowCheckBox)
|
||||
.Add(box)
|
||||
.AddGlue()
|
||||
.End()
|
||||
.SetInsets(spacing, spacing, spacing, spacing);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -769,26 +746,6 @@ SpaceBarSettingsView::~SpaceBarSettingsView()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SpaceBarSettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
BView* view = fColorControl->Parent();
|
||||
if (view == NULL)
|
||||
BView::GetPreferredSize(_width, _height);
|
||||
|
||||
if (_width != NULL) {
|
||||
float width = fSpaceBarShowCheckBox->Bounds().Width();
|
||||
if (view->Bounds().Width() > width)
|
||||
width = view->Bounds().Width();
|
||||
|
||||
*_width = width;
|
||||
}
|
||||
|
||||
if (_height != NULL)
|
||||
*_height = view->Frame().bottom;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SpaceBarSettingsView::AttachedToWindow()
|
||||
{
|
||||
@@ -976,40 +933,28 @@ SpaceBarSettingsView::IsRevertable() const
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
TrashSettingsView::TrashSettingsView(BRect rect)
|
||||
: SettingsView(rect, "TrashSettingsView")
|
||||
TrashSettingsView::TrashSettingsView()
|
||||
:
|
||||
SettingsView("TrashSettingsView")
|
||||
{
|
||||
rect.OffsetTo(B_ORIGIN);
|
||||
fDontMoveFilesToTrashCheckBox = new BCheckBox(rect, "",
|
||||
fDontMoveFilesToTrashCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("Don't move files to Trash"),
|
||||
new BMessage(kDontMoveFilesToTrashChanged));
|
||||
fDontMoveFilesToTrashCheckBox->ResizeToPreferred();
|
||||
AddChild(fDontMoveFilesToTrashCheckBox);
|
||||
|
||||
rect = fDontMoveFilesToTrashCheckBox->Frame();
|
||||
rect.OffsetBy(0, fDontMoveFilesToTrashCheckBox->Bounds().Height() + kItemExtraSpacing);
|
||||
|
||||
fAskBeforeDeleteFileCheckBox = new BCheckBox(rect, "",
|
||||
fAskBeforeDeleteFileCheckBox = new BCheckBox("",
|
||||
B_TRANSLATE("Ask before delete"),
|
||||
new BMessage(kAskBeforeDeleteFileChanged));
|
||||
fAskBeforeDeleteFileCheckBox->ResizeToPreferred();
|
||||
AddChild(fAskBeforeDeleteFileCheckBox);
|
||||
}
|
||||
|
||||
const float spacing = be_control_look->DefaultItemSpacing();
|
||||
|
||||
void
|
||||
TrashSettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
if (_width != NULL) {
|
||||
float width = fDontMoveFilesToTrashCheckBox->Bounds().Width();
|
||||
if (width < fAskBeforeDeleteFileCheckBox->Bounds().Width())
|
||||
width = fAskBeforeDeleteFileCheckBox->Bounds().Width();
|
||||
BGroupLayoutBuilder(this)
|
||||
.AddGroup(B_VERTICAL)
|
||||
.Add(fDontMoveFilesToTrashCheckBox)
|
||||
.Add(fAskBeforeDeleteFileCheckBox)
|
||||
.AddGlue()
|
||||
.End()
|
||||
.SetInsets(spacing, spacing, spacing, spacing);
|
||||
|
||||
*_width = width;
|
||||
}
|
||||
|
||||
if (_height != NULL)
|
||||
*_height = fAskBeforeDeleteFileCheckBox->Frame().bottom;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ All rights reserved.
|
||||
#define _SETTINGS_VIEWS
|
||||
|
||||
#include <CheckBox.h>
|
||||
#include <GroupView.h>
|
||||
#include <RadioButton.h>
|
||||
#include <TextControl.h>
|
||||
#include <ColorControl.h>
|
||||
@@ -51,9 +52,9 @@ class BStringView;
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class SettingsView : public BView {
|
||||
class SettingsView : public BGroupView {
|
||||
public:
|
||||
SettingsView(BRect frame, const char *name);
|
||||
SettingsView(const char* name);
|
||||
virtual ~SettingsView();
|
||||
|
||||
virtual void SetDefaults();
|
||||
@@ -64,16 +65,15 @@ class SettingsView : public BView {
|
||||
virtual bool IsRevertable() const;
|
||||
|
||||
protected:
|
||||
typedef BView _inherited;
|
||||
typedef BGroupView _inherited;
|
||||
};
|
||||
|
||||
class DesktopSettingsView : public SettingsView {
|
||||
public:
|
||||
DesktopSettingsView(BRect frame);
|
||||
DesktopSettingsView();
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual bool IsDefaultable() const;
|
||||
@@ -102,11 +102,10 @@ class DesktopSettingsView : public SettingsView {
|
||||
|
||||
class WindowsSettingsView : public SettingsView {
|
||||
public:
|
||||
WindowsSettingsView(BRect frame);
|
||||
WindowsSettingsView();
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual bool IsDefaultable() const;
|
||||
@@ -134,15 +133,13 @@ class WindowsSettingsView : public SettingsView {
|
||||
typedef SettingsView _inherited;
|
||||
};
|
||||
|
||||
|
||||
class SpaceBarSettingsView : public SettingsView {
|
||||
public:
|
||||
SpaceBarSettingsView(BRect frame);
|
||||
SpaceBarSettingsView();
|
||||
virtual ~SpaceBarSettingsView();
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual bool IsDefaultable() const;
|
||||
@@ -167,11 +164,10 @@ class SpaceBarSettingsView : public SettingsView {
|
||||
|
||||
class TrashSettingsView : public SettingsView {
|
||||
public:
|
||||
TrashSettingsView(BRect frame);
|
||||
TrashSettingsView();
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual bool IsDefaultable() const;
|
||||
|
||||
@@ -33,13 +33,14 @@ All rights reserved.
|
||||
*/
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <ControlLook.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
|
||||
#include "SettingsViews.h"
|
||||
#include "TrackerSettings.h"
|
||||
#include "TrackerSettingsWindow.h"
|
||||
|
||||
//#include <CheckBox.h>
|
||||
#include <ScrollView.h>
|
||||
|
||||
|
||||
@@ -73,76 +74,54 @@ TrackerSettingsWindow::TrackerSettingsWindow()
|
||||
BWindow(BRect(80, 80, 450, 350), B_TRANSLATE("Tracker preferences"),
|
||||
B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
|
||||
| B_NO_WORKSPACE_ACTIVATION | B_NOT_ANCHORED_ON_ACTIVATE
|
||||
| B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
||||
| B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
{
|
||||
BRect rect = Bounds();
|
||||
BView *topView = new BView(rect, "Background", B_FOLLOW_ALL, 0);
|
||||
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(topView);
|
||||
fSettingsTypeListView = new BListView("List View", B_SINGLE_SELECTION_LIST);
|
||||
|
||||
rect.InsetBy(10, 10);
|
||||
rect.right = be_plain_font->StringWidth(B_TRANSLATE("Volume Icons"))
|
||||
+ rect.left + (float)B_V_SCROLL_BAR_WIDTH + 40.0f;
|
||||
fSettingsTypeListView = new BListView(rect, "List View", B_SINGLE_SELECTION_LIST,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM);
|
||||
BScrollView* scrollView = new BScrollView("scrollview", fSettingsTypeListView,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
|
||||
topView->AddChild(scrollView);
|
||||
BScrollView* scrollView = new BScrollView("scrollview",
|
||||
fSettingsTypeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
|
||||
|
||||
rect = scrollView->Frame();
|
||||
rect.left = rect.right + 10;
|
||||
rect.top = rect.bottom;
|
||||
fDefaultsButton = new BButton(rect, "Defaults", B_TRANSLATE("Defaults"),
|
||||
new BMessage(kDefaultsButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fDefaultsButton->ResizeToPreferred();
|
||||
fDefaultsButton = new BButton("Defaults", B_TRANSLATE("Defaults"),
|
||||
new BMessage(kDefaultsButtonPressed));
|
||||
fDefaultsButton->SetEnabled(false);
|
||||
fDefaultsButton->MoveBy(0, -fDefaultsButton->Bounds().Height());
|
||||
|
||||
rect = fDefaultsButton->Frame();
|
||||
rect.left = rect.right + 10;
|
||||
fRevertButton = new BButton(rect, "Revert", B_TRANSLATE("Revert"),
|
||||
new BMessage(kRevertButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fRevertButton = new BButton("Revert", B_TRANSLATE("Revert"),
|
||||
new BMessage(kRevertButtonPressed));
|
||||
fRevertButton->SetEnabled(false);
|
||||
fRevertButton->ResizeToPreferred();
|
||||
|
||||
rect = scrollView->Frame();
|
||||
rect.left = rect.right + 10;
|
||||
rect.right = Bounds().right - 10;
|
||||
rect.bottom = fDefaultsButton->Frame().top - 10;
|
||||
fSettingsContainerBox = new BBox(rect, NULL, B_FOLLOW_ALL);
|
||||
topView->AddChild(fSettingsContainerBox);
|
||||
topView->AddChild(fDefaultsButton);
|
||||
topView->AddChild(fRevertButton);
|
||||
fSettingsContainerBox = new BBox("SettingsContainerBox");
|
||||
|
||||
const float spacing = be_control_look->DefaultItemSpacing();
|
||||
|
||||
rect = _SettingsFrame();
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.AddGroup(B_HORIZONTAL, spacing)
|
||||
.Add(scrollView)
|
||||
.AddGroup(B_VERTICAL, spacing)
|
||||
.Add(fSettingsContainerBox)
|
||||
.AddGroup(B_HORIZONTAL, spacing)
|
||||
.Add(fDefaultsButton)
|
||||
.Add(fRevertButton)
|
||||
.AddGlue()
|
||||
.End()
|
||||
.End()
|
||||
.SetInsets(spacing, spacing, spacing, spacing)
|
||||
.End();
|
||||
|
||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Desktop"),
|
||||
new DesktopSettingsView(rect)));
|
||||
new DesktopSettingsView()));
|
||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Windows"),
|
||||
new WindowsSettingsView(rect)));
|
||||
new WindowsSettingsView()));
|
||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Trash"),
|
||||
new TrashSettingsView(rect)));
|
||||
new TrashSettingsView()));
|
||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Volume icons"),
|
||||
new SpaceBarSettingsView(rect)));
|
||||
new SpaceBarSettingsView()));
|
||||
|
||||
// compute preferred view size
|
||||
|
||||
float minWidth = 0, minHeight = 0;
|
||||
|
||||
for (int32 i = 0; i < fSettingsTypeListView->CountItems(); i++) {
|
||||
SettingsView* view = ((SettingsItem *)fSettingsTypeListView->ItemAt(i))->View();
|
||||
|
||||
float width, height;
|
||||
view->GetPreferredSize(&width, &height);
|
||||
|
||||
if (minWidth < width)
|
||||
minWidth = width;
|
||||
if (minHeight < height)
|
||||
minHeight = height;
|
||||
}
|
||||
|
||||
ResizeBy(max_c(minWidth - rect.Width(), 0), max_c(minHeight - rect.Height(), 0));
|
||||
// make sure window is large enough to contain all views
|
||||
// constraint the listview width so that the longest item fits
|
||||
float width = 0;
|
||||
fSettingsTypeListView->GetPreferredSize(&width, NULL);
|
||||
width += B_V_SCROLL_BAR_WIDTH;
|
||||
fSettingsTypeListView->SetExplicitMinSize(BSize(width, 0));
|
||||
fSettingsTypeListView->SetExplicitMaxSize(BSize(width, B_SIZE_UNLIMITED));
|
||||
|
||||
fSettingsTypeListView->SetSelectionMessage(new BMessage(kSettingsViewChanged));
|
||||
fSettingsTypeListView->Select(0);
|
||||
@@ -230,19 +209,6 @@ TrackerSettingsWindow::_ViewAt(int32 i)
|
||||
}
|
||||
|
||||
|
||||
BRect
|
||||
TrackerSettingsWindow::_SettingsFrame()
|
||||
{
|
||||
font_height fontHeight;
|
||||
be_bold_font->GetHeight(&fontHeight);
|
||||
|
||||
BRect rect = fSettingsContainerBox->Bounds().InsetByCopy(8, 8);
|
||||
rect.top += ceilf(fontHeight.ascent + fontHeight.descent);
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackerSettingsWindow::_HandleChangedContents()
|
||||
{
|
||||
@@ -322,10 +288,6 @@ TrackerSettingsWindow::_HandleChangedSettingsView()
|
||||
view->Hide();
|
||||
fSettingsContainerBox->AddChild(view);
|
||||
|
||||
// Resize view after it has been attached to the window, so that
|
||||
// it's resizing modes are respected
|
||||
BRect rect = _SettingsFrame();
|
||||
view->ResizeTo(rect.Width(), rect.Height());
|
||||
view->Show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ class TrackerSettingsWindow : public BWindow {
|
||||
|
||||
private:
|
||||
SettingsView *_ViewAt(int32 i);
|
||||
BRect _SettingsFrame();
|
||||
|
||||
void _HandleChangedContents();
|
||||
void _HandlePressedDefaultsButton();
|
||||
|
||||
Reference in New Issue
Block a user