Ticket #5889: tracker.2.patch

File tracker.2.patch, 25.5 KB (added by mt, 14 years ago)

Apply BLayout to TrackerSettingsWindow.

  • VolumeWindow.cpp

     
    8585        }
    8686    }
    8787
    88     BMenuItem* item = fMenuBar->FindItem(B_TRANSLATE("Unmount"));
     88    BMenuItem* item = fMenuBar->FindItem(kUnmountVolume);
    8989    if (item)
    9090        item->SetEnabled(ejectableVolumeSelected);
    9191}
  • SettingsViews.cpp

     
    4444#include <Box.h>
    4545#include <Button.h>
    4646#include <Catalog.h>
     47#include <ControlLook.h>
     48#include <GroupLayoutBuilder.h>
    4749#include <Locale.h>
    4850#include <MenuField.h>
    4951#include <ColorControl.h>
     
    8385#undef B_TRANSLATE_CONTEXT
    8486#define B_TRANSLATE_CONTEXT "libtracker"
    8587
    86 SettingsView::SettingsView(BRect rect, const char *name)
    87     : BView(rect, name, B_FOLLOW_ALL, 0)
     88SettingsView::SettingsView()
     89    : BGroupView()
    8890{
    8991}
    9092
     
    165167// #pragma mark -
    166168
    167169
    168 DesktopSettingsView::DesktopSettingsView(BRect rect)
    169     : SettingsView(rect, "DesktopSettingsView")
     170DesktopSettingsView::DesktopSettingsView()
     171    : SettingsView()
    170172{
    171     rect.OffsetTo(B_ORIGIN);
    172     fShowDisksIconRadioButton = new BRadioButton(rect, "",
     173    fShowDisksIconRadioButton = new BRadioButton("",
    173174        B_TRANSLATE("Show Disks icon"),
    174175        new BMessage(kShowDisksIconChanged));
    175     fShowDisksIconRadioButton->ResizeToPreferred();
    176     AddChild(fShowDisksIconRadioButton);
    177176
    178     const float itemSpacing = fShowDisksIconRadioButton->Bounds().Height() + kItemExtraSpacing;
    179     rect.OffsetBy(0, itemSpacing);
    180 
    181     fMountVolumesOntoDesktopRadioButton = new BRadioButton(rect, "",
     177    fMountVolumesOntoDesktopRadioButton = new BRadioButton("",
    182178        B_TRANSLATE("Show volumes on Desktop"),
    183179        new BMessage(kVolumesOnDesktopChanged));
    184     AddChild(fMountVolumesOntoDesktopRadioButton);
    185     fMountVolumesOntoDesktopRadioButton->ResizeToPreferred();
    186180
    187     rect.OffsetBy(20, itemSpacing);
    188 
    189     fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox(rect, "",
     181    fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox("",
    190182        B_TRANSLATE("Show shared volumes on Desktop"),
    191183        new BMessage(kVolumesOnDesktopChanged));
    192     AddChild(fMountSharedVolumesOntoDesktopCheckBox);
    193     fMountSharedVolumesOntoDesktopCheckBox->ResizeToPreferred();
    194184
    195     rect.OffsetBy(-20, itemSpacing);
    196 
    197     rect = Bounds();
    198     rect.top = rect.bottom;
    199     fMountButton = new BButton(rect, "",
     185    fMountButton = new BButton("",
    200186        B_TRANSLATE("Mount settings" B_UTF8_ELLIPSIS),
    201         new BMessage(kRunAutomounterSettings), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
    202     fMountButton->ResizeToPreferred();
    203     fMountButton->MoveBy(0, -fMountButton->Bounds().Height());
    204     AddChild(fMountButton);
     187        new BMessage(kRunAutomounterSettings));
    205188
    206     fMountButton->SetTarget(be_app);
    207 }
     189    const float spacing = be_control_look->DefaultItemSpacing();
    208190
     191    BGroupLayoutBuilder(this)
     192        .AddGroup(B_VERTICAL)
     193            .Add(fShowDisksIconRadioButton)
     194            .Add(fMountVolumesOntoDesktopRadioButton)
     195            .AddGroup(B_VERTICAL)
     196                .Add(fMountSharedVolumesOntoDesktopCheckBox)
     197                .SetInsets(20, 0, 0, 0)
     198            .End()
     199            .AddGlue()
     200            .AddGroup(B_HORIZONTAL)
     201                .Add(fMountButton)
     202                .AddGlue()
     203            .End()
     204        .End()
     205        .SetInsets(spacing, spacing, spacing, spacing);
    209206
    210 void
    211 DesktopSettingsView::GetPreferredSize(float *_width, float *_height)
    212 {
    213     if (_width != NULL) {
    214         *_width = fMountSharedVolumesOntoDesktopCheckBox->Frame().right;
    215     }
    216 
    217     if (_height != NULL) {
    218         *_height = fMountSharedVolumesOntoDesktopCheckBox->Frame().bottom + 8
    219             + fMountButton->Bounds().Height();
    220     }
     207    fMountButton->SetTarget(be_app);
    221208}
    222209
    223210
     
    414401// #pragma mark -
    415402
    416403
    417 WindowsSettingsView::WindowsSettingsView(BRect rect)
    418     : SettingsView(rect, "WindowsSettingsView")
     404WindowsSettingsView::WindowsSettingsView()
     405    : SettingsView()
    419406{
    420     rect.OffsetTo(B_ORIGIN);
    421     fShowFullPathInTitleBarCheckBox = new BCheckBox(rect, "",
     407    fShowFullPathInTitleBarCheckBox = new BCheckBox("",
    422408        B_TRANSLATE("Show folder location in title tab"),
    423409        new BMessage(kWindowsShowFullPathChanged));
    424     fShowFullPathInTitleBarCheckBox->ResizeToPreferred();
    425     AddChild(fShowFullPathInTitleBarCheckBox);
    426410
    427     const float itemSpacing = fShowFullPathInTitleBarCheckBox->Bounds().Height() + kItemExtraSpacing;
    428     rect.OffsetBy(0, itemSpacing);
    429 
    430     fSingleWindowBrowseCheckBox = new BCheckBox(rect, "",
     411    fSingleWindowBrowseCheckBox = new BCheckBox("",
    431412        B_TRANSLATE("Single window navigation"),
    432413        new BMessage(kSingleWindowBrowseChanged));
    433     fSingleWindowBrowseCheckBox->ResizeToPreferred();
    434     AddChild(fSingleWindowBrowseCheckBox);
    435414
    436     rect.OffsetBy(20, itemSpacing);
    437 
    438     fShowNavigatorCheckBox = new BCheckBox(rect, "",
     415    fShowNavigatorCheckBox = new BCheckBox("",
    439416        B_TRANSLATE("Show navigator"),
    440417        new BMessage(kShowNavigatorChanged));
    441     fShowNavigatorCheckBox->ResizeToPreferred();
    442     AddChild(fShowNavigatorCheckBox);
    443418
    444     rect.OffsetBy(-20, itemSpacing);
    445 
    446     fOutlineSelectionCheckBox = new BCheckBox(rect, "",
     419    fOutlineSelectionCheckBox = new BCheckBox("",
    447420        B_TRANSLATE("Outline selection rectangle only"),
    448421        new BMessage(kTransparentSelectionChanged));
    449     fOutlineSelectionCheckBox->ResizeToPreferred();
    450     AddChild(fOutlineSelectionCheckBox);
    451422
    452     rect.OffsetBy(0, itemSpacing);
    453 
    454     fSortFolderNamesFirstCheckBox = new BCheckBox(rect, "",
     423    fSortFolderNamesFirstCheckBox = new BCheckBox("",
    455424        B_TRANSLATE("List folders first"),
    456425        new BMessage(kSortFolderNamesFirstChanged));
    457     fSortFolderNamesFirstCheckBox->ResizeToPreferred();
    458     AddChild(fSortFolderNamesFirstCheckBox);
    459426
    460     rect.OffsetBy(0, itemSpacing);
    461 
    462     fTypeAheadFilteringCheckBox = new BCheckBox(rect, "",
     427    fTypeAheadFilteringCheckBox = new BCheckBox("",
    463428        B_TRANSLATE("Enable type-ahead filtering"),
    464429        new BMessage(kTypeAheadFilteringChanged));
    465     fTypeAheadFilteringCheckBox->ResizeToPreferred();
    466     AddChild(fTypeAheadFilteringCheckBox);
    467 }
    468430
     431    const float spacing = be_control_look->DefaultItemSpacing();
    469432
    470 void
    471 WindowsSettingsView::GetPreferredSize(float *_width, float *_height)
    472 {
    473     if (_width != NULL)
    474         *_width = fOutlineSelectionCheckBox->Frame().right;
    475 
    476     if (_height != NULL)
    477         *_height = fSortFolderNamesFirstCheckBox->Frame().bottom;
     433    BGroupLayoutBuilder(this)
     434        .AddGroup(B_VERTICAL)
     435            .AddGroup(B_VERTICAL)
     436                .Add(fShowFullPathInTitleBarCheckBox)
     437                .Add(fSingleWindowBrowseCheckBox)
     438            .End()
     439            .AddGroup(B_VERTICAL)
     440                .Add(fShowNavigatorCheckBox)
     441                .SetInsets(20, 0, 0, 0)
     442            .End()
     443            .AddGroup(B_VERTICAL)
     444                .Add(fOutlineSelectionCheckBox)
     445                .Add(fSortFolderNamesFirstCheckBox)
     446                .Add(fTypeAheadFilteringCheckBox)
     447            .End()
     448        .AddGlue()
     449        .End()
     450        .SetInsets(spacing, spacing, spacing, spacing);
    478451}
    479452
    480453
     
    719692// #pragma mark -
    720693
    721694
    722 TimeFormatSettingsView::TimeFormatSettingsView(BRect rect)
    723     : SettingsView(rect, "WindowsSettingsView")
     695TimeFormatSettingsView::TimeFormatSettingsView()
     696    : SettingsView()
    724697{
    725     rect.OffsetTo(B_ORIGIN);
    726698
    727     font_height fontHeight;
    728     be_bold_font->GetHeight(&fontHeight);
    729 
    730     rect.bottom = ceilf(fontHeight.ascent + fontHeight.descent) + 10;
    731     BBox *clockBox = new BBox(rect, "Clock");
     699    BBox* clockBox = new BBox("Clock");
    732700    clockBox->SetLabel(B_TRANSLATE("Clock"));
    733     AddChild(clockBox);
    734701
    735     rect.left = 8;
    736     rect.top = rect.bottom - 8;
    737     f24HrRadioButton = new BRadioButton(rect, "",
     702    f24HrRadioButton = new BRadioButton("",
    738703        B_TRANSLATE("24 hour"),
    739704        new BMessage(kSettingsContentsModified));
    740     f24HrRadioButton->ResizeToPreferred();
    741     clockBox->AddChild(f24HrRadioButton);
    742705
    743     const float itemSpacing = f24HrRadioButton->Bounds().Height() + kItemExtraSpacing;
    744     rect.OffsetBy(0, itemSpacing);
    745 
    746     f12HrRadioButton = new BRadioButton(rect, "",
     706    f12HrRadioButton = new BRadioButton("",
    747707        B_TRANSLATE("12 hour"),
    748708        new BMessage(kSettingsContentsModified));
    749     f12HrRadioButton->ResizeToPreferred();
    750     clockBox->AddChild(f12HrRadioButton);
    751709
    752     float width = max_c(f12HrRadioButton->Frame().right, f24HrRadioButton->Frame().right) + 8.0f;
    753     clockBox->ResizeTo(width, clockBox->Bounds().Height()
    754         + 3 * f12HrRadioButton->Frame().Height());
     710    const float spacing = be_control_look->DefaultItemSpacing();
    755711
    756     rect = clockBox->Frame();
    757     rect.OffsetBy(rect.Width() + 8, 0);
    758     BBox *dateFormatBox = new BBox(rect, "Date order");
     712    BGroupView* view = new BGroupView();
     713    BGroupLayoutBuilder(view)
     714        .AddGroup(B_VERTICAL)
     715        .Add(f24HrRadioButton)
     716        .Add(f12HrRadioButton)
     717        .AddGlue()
     718        .SetInsets(spacing, spacing, spacing, spacing)
     719        .End();
     720
     721    clockBox->AddChild(view);
     722
     723    BBox* dateFormatBox = new BBox("Date order");
    759724    dateFormatBox->SetLabel(B_TRANSLATE("Date order"));
    760     AddChild(dateFormatBox);
    761725
    762     rect = f24HrRadioButton->Frame();
    763     fYMDRadioButton = new BRadioButton(rect, "",
     726    fYMDRadioButton = new BRadioButton("",
    764727        B_TRANSLATE("Year-month-day"),
    765728        new BMessage(kSettingsContentsModified));
    766     fYMDRadioButton->ResizeToPreferred();
    767     dateFormatBox->AddChild(fYMDRadioButton);
    768729
    769     rect.OffsetBy(0, itemSpacing);
    770 
    771     fDMYRadioButton = new BRadioButton(rect, "",
     730    fDMYRadioButton = new BRadioButton("",
    772731        B_TRANSLATE("Day-month-year"),
    773732        new BMessage(kSettingsContentsModified));
    774     fDMYRadioButton->ResizeToPreferred();
    775     dateFormatBox->AddChild(fDMYRadioButton);
    776733
    777     rect.OffsetBy(0, itemSpacing);
    778 
    779     fMDYRadioButton = new BRadioButton(rect, "",
     734    fMDYRadioButton = new BRadioButton("",
    780735        B_TRANSLATE("Month-day-year"),
    781736        new BMessage(kSettingsContentsModified));
    782     fMDYRadioButton->ResizeToPreferred();
    783     dateFormatBox->AddChild(fMDYRadioButton);
    784737
    785     dateFormatBox->ResizeTo(fYMDRadioButton->Bounds().Width() + 16,
    786         dateFormatBox->Bounds().Height());
     738    view = new BGroupView();
     739    BGroupLayoutBuilder(view)
     740        .AddGroup(B_VERTICAL)
     741        .Add(fYMDRadioButton)
     742        .Add(fDMYRadioButton)
     743        .Add(fMDYRadioButton)
     744        .AddGlue()
     745        .SetInsets(spacing, spacing, spacing, spacing)
     746        .End();
    787747
    788     BPopUpMenu *menu = new BPopUpMenu("Separator");
     748    dateFormatBox->AddChild(view);
     749
     750    BPopUpMenu* menu = new BPopUpMenu("Separator");
    789751    menu->AddItem(new BMenuItem(B_TRANSLATE("None"),
    790752        new BMessage(kSettingsContentsModified)));
    791753    menu->AddItem(new BMenuItem(B_TRANSLATE("Space"),
     
    795757    menu->AddItem(new BMenuItem("\\", new BMessage(kSettingsContentsModified)));
    796758    menu->AddItem(new BMenuItem(".", new BMessage(kSettingsContentsModified)));
    797759
    798     rect.left = 0;
    799     rect.top = clockBox->Frame().bottom + 8;
    800     rect.right = Bounds().Width() - 8;
    801     rect.bottom = rect.top + itemSpacing;
    802     fSeparatorMenuField = new BMenuField(rect, "Separator", "Separator:", menu);
    803     fSeparatorMenuField->SetDivider(fSeparatorMenuField->StringWidth(fSeparatorMenuField->Label()) + 8.0f);
     760    fSeparatorMenuField = new BMenuField("Separator", "Separator:", menu);
    804761    fSeparatorMenuField->SetAlignment(B_ALIGN_LEFT);
    805     fSeparatorMenuField->ResizeToPreferred();
    806     AddChild(fSeparatorMenuField);
    807762
    808     rect.OffsetBy(0, itemSpacing + 10);
     763    BStringView* exampleView = new BStringView("", B_TRANSLATE("Examples:"));
    809764
    810     BStringView* exampleView = new BStringView(rect, "", B_TRANSLATE("Examples:"));
    811     exampleView->ResizeToPreferred();
    812     AddChild(exampleView);
     765    fLongDateExampleView = new BStringView("", "");
    813766
    814     rect.OffsetBy(0, itemSpacing);
     767    fShortDateExampleView = new BStringView("", "");
    815768
    816     fLongDateExampleView = new BStringView(rect, "", "");
    817     fLongDateExampleView->ResizeToPreferred();
    818     AddChild(fLongDateExampleView);
     769    BGroupLayoutBuilder(this)
     770        .AddGroup(B_VERTICAL)
     771        .AddGroup(B_HORIZONTAL)
     772            .Add(clockBox)
     773            .Add(dateFormatBox)
     774        .End()
     775        .AddGroup(B_HORIZONTAL)
     776            .Add(fSeparatorMenuField)
     777            .AddGlue()
     778        .End()
     779        .AddGroup(B_HORIZONTAL)
     780            .Add(exampleView)
     781            .AddGlue()
     782        .End()
     783        .AddGroup(B_HORIZONTAL)
     784            .Add(fLongDateExampleView)
     785            .AddGlue()
     786        .End()
     787        .AddGroup(B_HORIZONTAL)
     788            .Add(fShortDateExampleView)
     789            .AddGlue()
     790        .End()
     791        .AddGlue()
     792        .SetInsets(spacing, spacing, spacing, spacing)
     793        .End();
    819794
    820     rect.OffsetBy(0, itemSpacing);
    821 
    822     fShortDateExampleView = new BStringView(rect, "", "");
    823     fShortDateExampleView->ResizeToPreferred();
    824     AddChild(fShortDateExampleView);
    825 
    826795    _UpdateExamples();
    827796}
    828797
    829798
    830799void
    831 TimeFormatSettingsView::GetPreferredSize(float *_width, float *_height)
    832 {
    833     if (_width != NULL) {
    834         BView* view = fMDYRadioButton->Parent();
    835         if (view != NULL)
    836             *_width = view->Frame().right;
    837         else
    838             *_width = Bounds().Width();
    839     }
    840 
    841     if (_height != NULL)
    842         *_height = fShortDateExampleView->Frame().bottom;
    843 }
    844 
    845 
    846 void
    847800TimeFormatSettingsView::AttachedToWindow()
    848801{
    849802    f24HrRadioButton->SetTarget(this);
     
    10701023// #pragma mark -
    10711024
    10721025
    1073 SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
    1074     : SettingsView(rect, "SpaceBarSettingsView")
     1026SpaceBarSettingsView::SpaceBarSettingsView()
     1027    : SettingsView()
    10751028{
    1076     rect.OffsetTo(B_ORIGIN);
    1077     fSpaceBarShowCheckBox = new BCheckBox(rect, "",
     1029    fSpaceBarShowCheckBox = new BCheckBox("",
    10781030        B_TRANSLATE("Show space bars on volumes"),
    10791031        new BMessage(kUpdateVolumeSpaceBar));
    1080     fSpaceBarShowCheckBox->ResizeToPreferred();
    1081     AddChild(fSpaceBarShowCheckBox);
    10821032
    1083     rect = fSpaceBarShowCheckBox->Frame();
    1084     rect.OffsetBy(0, fSpaceBarShowCheckBox->Bounds().Height() + kItemExtraSpacing);
    1085 
    1086     BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING);
     1033    BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING);
    10871034    menu->SetFont(be_plain_font);
    10881035
    1089     BMenuItem *item;
     1036    BMenuItem* item;
    10901037    menu->AddItem(item = new BMenuItem(
    10911038        B_TRANSLATE("Used space color"),
    10921039        new BMessage(kSpaceBarSwitchColor)));
     
    10991046        B_TRANSLATE("Warning space color"),
    11001047        new BMessage(kSpaceBarSwitchColor)));
    11011048
    1102     BBox *box = new BBox(rect);
    1103     box->SetLabel(fColorPicker = new BMenuField(rect, NULL, NULL, menu));
    1104     AddChild(box);
     1049    BBox* box = new BBox("box");
     1050    box->SetLabel(fColorPicker = new BMenuField("menu", NULL, menu));
    11051051
    11061052    fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height()
    11071053            + 8 + kItemExtraSpacing),
    11081054        B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged));
    11091055    fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
    1110     fColorControl->ResizeToPreferred();
    11111056    box->AddChild(fColorControl);
    11121057
    1113     box->ResizeTo(fColorControl->Bounds().Width() + 16,
    1114         fColorControl->Frame().bottom + 8);
    1115 }
     1058    const float spacing = be_control_look->DefaultItemSpacing();
    11161059
     1060    BGroupLayoutBuilder(this)
     1061        .AddGroup(B_VERTICAL)
     1062            .Add(fSpaceBarShowCheckBox)
     1063            .Add(box)
     1064        .AddGlue()
     1065        .End()
     1066        .SetInsets(spacing, spacing, spacing, spacing);
    11171067
    1118 SpaceBarSettingsView::~SpaceBarSettingsView()
    1119 {
    11201068}
    11211069
    11221070
    1123 void
    1124 SpaceBarSettingsView::GetPreferredSize(float *_width, float *_height)
     1071SpaceBarSettingsView::~SpaceBarSettingsView()
    11251072{
    1126     BView* view = fColorControl->Parent();
    1127     if (view == NULL)
    1128         BView::GetPreferredSize(_width, _height);
    1129 
    1130     if (_width != NULL) {
    1131         float width = fSpaceBarShowCheckBox->Bounds().Width();
    1132         if (view->Bounds().Width() > width)
    1133             width = view->Bounds().Width();
    1134 
    1135         *_width = width;
    1136     }
    1137 
    1138     if (_height != NULL)
    1139         *_height = view->Frame().bottom;
    11401073}
    11411074
    11421075
     
    13271260// #pragma mark -
    13281261
    13291262
    1330 TrashSettingsView::TrashSettingsView(BRect rect)
    1331     : SettingsView(rect, "TrashSettingsView")
     1263TrashSettingsView::TrashSettingsView()
     1264    : SettingsView()
    13321265{
    1333     rect.OffsetTo(B_ORIGIN);
    1334     fDontMoveFilesToTrashCheckBox = new BCheckBox(rect, "",
     1266    fDontMoveFilesToTrashCheckBox = new BCheckBox("",
    13351267        B_TRANSLATE("Don't move files to Trash"),
    13361268            new BMessage(kDontMoveFilesToTrashChanged));
    1337     fDontMoveFilesToTrashCheckBox->ResizeToPreferred();
    1338     AddChild(fDontMoveFilesToTrashCheckBox);
    13391269
    1340     rect = fDontMoveFilesToTrashCheckBox->Frame();
    1341     rect.OffsetBy(0, fDontMoveFilesToTrashCheckBox->Bounds().Height() + kItemExtraSpacing);
    1342 
    1343     fAskBeforeDeleteFileCheckBox = new BCheckBox(rect, "",
     1270    fAskBeforeDeleteFileCheckBox = new BCheckBox("",
    13441271        B_TRANSLATE("Ask before delete"),
    13451272            new BMessage(kAskBeforeDeleteFileChanged));
    1346     fAskBeforeDeleteFileCheckBox->ResizeToPreferred();
    1347     AddChild(fAskBeforeDeleteFileCheckBox);
    1348 }
    13491273
     1274    const float spacing = be_control_look->DefaultItemSpacing();
    13501275
    1351 void
    1352 TrashSettingsView::GetPreferredSize(float *_width, float *_height)
    1353 {
    1354     if (_width != NULL) {
    1355         float width = fDontMoveFilesToTrashCheckBox->Bounds().Width();
    1356         if (width < fAskBeforeDeleteFileCheckBox->Bounds().Width())
    1357             width = fAskBeforeDeleteFileCheckBox->Bounds().Width();
     1276    BGroupLayoutBuilder(this)
     1277        .AddGroup(B_VERTICAL)
     1278            .Add(fDontMoveFilesToTrashCheckBox)
     1279            .Add(fAskBeforeDeleteFileCheckBox)
     1280            .AddGlue()
     1281        .End()
     1282        .SetInsets(spacing, spacing, spacing, spacing);
    13581283
    1359         *_width = width;
    1360     }
    1361 
    1362     if (_height != NULL)
    1363         *_height = fAskBeforeDeleteFileCheckBox->Frame().bottom;
    13641284}
    13651285
    13661286
  • TrackerSettingsWindow.cpp

     
    3333*/
    3434
    3535#include <Catalog.h>
     36#include <ControlLook.h>
     37#include <LayoutBuilder.h>
    3638#include <Locale.h>
    3739
    3840#include "SettingsViews.h"
    3941#include "TrackerSettings.h"
    4042#include "TrackerSettingsWindow.h"
    4143
    42 //#include <CheckBox.h>
    4344#include <ScrollView.h>
    4445
    4546
     
    7374    BWindow(BRect(80, 80, 450, 350), B_TRANSLATE("Tracker preferences"),
    7475        B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
    7576        | B_NO_WORKSPACE_ACTIVATION | B_NOT_ANCHORED_ON_ACTIVATE
    76         | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
     77        | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
    7778{
    78     BRect rect = Bounds();
    79     BView *topView = new BView(rect, "Background", B_FOLLOW_ALL, 0);
    80     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    81     AddChild(topView);
     79    fSettingsTypeListView = new BListView("List View", B_SINGLE_SELECTION_LIST);
    8280
    83     rect.InsetBy(10, 10);
    84     rect.right = be_plain_font->StringWidth(B_TRANSLATE("Volume Icons"))
    85         + rect.left + (float)B_V_SCROLL_BAR_WIDTH + 40.0f;
    86     fSettingsTypeListView = new BListView(rect, "List View", B_SINGLE_SELECTION_LIST,
    87         B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM);
     81// TODO: Get width of listview using longest translated label.
     82    float width = be_plain_font->StringWidth(B_TRANSLATE("Volume Icons"))
     83        + (float)B_V_SCROLL_BAR_WIDTH + 40.0f;
     84    fSettingsTypeListView->SetExplicitMinSize(BSize(width, 0));
     85    fSettingsTypeListView->SetExplicitMaxSize(  BSize(width, B_SIZE_UNLIMITED));
     86
    8887    BScrollView* scrollView = new BScrollView("scrollview", fSettingsTypeListView,
    89         B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    90     topView->AddChild(scrollView);
     88    B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    9189
    92     rect = scrollView->Frame();
    93     rect.left = rect.right + 10;
    94     rect.top = rect.bottom;
    95     fDefaultsButton = new BButton(rect, "Defaults", B_TRANSLATE("Defaults"),
    96         new BMessage(kDefaultsButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
    97     fDefaultsButton->ResizeToPreferred();
     90    fDefaultsButton = new BButton("Defaults", B_TRANSLATE("Defaults"),
     91        new BMessage(kDefaultsButtonPressed));
    9892    fDefaultsButton->SetEnabled(false);
    99     fDefaultsButton->MoveBy(0, -fDefaultsButton->Bounds().Height());
    10093
    101     rect = fDefaultsButton->Frame();
    102     rect.left = rect.right + 10;
    103     fRevertButton = new BButton(rect, "Revert", B_TRANSLATE("Revert"),
    104         new BMessage(kRevertButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
     94    fRevertButton = new BButton("Revert", B_TRANSLATE("Revert"),
     95        new BMessage(kRevertButtonPressed));
    10596    fRevertButton->SetEnabled(false);
    106     fRevertButton->ResizeToPreferred();
    10797
    108     rect = scrollView->Frame();
    109     rect.left = rect.right + 10;
    110     rect.right = Bounds().right - 10;
    111     rect.bottom = fDefaultsButton->Frame().top - 10;
    112     fSettingsContainerBox = new BBox(rect, NULL, B_FOLLOW_ALL);
    113     topView->AddChild(fSettingsContainerBox);
    114     topView->AddChild(fDefaultsButton);
    115     topView->AddChild(fRevertButton);
     98    fSettingsContainerBox = new BBox("SettingsContainerBox");
     99   
     100    const float spacing = be_control_look->DefaultItemSpacing();
    116101
    117     rect = _SettingsFrame();
     102    BLayoutBuilder::Group<>(this)
     103        .AddGroup(B_HORIZONTAL, spacing)
     104            .Add(scrollView)
     105            .AddGroup(B_VERTICAL, spacing)
     106                .Add(fSettingsContainerBox)
     107                .AddGroup(B_HORIZONTAL, spacing)
     108                    .Add(fDefaultsButton)
     109                    .Add(fRevertButton)
     110                    .AddGlue()
     111                .End()
     112            .End()
     113        .SetInsets(spacing, spacing, spacing, spacing)
     114        .End();
    118115
    119116    fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Desktop"),
    120         new DesktopSettingsView(rect)));
     117        new DesktopSettingsView()));
    121118    fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Windows"),
    122         new WindowsSettingsView(rect)));
     119        new WindowsSettingsView()));
    123120    fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Date & Time"),
    124         new TimeFormatSettingsView(rect)));
     121        new TimeFormatSettingsView()));
    125122    fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Trash"),
    126         new TrashSettingsView(rect)));
     123        new TrashSettingsView()));
    127124    fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Volume icons"),
    128         new SpaceBarSettingsView(rect)));
     125        new SpaceBarSettingsView()));
    129126
    130     // compute preferred view size
    131 
    132     float minWidth = 0, minHeight = 0;
    133 
    134     for (int32 i = 0; i < fSettingsTypeListView->CountItems(); i++) {
    135         SettingsView* view = ((SettingsItem *)fSettingsTypeListView->ItemAt(i))->View();
    136 
    137         float width, height;
    138         view->GetPreferredSize(&width, &height);
    139 
    140         if (minWidth < width)
    141             minWidth = width;
    142         if (minHeight < height)
    143             minHeight = height;
    144     }
    145 
    146     ResizeBy(max_c(minWidth - rect.Width(), 0), max_c(minHeight - rect.Height(), 0));
    147         // make sure window is large enough to contain all views
    148 
    149127    fSettingsTypeListView->SetSelectionMessage(new BMessage(kSettingsViewChanged));
    150128    fSettingsTypeListView->Select(0);
    151129}
     
    232210}
    233211
    234212
    235 BRect
    236 TrackerSettingsWindow::_SettingsFrame()
    237 {
    238     font_height fontHeight;
    239     be_bold_font->GetHeight(&fontHeight);
    240 
    241     BRect rect = fSettingsContainerBox->Bounds().InsetByCopy(8, 8);
    242     rect.top += ceilf(fontHeight.ascent + fontHeight.descent);
    243 
    244     return rect;
    245 }
    246 
    247 
    248213void
    249214TrackerSettingsWindow::_HandleChangedContents()
    250215{
     
    324289        view->Hide();
    325290        fSettingsContainerBox->AddChild(view);
    326291
    327         // Resize view after it has been attached to the window, so that
    328         // it's resizing modes are respected
    329         BRect rect = _SettingsFrame();
    330         view->ResizeTo(rect.Width(), rect.Height());
    331292        view->Show();
    332293    }
    333294}
  • SettingsViews.h

     
    3636#define _SETTINGS_VIEWS
    3737
    3838#include <CheckBox.h>
     39#include <GroupView.h>
    3940#include <RadioButton.h>
    4041#include <TextControl.h>
    4142#include <ColorControl.h>
     
    5152
    5253namespace BPrivate {
    5354
    54 class SettingsView : public BView {
     55class SettingsView : public BGroupView {
    5556    public:
    56         SettingsView(BRect frame, const char *name);
     57        SettingsView();
    5758        virtual ~SettingsView();
    5859
    5960        virtual void SetDefaults();
     
    6465        virtual bool IsRevertable() const;
    6566
    6667    protected:
    67         typedef BView _inherited;
     68        typedef BGroupView _inherited;
    6869};
    6970
    7071class DesktopSettingsView : public SettingsView {
    7172    public:
    72         DesktopSettingsView(BRect frame);
     73        DesktopSettingsView();
    7374
    7475        virtual void MessageReceived(BMessage *message);
    7576        virtual void AttachedToWindow();
    76         virtual void GetPreferredSize(float *_width, float *_height);
    7777
    7878        virtual void SetDefaults();
    7979        virtual bool IsDefaultable() const;
     
    102102
    103103class WindowsSettingsView : public SettingsView {
    104104    public:
    105         WindowsSettingsView(BRect frame);
     105        WindowsSettingsView();
    106106
    107107        virtual void MessageReceived(BMessage *message);
    108108        virtual void AttachedToWindow();
    109         virtual void GetPreferredSize(float *_width, float *_height);
    110109
    111110        virtual void SetDefaults();
    112111        virtual bool IsDefaultable() const;
     
    136135
    137136class TimeFormatSettingsView : public SettingsView {
    138137    public:
    139         TimeFormatSettingsView(BRect frame);
     138        TimeFormatSettingsView();
    140139
    141140        virtual void MessageReceived(BMessage *message);
    142141        virtual void AttachedToWindow();
    143         virtual void GetPreferredSize(float *_width, float *_height);
    144142
    145143        virtual void SetDefaults();
    146144        virtual bool IsDefaultable() const;
     
    175173
    176174class SpaceBarSettingsView : public SettingsView {
    177175    public:
    178         SpaceBarSettingsView(BRect frame);
     176        SpaceBarSettingsView();
    179177        virtual ~SpaceBarSettingsView();
    180178
    181179        virtual void MessageReceived(BMessage *message);
    182180        virtual void AttachedToWindow();
    183         virtual void GetPreferredSize(float *_width, float *_height);
    184181
    185182        virtual void SetDefaults();
    186183        virtual bool IsDefaultable() const;
     
    205202
    206203class TrashSettingsView : public SettingsView {
    207204    public:
    208         TrashSettingsView(BRect frame);
     205        TrashSettingsView();
    209206
    210207        virtual void MessageReceived(BMessage *message);
    211208        virtual void AttachedToWindow();
    212         virtual void GetPreferredSize(float *_width, float *_height);
    213209
    214210        virtual void SetDefaults();
    215211        virtual bool IsDefaultable() const;
  • ContainerWindow.cpp

     
    21952195    bool poseViewIsQuery = TargetModel()->IsQuery();
    21962196        // if the view is a query pose view, add edit query menu item
    21972197
    2198     BMenuItem* item = menu->FindItem(B_TRANSLATE("Edit query"));
     2198    BMenuItem* item = menu->FindItem(kEditQuery);
    21992199    if (!poseViewIsQuery && !queryInSelection && item)
    22002200        item->Menu()->RemoveItem(item);
    22012201
     
    30243024
    30253025    if (context == kMenuBarContext || context == kWindowPopUpContext) {
    30263026        BMenu* sizeMenu = NULL;
    3027         if (BMenuItem* item = menu->FindItem(B_TRANSLATE("Icon view"))) {
     3027        if (BMenuItem* item = menu->FindItem(kIconMode)) {
    30283028            sizeMenu = item->Submenu();
    30293029        }
    30303030
  • TrackerSettingsWindow.h

     
    5757
    5858    private:
    5959        SettingsView *_ViewAt(int32 i);
    60         BRect _SettingsFrame();
    6160
    6261        void _HandleChangedContents();
    6362        void _HandlePressedDefaultsButton();