* 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 <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <ColorControl.h>
|
#include <ColorControl.h>
|
||||||
@@ -83,8 +85,9 @@ send_bool_notices(uint32 what, const char *name, bool value)
|
|||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
#define B_TRANSLATE_CONTEXT "libtracker"
|
#define B_TRANSLATE_CONTEXT "libtracker"
|
||||||
|
|
||||||
SettingsView::SettingsView(BRect rect, const char *name)
|
SettingsView::SettingsView(const char* name)
|
||||||
: BView(rect, name, B_FOLLOW_ALL, 0)
|
:
|
||||||
|
BGroupView(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,62 +168,48 @@ SettingsView::IsRevertable() const
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
DesktopSettingsView::DesktopSettingsView(BRect rect)
|
DesktopSettingsView::DesktopSettingsView()
|
||||||
: SettingsView(rect, "DesktopSettingsView")
|
:
|
||||||
|
SettingsView("DesktopSettingsView")
|
||||||
{
|
{
|
||||||
rect.OffsetTo(B_ORIGIN);
|
fShowDisksIconRadioButton = new BRadioButton("",
|
||||||
fShowDisksIconRadioButton = new BRadioButton(rect, "",
|
|
||||||
B_TRANSLATE("Show Disks icon"),
|
B_TRANSLATE("Show Disks icon"),
|
||||||
new BMessage(kShowDisksIconChanged));
|
new BMessage(kShowDisksIconChanged));
|
||||||
fShowDisksIconRadioButton->ResizeToPreferred();
|
|
||||||
AddChild(fShowDisksIconRadioButton);
|
|
||||||
|
|
||||||
const float itemSpacing = fShowDisksIconRadioButton->Bounds().Height() + kItemExtraSpacing;
|
fMountVolumesOntoDesktopRadioButton = new BRadioButton("",
|
||||||
rect.OffsetBy(0, itemSpacing);
|
|
||||||
|
|
||||||
fMountVolumesOntoDesktopRadioButton = new BRadioButton(rect, "",
|
|
||||||
B_TRANSLATE("Show volumes on Desktop"),
|
B_TRANSLATE("Show volumes on Desktop"),
|
||||||
new BMessage(kVolumesOnDesktopChanged));
|
new BMessage(kVolumesOnDesktopChanged));
|
||||||
AddChild(fMountVolumesOntoDesktopRadioButton);
|
|
||||||
fMountVolumesOntoDesktopRadioButton->ResizeToPreferred();
|
|
||||||
|
|
||||||
rect.OffsetBy(20, itemSpacing);
|
fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox("",
|
||||||
|
|
||||||
fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("Show shared volumes on Desktop"),
|
B_TRANSLATE("Show shared volumes on Desktop"),
|
||||||
new BMessage(kVolumesOnDesktopChanged));
|
new BMessage(kVolumesOnDesktopChanged));
|
||||||
AddChild(fMountSharedVolumesOntoDesktopCheckBox);
|
|
||||||
fMountSharedVolumesOntoDesktopCheckBox->ResizeToPreferred();
|
|
||||||
|
|
||||||
rect.OffsetBy(-20, itemSpacing);
|
fMountButton = new BButton("",
|
||||||
|
|
||||||
rect = Bounds();
|
|
||||||
rect.top = rect.bottom;
|
|
||||||
fMountButton = new BButton(rect, "",
|
|
||||||
B_TRANSLATE("Mount settings" B_UTF8_ELLIPSIS),
|
B_TRANSLATE("Mount settings" B_UTF8_ELLIPSIS),
|
||||||
new BMessage(kRunAutomounterSettings), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
new BMessage(kRunAutomounterSettings));
|
||||||
fMountButton->ResizeToPreferred();
|
|
||||||
fMountButton->MoveBy(0, -fMountButton->Bounds().Height());
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
AddChild(fMountButton);
|
|
||||||
|
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);
|
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
|
void
|
||||||
DesktopSettingsView::AttachedToWindow()
|
DesktopSettingsView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@@ -414,67 +403,54 @@ DesktopSettingsView::IsRevertable() const
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
WindowsSettingsView::WindowsSettingsView(BRect rect)
|
WindowsSettingsView::WindowsSettingsView()
|
||||||
: SettingsView(rect, "WindowsSettingsView")
|
:
|
||||||
|
SettingsView("WindowsSettingsView")
|
||||||
{
|
{
|
||||||
rect.OffsetTo(B_ORIGIN);
|
fShowFullPathInTitleBarCheckBox = new BCheckBox("",
|
||||||
fShowFullPathInTitleBarCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("Show folder location in title tab"),
|
B_TRANSLATE("Show folder location in title tab"),
|
||||||
new BMessage(kWindowsShowFullPathChanged));
|
new BMessage(kWindowsShowFullPathChanged));
|
||||||
fShowFullPathInTitleBarCheckBox->ResizeToPreferred();
|
|
||||||
AddChild(fShowFullPathInTitleBarCheckBox);
|
|
||||||
|
|
||||||
const float itemSpacing = fShowFullPathInTitleBarCheckBox->Bounds().Height() + kItemExtraSpacing;
|
fSingleWindowBrowseCheckBox = new BCheckBox("",
|
||||||
rect.OffsetBy(0, itemSpacing);
|
|
||||||
|
|
||||||
fSingleWindowBrowseCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("Single window navigation"),
|
B_TRANSLATE("Single window navigation"),
|
||||||
new BMessage(kSingleWindowBrowseChanged));
|
new BMessage(kSingleWindowBrowseChanged));
|
||||||
fSingleWindowBrowseCheckBox->ResizeToPreferred();
|
|
||||||
AddChild(fSingleWindowBrowseCheckBox);
|
|
||||||
|
|
||||||
rect.OffsetBy(20, itemSpacing);
|
fShowNavigatorCheckBox = new BCheckBox("",
|
||||||
|
|
||||||
fShowNavigatorCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("Show navigator"),
|
B_TRANSLATE("Show navigator"),
|
||||||
new BMessage(kShowNavigatorChanged));
|
new BMessage(kShowNavigatorChanged));
|
||||||
fShowNavigatorCheckBox->ResizeToPreferred();
|
|
||||||
AddChild(fShowNavigatorCheckBox);
|
|
||||||
|
|
||||||
rect.OffsetBy(-20, itemSpacing);
|
fOutlineSelectionCheckBox = new BCheckBox("",
|
||||||
|
|
||||||
fOutlineSelectionCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("Outline selection rectangle only"),
|
B_TRANSLATE("Outline selection rectangle only"),
|
||||||
new BMessage(kTransparentSelectionChanged));
|
new BMessage(kTransparentSelectionChanged));
|
||||||
fOutlineSelectionCheckBox->ResizeToPreferred();
|
|
||||||
AddChild(fOutlineSelectionCheckBox);
|
|
||||||
|
|
||||||
rect.OffsetBy(0, itemSpacing);
|
fSortFolderNamesFirstCheckBox = new BCheckBox("",
|
||||||
|
|
||||||
fSortFolderNamesFirstCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("List folders first"),
|
B_TRANSLATE("List folders first"),
|
||||||
new BMessage(kSortFolderNamesFirstChanged));
|
new BMessage(kSortFolderNamesFirstChanged));
|
||||||
fSortFolderNamesFirstCheckBox->ResizeToPreferred();
|
|
||||||
AddChild(fSortFolderNamesFirstCheckBox);
|
|
||||||
|
|
||||||
rect.OffsetBy(0, itemSpacing);
|
fTypeAheadFilteringCheckBox = new BCheckBox("",
|
||||||
|
|
||||||
fTypeAheadFilteringCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("Enable type-ahead filtering"),
|
B_TRANSLATE("Enable type-ahead filtering"),
|
||||||
new BMessage(kTypeAheadFilteringChanged));
|
new BMessage(kTypeAheadFilteringChanged));
|
||||||
fTypeAheadFilteringCheckBox->ResizeToPreferred();
|
|
||||||
AddChild(fTypeAheadFilteringCheckBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
|
|
||||||
void
|
BGroupLayoutBuilder(this)
|
||||||
WindowsSettingsView::GetPreferredSize(float *_width, float *_height)
|
.AddGroup(B_VERTICAL)
|
||||||
{
|
.AddGroup(B_VERTICAL)
|
||||||
if (_width != NULL)
|
.Add(fShowFullPathInTitleBarCheckBox)
|
||||||
*_width = fOutlineSelectionCheckBox->Frame().right;
|
.Add(fSingleWindowBrowseCheckBox)
|
||||||
|
.End()
|
||||||
if (_height != NULL)
|
.AddGroup(B_VERTICAL)
|
||||||
*_height = fSortFolderNamesFirstCheckBox->Frame().bottom;
|
.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 -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
SpaceBarSettingsView::SpaceBarSettingsView()
|
||||||
: SettingsView(rect, "SpaceBarSettingsView")
|
:
|
||||||
|
SettingsView("SpaceBarSettingsView")
|
||||||
{
|
{
|
||||||
rect.OffsetTo(B_ORIGIN);
|
fSpaceBarShowCheckBox = new BCheckBox("",
|
||||||
fSpaceBarShowCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("Show space bars on volumes"),
|
B_TRANSLATE("Show space bars on volumes"),
|
||||||
new BMessage(kUpdateVolumeSpaceBar));
|
new BMessage(kUpdateVolumeSpaceBar));
|
||||||
fSpaceBarShowCheckBox->ResizeToPreferred();
|
|
||||||
AddChild(fSpaceBarShowCheckBox);
|
|
||||||
|
|
||||||
rect = fSpaceBarShowCheckBox->Frame();
|
BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING);
|
||||||
rect.OffsetBy(0, fSpaceBarShowCheckBox->Bounds().Height() + kItemExtraSpacing);
|
|
||||||
|
|
||||||
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING);
|
|
||||||
menu->SetFont(be_plain_font);
|
menu->SetFont(be_plain_font);
|
||||||
|
|
||||||
BMenuItem *item;
|
BMenuItem* item;
|
||||||
menu->AddItem(item = new BMenuItem(
|
menu->AddItem(item = new BMenuItem(
|
||||||
B_TRANSLATE("Used space color"),
|
B_TRANSLATE("Used space color"),
|
||||||
new BMessage(kSpaceBarSwitchColor)));
|
new BMessage(kSpaceBarSwitchColor)));
|
||||||
@@ -748,19 +719,25 @@ SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
|||||||
B_TRANSLATE("Warning space color"),
|
B_TRANSLATE("Warning space color"),
|
||||||
new BMessage(kSpaceBarSwitchColor)));
|
new BMessage(kSpaceBarSwitchColor)));
|
||||||
|
|
||||||
BBox *box = new BBox(rect);
|
BBox* box = new BBox("box");
|
||||||
box->SetLabel(fColorPicker = new BMenuField(rect, NULL, NULL, menu));
|
box->SetLabel(fColorPicker = new BMenuField("menu", NULL, menu));
|
||||||
AddChild(box);
|
|
||||||
|
|
||||||
fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height()
|
fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height()
|
||||||
+ 8 + kItemExtraSpacing),
|
+ 8 + kItemExtraSpacing),
|
||||||
B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged));
|
B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged));
|
||||||
fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
|
fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
|
||||||
fColorControl->ResizeToPreferred();
|
|
||||||
box->AddChild(fColorControl);
|
box->AddChild(fColorControl);
|
||||||
|
|
||||||
box->ResizeTo(fColorControl->Bounds().Width() + 16,
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
fColorControl->Frame().bottom + 8);
|
|
||||||
|
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
|
void
|
||||||
SpaceBarSettingsView::AttachedToWindow()
|
SpaceBarSettingsView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@@ -976,40 +933,28 @@ SpaceBarSettingsView::IsRevertable() const
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
TrashSettingsView::TrashSettingsView(BRect rect)
|
TrashSettingsView::TrashSettingsView()
|
||||||
: SettingsView(rect, "TrashSettingsView")
|
:
|
||||||
|
SettingsView("TrashSettingsView")
|
||||||
{
|
{
|
||||||
rect.OffsetTo(B_ORIGIN);
|
fDontMoveFilesToTrashCheckBox = new BCheckBox("",
|
||||||
fDontMoveFilesToTrashCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("Don't move files to Trash"),
|
B_TRANSLATE("Don't move files to Trash"),
|
||||||
new BMessage(kDontMoveFilesToTrashChanged));
|
new BMessage(kDontMoveFilesToTrashChanged));
|
||||||
fDontMoveFilesToTrashCheckBox->ResizeToPreferred();
|
|
||||||
AddChild(fDontMoveFilesToTrashCheckBox);
|
|
||||||
|
|
||||||
rect = fDontMoveFilesToTrashCheckBox->Frame();
|
fAskBeforeDeleteFileCheckBox = new BCheckBox("",
|
||||||
rect.OffsetBy(0, fDontMoveFilesToTrashCheckBox->Bounds().Height() + kItemExtraSpacing);
|
|
||||||
|
|
||||||
fAskBeforeDeleteFileCheckBox = new BCheckBox(rect, "",
|
|
||||||
B_TRANSLATE("Ask before delete"),
|
B_TRANSLATE("Ask before delete"),
|
||||||
new BMessage(kAskBeforeDeleteFileChanged));
|
new BMessage(kAskBeforeDeleteFileChanged));
|
||||||
fAskBeforeDeleteFileCheckBox->ResizeToPreferred();
|
|
||||||
AddChild(fAskBeforeDeleteFileCheckBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
|
|
||||||
void
|
BGroupLayoutBuilder(this)
|
||||||
TrashSettingsView::GetPreferredSize(float *_width, float *_height)
|
.AddGroup(B_VERTICAL)
|
||||||
{
|
.Add(fDontMoveFilesToTrashCheckBox)
|
||||||
if (_width != NULL) {
|
.Add(fAskBeforeDeleteFileCheckBox)
|
||||||
float width = fDontMoveFilesToTrashCheckBox->Bounds().Width();
|
.AddGlue()
|
||||||
if (width < fAskBeforeDeleteFileCheckBox->Bounds().Width())
|
.End()
|
||||||
width = fAskBeforeDeleteFileCheckBox->Bounds().Width();
|
.SetInsets(spacing, spacing, spacing, spacing);
|
||||||
|
|
||||||
*_width = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_height != NULL)
|
|
||||||
*_height = fAskBeforeDeleteFileCheckBox->Frame().bottom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ All rights reserved.
|
|||||||
#define _SETTINGS_VIEWS
|
#define _SETTINGS_VIEWS
|
||||||
|
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
|
#include <GroupView.h>
|
||||||
#include <RadioButton.h>
|
#include <RadioButton.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <ColorControl.h>
|
#include <ColorControl.h>
|
||||||
@@ -51,9 +52,9 @@ class BStringView;
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
class SettingsView : public BView {
|
class SettingsView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
SettingsView(BRect frame, const char *name);
|
SettingsView(const char* name);
|
||||||
virtual ~SettingsView();
|
virtual ~SettingsView();
|
||||||
|
|
||||||
virtual void SetDefaults();
|
virtual void SetDefaults();
|
||||||
@@ -64,16 +65,15 @@ class SettingsView : public BView {
|
|||||||
virtual bool IsRevertable() const;
|
virtual bool IsRevertable() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef BView _inherited;
|
typedef BGroupView _inherited;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DesktopSettingsView : public SettingsView {
|
class DesktopSettingsView : public SettingsView {
|
||||||
public:
|
public:
|
||||||
DesktopSettingsView(BRect frame);
|
DesktopSettingsView();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void GetPreferredSize(float *_width, float *_height);
|
|
||||||
|
|
||||||
virtual void SetDefaults();
|
virtual void SetDefaults();
|
||||||
virtual bool IsDefaultable() const;
|
virtual bool IsDefaultable() const;
|
||||||
@@ -102,11 +102,10 @@ class DesktopSettingsView : public SettingsView {
|
|||||||
|
|
||||||
class WindowsSettingsView : public SettingsView {
|
class WindowsSettingsView : public SettingsView {
|
||||||
public:
|
public:
|
||||||
WindowsSettingsView(BRect frame);
|
WindowsSettingsView();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void GetPreferredSize(float *_width, float *_height);
|
|
||||||
|
|
||||||
virtual void SetDefaults();
|
virtual void SetDefaults();
|
||||||
virtual bool IsDefaultable() const;
|
virtual bool IsDefaultable() const;
|
||||||
@@ -134,15 +133,13 @@ class WindowsSettingsView : public SettingsView {
|
|||||||
typedef SettingsView _inherited;
|
typedef SettingsView _inherited;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SpaceBarSettingsView : public SettingsView {
|
class SpaceBarSettingsView : public SettingsView {
|
||||||
public:
|
public:
|
||||||
SpaceBarSettingsView(BRect frame);
|
SpaceBarSettingsView();
|
||||||
virtual ~SpaceBarSettingsView();
|
virtual ~SpaceBarSettingsView();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void GetPreferredSize(float *_width, float *_height);
|
|
||||||
|
|
||||||
virtual void SetDefaults();
|
virtual void SetDefaults();
|
||||||
virtual bool IsDefaultable() const;
|
virtual bool IsDefaultable() const;
|
||||||
@@ -167,11 +164,10 @@ class SpaceBarSettingsView : public SettingsView {
|
|||||||
|
|
||||||
class TrashSettingsView : public SettingsView {
|
class TrashSettingsView : public SettingsView {
|
||||||
public:
|
public:
|
||||||
TrashSettingsView(BRect frame);
|
TrashSettingsView();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void GetPreferredSize(float *_width, float *_height);
|
|
||||||
|
|
||||||
virtual void SetDefaults();
|
virtual void SetDefaults();
|
||||||
virtual bool IsDefaultable() const;
|
virtual bool IsDefaultable() const;
|
||||||
|
|||||||
@@ -33,13 +33,14 @@ All rights reserved.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
|
|
||||||
#include "SettingsViews.h"
|
#include "SettingsViews.h"
|
||||||
#include "TrackerSettings.h"
|
#include "TrackerSettings.h"
|
||||||
#include "TrackerSettingsWindow.h"
|
#include "TrackerSettingsWindow.h"
|
||||||
|
|
||||||
//#include <CheckBox.h>
|
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -73,76 +74,54 @@ TrackerSettingsWindow::TrackerSettingsWindow()
|
|||||||
BWindow(BRect(80, 80, 450, 350), B_TRANSLATE("Tracker preferences"),
|
BWindow(BRect(80, 80, 450, 350), B_TRANSLATE("Tracker preferences"),
|
||||||
B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
|
B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
|
||||||
| B_NO_WORKSPACE_ACTIVATION | B_NOT_ANCHORED_ON_ACTIVATE
|
| 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();
|
fSettingsTypeListView = new BListView("List View", B_SINGLE_SELECTION_LIST);
|
||||||
BView *topView = new BView(rect, "Background", B_FOLLOW_ALL, 0);
|
|
||||||
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
AddChild(topView);
|
|
||||||
|
|
||||||
rect.InsetBy(10, 10);
|
BScrollView* scrollView = new BScrollView("scrollview",
|
||||||
rect.right = be_plain_font->StringWidth(B_TRANSLATE("Volume Icons"))
|
fSettingsTypeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
|
||||||
+ 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);
|
|
||||||
|
|
||||||
rect = scrollView->Frame();
|
fDefaultsButton = new BButton("Defaults", B_TRANSLATE("Defaults"),
|
||||||
rect.left = rect.right + 10;
|
new BMessage(kDefaultsButtonPressed));
|
||||||
rect.top = rect.bottom;
|
|
||||||
fDefaultsButton = new BButton(rect, "Defaults", B_TRANSLATE("Defaults"),
|
|
||||||
new BMessage(kDefaultsButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
|
||||||
fDefaultsButton->ResizeToPreferred();
|
|
||||||
fDefaultsButton->SetEnabled(false);
|
fDefaultsButton->SetEnabled(false);
|
||||||
fDefaultsButton->MoveBy(0, -fDefaultsButton->Bounds().Height());
|
|
||||||
|
|
||||||
rect = fDefaultsButton->Frame();
|
fRevertButton = new BButton("Revert", B_TRANSLATE("Revert"),
|
||||||
rect.left = rect.right + 10;
|
new BMessage(kRevertButtonPressed));
|
||||||
fRevertButton = new BButton(rect, "Revert", B_TRANSLATE("Revert"),
|
|
||||||
new BMessage(kRevertButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
|
||||||
fRevertButton->SetEnabled(false);
|
fRevertButton->SetEnabled(false);
|
||||||
fRevertButton->ResizeToPreferred();
|
|
||||||
|
|
||||||
rect = scrollView->Frame();
|
fSettingsContainerBox = new BBox("SettingsContainerBox");
|
||||||
rect.left = rect.right + 10;
|
|
||||||
rect.right = Bounds().right - 10;
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
rect.bottom = fDefaultsButton->Frame().top - 10;
|
|
||||||
fSettingsContainerBox = new BBox(rect, NULL, B_FOLLOW_ALL);
|
|
||||||
topView->AddChild(fSettingsContainerBox);
|
|
||||||
topView->AddChild(fDefaultsButton);
|
|
||||||
topView->AddChild(fRevertButton);
|
|
||||||
|
|
||||||
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"),
|
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Desktop"),
|
||||||
new DesktopSettingsView(rect)));
|
new DesktopSettingsView()));
|
||||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Windows"),
|
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Windows"),
|
||||||
new WindowsSettingsView(rect)));
|
new WindowsSettingsView()));
|
||||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Trash"),
|
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Trash"),
|
||||||
new TrashSettingsView(rect)));
|
new TrashSettingsView()));
|
||||||
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Volume icons"),
|
fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Volume icons"),
|
||||||
new SpaceBarSettingsView(rect)));
|
new SpaceBarSettingsView()));
|
||||||
|
|
||||||
// compute preferred view size
|
// constraint the listview width so that the longest item fits
|
||||||
|
float width = 0;
|
||||||
float minWidth = 0, minHeight = 0;
|
fSettingsTypeListView->GetPreferredSize(&width, NULL);
|
||||||
|
width += B_V_SCROLL_BAR_WIDTH;
|
||||||
for (int32 i = 0; i < fSettingsTypeListView->CountItems(); i++) {
|
fSettingsTypeListView->SetExplicitMinSize(BSize(width, 0));
|
||||||
SettingsView* view = ((SettingsItem *)fSettingsTypeListView->ItemAt(i))->View();
|
fSettingsTypeListView->SetExplicitMaxSize(BSize(width, B_SIZE_UNLIMITED));
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
fSettingsTypeListView->SetSelectionMessage(new BMessage(kSettingsViewChanged));
|
fSettingsTypeListView->SetSelectionMessage(new BMessage(kSettingsViewChanged));
|
||||||
fSettingsTypeListView->Select(0);
|
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
|
void
|
||||||
TrackerSettingsWindow::_HandleChangedContents()
|
TrackerSettingsWindow::_HandleChangedContents()
|
||||||
{
|
{
|
||||||
@@ -322,10 +288,6 @@ TrackerSettingsWindow::_HandleChangedSettingsView()
|
|||||||
view->Hide();
|
view->Hide();
|
||||||
fSettingsContainerBox->AddChild(view);
|
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();
|
view->Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ class TrackerSettingsWindow : public BWindow {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SettingsView *_ViewAt(int32 i);
|
SettingsView *_ViewAt(int32 i);
|
||||||
BRect _SettingsFrame();
|
|
||||||
|
|
||||||
void _HandleChangedContents();
|
void _HandleChangedContents();
|
||||||
void _HandlePressedDefaultsButton();
|
void _HandlePressedDefaultsButton();
|
||||||
|
|||||||
Reference in New Issue
Block a user