Changeset 28708

Show
Ignore:
Timestamp:
11/20/08 19:17:59 (7 weeks ago)
Author:
stippi
Message:

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.

Location:
haiku/trunk/src/preferences/appearance
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/preferences/appearance/APRView.cpp

    r28149 r28708  
    77 *              Rene Gollent (rene@gollent.com) 
    88 */ 
    9 #include <OS.h> 
     9#include "APRView.h" 
     10 
     11#include <Alert.h> 
    1012#include <Directory.h> 
    11 #include <Alert.h> 
    12 #include <Messenger.h> 
    13 #include <storage/Path.h> 
    1413#include <Entry.h> 
    1514#include <File.h> 
     15#include <GroupLayoutBuilder.h> 
     16#include <Messenger.h> 
     17#include <Path.h> 
     18#include <SpaceLayoutItem.h> 
     19 
    1620#include <stdio.h> 
    1721 
    18 #include <InterfaceDefs.h> 
    19  
    20 #include "APRView.h" 
    2122#include "APRWindow.h" 
    2223#include "defs.h" 
     
    3839} 
    3940 
    40 APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags) 
    41  :      BView(frame,name,resize,flags), 
     41APRView::APRView(const char *name, uint32 flags) 
     42 :      BView(name, flags), 
    4243        fDefaultSet(ColorSet::DefaultColorSet()), 
    4344        fDecorMenu(NULL) 
    4445{ 
    4546        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 
    46          
    47         BRect rect(Bounds().InsetByCopy(kBorderSpace,kBorderSpace)); 
    48          
    49         #ifdef HAIKU_TARGET_PLATFORM_HAIKU 
    5047         
    5148        fDecorMenu = new BMenu("Window Style"); 
     
    5855                                continue; 
    5956                        fDecorMenu->AddItem(new BMenuItem(name.String(), 
    60                                                                 new BMessage(DECORATOR_CHANGED))); 
     57                                new BMessage(DECORATOR_CHANGED))); 
    6158                } 
    6259                 
    63                 BMenuField *field = new BMenuField(rect, "menufield", "Window Style", 
    64                                                                                 fDecorMenu, B_FOLLOW_RIGHT |  
    65                                                                                 B_FOLLOW_TOP); 
    66                 AddChild(field); 
    67                 field->SetDivider(be_plain_font->StringWidth("Window style: ") + 5); 
    68                 field->ResizeToPreferred(); 
    69                 field->MoveTo(Bounds().right - field->Bounds().Width(), 10); 
    70                 rect = Bounds().InsetByCopy(10,10); 
    71                 rect.OffsetTo(10, field->Frame().bottom + 10); 
     60                BMenuField *field = new BMenuField("Window Style", fDecorMenu); 
     61                // TODO: use this menu field. 
    7262        } 
    7363        BMenuItem *marked = fDecorMenu->ItemAt(BPrivate::get_decorator()); 
    7464        if (marked) 
    7565                marked->SetMarked(true); 
    76         else 
    77         { 
     66        else { 
    7867                marked = fDecorMenu->FindItem("Default"); 
    7968                if (marked) 
     
    8170        } 
    8271         
    83         #endif 
    84          
    85         // Set up list of color fAttributes 
    86         rect.right -= B_V_SCROLL_BAR_WIDTH; 
    87         rect.bottom = rect.top + 75; 
    88         fAttrList = new BListView(rect,"AttributeList", B_SINGLE_SELECTION_LIST, 
    89                                                         B_FOLLOW_ALL_SIDES); 
    90          
    91         fScrollView = new BScrollView("ScrollView",fAttrList, B_FOLLOW_ALL_SIDES,  
    92                 0, false, true); 
    93         AddChild(fScrollView); 
     72        // Set up list of color attributes 
     73        fAttrList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST); 
     74         
     75        fScrollView = new BScrollView("ScrollView", fAttrList, 0, false, true); 
    9476        fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 
    9577         
    96         fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN)); 
    97  
    9878        for (int32 i = 0; i < color_description_count(); i++) { 
    9979                const ColorDescription& description = *get_color_description(i);  
     
    10282                fAttrList->AddItem(new ColorWhichItem(text, which)); 
    10383        } 
    104          
    105         rect = fScrollView->Frame(); 
     84 
    10685        BRect wellrect(0, 0, 50, 50); 
    107         wellrect.OffsetBy(rect.left, rect.bottom + kBorderSpace); 
    108         fColorWell = new ColorWell(wellrect, new BMessage(COLOR_DROPPED),  
    109                 B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); 
    110         AddChild(fColorWell); 
    111          
    112         fPicker = new BColorControl(BPoint(wellrect.right + kBorderSpace, wellrect.top), 
    113                         B_CELLS_32x8, 8.0, "fPicker", new BMessage(UPDATE_COLOR)); 
    114         fPicker->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); 
    115         AddChild(fPicker);       
    116          
    117         // bottom align ColorWell and ColorPicker 
    118         float bottom = Bounds().bottom - kBorderSpace; 
    119         float colorWellBottom = fColorWell->Frame().bottom; 
    120         float pickerBottom = fPicker->Frame().bottom; 
    121         float delta = bottom - max_c(colorWellBottom, pickerBottom); 
    122         fColorWell->MoveBy(0, delta); 
    123         fPicker->MoveBy(0, delta); 
    124         fScrollView->ResizeBy(0, delta); 
    125         // since this view is not attached to a window yet, 
    126         // we have to resize the fScrollView children too 
    127         fScrollView->ScrollBar(B_VERTICAL)->ResizeBy(0, delta); 
    128         fAttrList->ResizeBy(0, delta); 
     86        fColorWell = new ColorWell(wellrect, new BMessage(COLOR_DROPPED), 0); 
     87        fColorWell->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER, 
     88                B_ALIGN_BOTTOM)); 
     89 
     90        fPicker = new BColorControl(B_ORIGIN, B_CELLS_32x8, 8.0, 
     91                "picker", new BMessage(UPDATE_COLOR)); 
     92 
     93        SetLayout(new BGroupLayout(B_VERTICAL)); 
     94 
     95        // TODO: Make list view and scroller use all the additional height 
     96        // available! 
     97        AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) 
     98                .Add(fScrollView) 
     99                .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) 
     100                .Add(BGroupLayoutBuilder(B_HORIZONTAL) 
     101                        .Add(fColorWell) 
     102                        .Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) 
     103                        .Add(fPicker) 
     104                ) 
     105                .SetInsets(10, 10, 10, 10) 
     106        ); 
     107 
     108        fAttrList->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN)); 
    129109} 
    130110 
  • haiku/trunk/src/preferences/appearance/APRView.h

    r27347 r28708  
    3434{ 
    3535public: 
    36                         APRView(const BRect &frame, const char *name, int32 resize,  
    37                                         int32 flags); 
     36                        APRView(const char *name, uint32 flags); 
    3837                        ~APRView(void); 
    3938        void    AttachedToWindow(void); 
  • haiku/trunk/src/preferences/appearance/APRWindow.cpp

    r27652 r28708  
    66 *              DarkWyrm (darkwyrm@earthlink.net) 
    77 */ 
     8#include "APRWindow.h" 
    89 
    910#include <Button.h> 
     11#include <GroupLayoutBuilder.h> 
    1012#include <Messenger.h> 
     13#include <SpaceLayoutItem.h> 
    1114#include <TabView.h> 
    12 #include "APRWindow.h" 
     15 
    1316#include "APRView.h" 
    1417#include "defs.h" 
     
    1821 
    1922APRWindow::APRWindow(BRect frame) 
    20  :      BWindow(frame, "Appearance", B_TITLED_WINDOW, B_NOT_ZOOMABLE, 
    21                         B_ALL_WORKSPACES) 
     23 :      BWindow(frame, "Appearance", B_TITLED_WINDOW, 
     24                B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, 
     25                B_ALL_WORKSPACES) 
    2226{ 
    23         BRect rect = Bounds(); 
    24         BView* view = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW); 
    25         view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 
    26         AddChild(view); 
     27        SetLayout(new BGroupLayout(B_HORIZONTAL)); 
    2728 
    28         rect.left = 10; 
    29         rect.top = rect.bottom - 10; 
    30         fDefaultsButton = new BButton(rect, "defaults", "Defaults", 
    31                 new BMessage(kMsgSetDefaults), B_FOLLOW_LEFT 
    32                         | B_FOLLOW_BOTTOM, B_WILL_DRAW); 
    33         fDefaultsButton->ResizeToPreferred(); 
    34         fDefaultsButton->SetEnabled(false); 
    35         float buttonHeight = fDefaultsButton->Bounds().Height(); 
    36         fDefaultsButton->MoveBy(0, -buttonHeight); 
    37         view->AddChild(fDefaultsButton); 
     29        fDefaultsButton = new BButton("defaults", "Defaults", 
     30                new BMessage(kMsgSetDefaults), B_WILL_DRAW); 
    3831 
    39         rect = fDefaultsButton->Frame(); 
    40         rect.OffsetBy(fDefaultsButton->Bounds().Width() + 10, 0); 
     32        fRevertButton = new BButton("revert", "Revert", 
     33                new BMessage(kMsgRevert), B_WILL_DRAW); 
    4134 
    42         fRevertButton = new BButton(rect, "revert", "Revert", 
    43                 new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW); 
    44         fRevertButton->ResizeToPreferred(); 
    45         fRevertButton->SetEnabled(false); 
    46         view->AddChild(fRevertButton); 
     35        BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL); 
    4736 
    48         rect = Bounds(); 
    49         rect.top += 5; 
    50         rect.bottom -= 20 + buttonHeight; 
    51         rect.left += 5; 
    52         BTabView *tabView = new BTabView(rect, "tabview", B_WIDTH_FROM_LABEL); 
    53  
    54         rect = tabView->ContainerView()->Bounds().InsetByCopy(5, 8); 
    55  
    56         fAntialiasingSettings = new AntialiasingSettingsView(rect, "Antialiasing"); 
    57         fColorsView = new APRView(rect, "Colors", B_FOLLOW_ALL, B_WILL_DRAW); 
     37        fAntialiasingSettings = new AntialiasingSettingsView("Antialiasing"); 
     38        fColorsView = new APRView("Colors", B_WILL_DRAW); 
    5839 
    5940        tabView->AddTab(fColorsView); 
    6041        tabView->AddTab(fAntialiasingSettings); 
    6142                 
    62         view->AddChild(tabView); 
    63         fColorsView->ResizeToPreferred(); 
    64         fAntialiasingSettings->ResizeToPreferred(); 
    65  
    6643        fDefaultsButton->SetEnabled(fColorsView->IsDefaultable() 
    6744                || fAntialiasingSettings->IsDefaultable()); 
    68         fDefaultsButton->SetTarget(this); 
    69         fRevertButton->SetTarget(this); 
     45        fRevertButton->SetEnabled(false); 
     46 
     47        AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) 
     48                .Add(tabView) 
     49                .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) 
     50                .Add(BGroupLayoutBuilder(B_HORIZONTAL) 
     51                        .Add(fRevertButton) 
     52                        .AddGlue() 
     53                        .Add(fDefaultsButton) 
     54                ) 
     55                .SetInsets(5, 5, 5, 5) 
     56        ); 
    7057} 
    7158 
  • haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.cpp

    r27653 r28708  
    5454 
    5555 
    56 AntialiasingSettingsView::AntialiasingSettingsView(BRect rect, const char* name) 
    57         : BView(rect, name, B_FOLLOW_ALL, B_SUPPORTS_LAYOUT) 
     56AntialiasingSettingsView::AntialiasingSettingsView(const char* name) 
     57        : BView(name, 0) 
    5858{ 
    5959        // collect the current system settings 
     
    142142        _SetCurrentHinting(); 
    143143        _SetCurrentAverageWeight(); 
    144  
    145         // TODO: Remove once these two lines once the entire window uses 
    146         // layout management. 
    147         MoveTo(rect.LeftTop()); 
    148         ResizeTo(rect.Width(), rect.Height()); 
    149144} 
    150145 
  • haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.h

    r27634 r28708  
    1717class AntialiasingSettingsView : public BView { 
    1818public: 
    19                                                         AntialiasingSettingsView(BRect rect, 
    20                                                                 const char* name); 
     19                                                        AntialiasingSettingsView(const char* name); 
    2120        virtual                                 ~AntialiasingSettingsView(); 
    2221