[haiku-commits] r36882 - haiku/trunk/src/preferences/filetypes

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 21 May 2010 12:59:20 +0200 (CEST)

Author: axeld
Date: 2010-05-21 12:59:19 +0200 (Fri, 21 May 2010)
New Revision: 36882
Changeset: http://dev.haiku-os.org/changeset/36882/haiku

Modified:
   haiku/trunk/src/preferences/filetypes/ApplicationTypeWindow.cpp
   haiku/trunk/src/preferences/filetypes/ApplicationTypesWindow.cpp
   haiku/trunk/src/preferences/filetypes/AttributeWindow.cpp
   haiku/trunk/src/preferences/filetypes/ExtensionWindow.cpp
   haiku/trunk/src/preferences/filetypes/FileTypeWindow.cpp
   haiku/trunk/src/preferences/filetypes/FileTypesWindow.cpp
   haiku/trunk/src/preferences/filetypes/NewFileTypeWindow.cpp
   haiku/trunk/src/preferences/filetypes/TypeListWindow.cpp
Log:
* The spacing was hard coded to 3 since r36405 which made the whole thing look
  poorly with the default font size, I wonder why no one noticed that before
  applying.
* This also hid some bugs in the layouting code causing the doubled spacing to
  be used.
* Fixed some weird layout in FileTypeWindow.
* Changed some code to BLayoutBuilder in a few cases.
* Made sure the list views have a better default size, and resize with the
  window.
* Removed superfluous checks if be_control_look is NULL.
* Enlarged the icon size in the main window to 48 pixels.
* I've worked around some strange resizing in the ApplicationTypesWindow by
  setting a max size for the list view. Also, setting a max limit for the
  BStringView on the right side had no effect on layouting (only the text
  was cut).


Modified: haiku/trunk/src/preferences/filetypes/ApplicationTypeWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/filetypes/ApplicationTypeWindow.cpp     
2010-05-21 03:56:31 UTC (rev 36881)
+++ haiku/trunk/src/preferences/filetypes/ApplicationTypeWindow.cpp     
2010-05-21 10:59:19 UTC (rev 36882)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved.
+3 * Copyright 2006-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
@@ -245,13 +245,8 @@
                        B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS),
        fChangedProperties(0)
 {
-       float padding = 3.0f;
-       BAlignment labelAlignment = BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP);
-       if (be_control_look){
-               // padding = be_control_look->DefaultItemSpacing();
-                       // seems too big
-               labelAlignment = be_control_look->DefaultLabelAlignment();
-       }
+       float padding = be_control_look->DefaultItemSpacing();
+       BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();
 
        BMenuBar* menuBar = new BMenuBar((char*)NULL);
        menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
@@ -271,7 +266,6 @@
                new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY));
        menuBar->AddItem(menu);
 
-
        // Signature
 
        fSignatureControl = new BTextControl(B_TRANSLATE("Signature:"), NULL,
@@ -310,7 +304,7 @@
        fBackgroundAppCheckBox = new BCheckBox("background",
                B_TRANSLATE("Background app"), new 
BMessage(kMsgAppFlagsChanged));
 
-       flagsBox->AddChild(BGridLayoutBuilder(padding, padding)
+       flagsBox->AddChild(BGridLayoutBuilder()
                .Add(fSingleLaunchButton, 0, 0).Add(fArgsOnlyCheckBox, 1, 0)
                .Add(fMultipleLaunchButton, 0, 1).Add(fBackgroundAppCheckBox, 
1, 1)
                .Add(fExclusiveLaunchButton, 0, 2)
@@ -323,11 +317,9 @@
        iconBox->SetLabel(B_TRANSLATE("Icon"));
        fIconView = new IconView("icon");
        fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
-       iconBox->AddChild(
-               BGroupLayoutBuilder(B_HORIZONTAL)
+       iconBox->AddChild(BGroupLayoutBuilder(B_HORIZONTAL)
                .Add(fIconView)
-               .SetInsets(padding, padding, padding, padding)
-       );
+               .SetInsets(padding, padding, padding, padding));
 
        // "Supported Types" group
 
@@ -359,9 +351,9 @@
                .SetInsets(padding, padding, padding, padding)
                .SetColumnWeight(0, 3)
                .SetColumnWeight(1, 2)
-               .SetColumnWeight(2, 1)
-       );
-       iconHolder->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, 
B_ALIGN_MIDDLE));
+               .SetColumnWeight(2, 1));
+       iconHolder->SetExplicitAlignment(
+               BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
 
        // "Version Info" group
 
@@ -409,10 +401,10 @@
 
        // TODO: remove workaround (bug #5678)
        BSize minScrollSize = scrollView->ScrollBar(B_VERTICAL)->MinSize();
-       minScrollSize.width+=fLongDescriptionView->MinSize().width;
+       minScrollSize.width += fLongDescriptionView->MinSize().width;
        scrollView->SetExplicitMinSize(minScrollSize);
 
-       versionBox->AddChild(BGridLayoutBuilder(padding, padding)
+       versionBox->AddChild(BGridLayoutBuilder(padding / 2, padding)
                .Add(fMajorVersionControl->CreateLabelLayoutItem(), 0, 0)
                .Add(fMajorVersionControl->CreateTextViewLayoutItem(), 1, 0)
                .Add(fMiddleVersionControl, 2, 0, 2)
@@ -424,8 +416,7 @@
                .Add(longLabel, 0, 2)
                .Add(scrollView, 1, 2, 10, 3)
                .SetInsets(padding, padding, padding, padding)
-               .SetRowWeight(3, 3)
-       );
+               .SetRowWeight(3, 3));
 
        // put it all together
        SetLayout(new BGroupLayout(B_VERTICAL));
@@ -434,12 +425,10 @@
                .Add(fSignatureControl)
                .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
                        .Add(flagsBox, 3)
-                       .Add(iconBox, 1)
-               )
+                       .Add(iconBox, 1))
                .Add(typeBox)
                .Add(versionBox)
-               .SetInsets(padding, padding, padding, padding)
-       );
+               .SetInsets(padding, padding, padding, padding));
 
        SetKeyMenuBar(menuBar);
 

Modified: haiku/trunk/src/preferences/filetypes/ApplicationTypesWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/filetypes/ApplicationTypesWindow.cpp    
2010-05-21 03:56:31 UTC (rev 36881)
+++ haiku/trunk/src/preferences/filetypes/ApplicationTypesWindow.cpp    
2010-05-21 10:59:19 UTC (rev 36882)
@@ -1,9 +1,8 @@
 /*
- * Copyright 2006, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved.
+ * Copyright 2006-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
-// TODO: think about adopting Tracker's info window style here (pressable path)
 
 #include "ApplicationTypesWindow.h"
 #include "FileTypes.h"
@@ -20,6 +19,7 @@
 #include <ControlLook.h>
 #include <GridLayoutBuilder.h>
 #include <GroupLayoutBuilder.h>
+#include <LayoutBuilder.h>
 #include <Locale.h>
 #include <MenuField.h>
 #include <MenuItem.h>
@@ -40,13 +40,17 @@
 #include <stdio.h>
 
 
+// TODO: think about adopting Tracker's info window style here (pressable path)
+
+
 #undef B_TRANSLATE_CONTEXT
 #define B_TRANSLATE_CONTEXT "Application Types Window"
 
 
 class ProgressWindow : public BWindow {
        public:
-               ProgressWindow(const char* message, int32 max, volatile bool* 
signalQuit);
+               ProgressWindow(const char* message, int32 max,
+                       volatile bool* signalQuit);
                virtual ~ProgressWindow();
 
                virtual void MessageReceived(BMessage* message);
@@ -166,23 +170,19 @@
                B_TITLED_WINDOW,
                B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | 
B_AUTO_UPDATE_SIZE_LIMITS)
 {
+       float padding = be_control_look->DefaultItemSpacing();
+       BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();
+       BAlignment fullWidthTopAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP);
 
-       float padding = 3.0f;
-       BAlignment labelAlignment = BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP);
-       BAlignment fullWidthTopAlignment =
-               BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP);
-       if (be_control_look) {
-               // padding = be_control_look->DefaultItemSpacing();
-                       // seems too big
-               labelAlignment = be_control_look->DefaultLabelAlignment();
-       }
-
        // Application list
-       BView* currentView = new BGroupView(B_VERTICAL, padding);
 
        fTypeListView = new MimeTypeListView("listview", "application", true, 
true);
        fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
        fTypeListView->SetInvocationMessage(new BMessage(kMsgTypeInvoked));
+       // TODO: this isn't the perfect solution, but otherwise the window 
contents
+       // will jump chaotically
+       fTypeListView->SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
+       fTypeListView->SetExplicitMaxSize(BSize(250, B_SIZE_UNSET));
 
        BScrollView* scrollView = new BScrollView("scrollview", fTypeListView,
                B_FRAME_EVENTS | B_WILL_DRAW, false, true);
@@ -208,16 +208,14 @@
        fPathView->TextView()->SetExplicitAlignment(labelAlignment);
        fPathView->LabelView()->SetExplicitAlignment(labelAlignment);
 
-       infoBox->AddChild(
-               BGridLayoutBuilder(padding, padding)
-                       .Add(fNameView->LabelView(), 0, 0)
-                       .Add(fNameView->TextView(), 1, 0, 2)
-                       .Add(fSignatureView->LabelView(), 0, 1)
-                       .Add(fSignatureView->TextView(), 1, 1, 2)
-                       .Add(fPathView->LabelView(), 0, 2)
-                       .Add(fPathView->TextView(), 1, 2, 2)
-                       .SetInsets(padding, padding, padding, padding)
-       );
+       infoBox->AddChild(BGridLayoutBuilder(padding, padding)
+               .Add(fNameView->LabelView(), 0, 0)
+               .Add(fNameView->TextView(), 1, 0, 2)
+               .Add(fSignatureView->LabelView(), 0, 1)
+               .Add(fSignatureView->TextView(), 1, 1, 2)
+               .Add(fPathView->LabelView(), 0, 2)
+               .Add(fPathView->TextView(), 1, 2, 2)
+               .SetInsets(padding, padding, padding, padding));
 
        // "Version" group
 
@@ -235,15 +233,12 @@
        fDescriptionView->SetLowColor(fDescriptionView->ViewColor());
        fDescriptionView->MakeEditable(false);
 
-       versionBox->AddChild(currentView =
-               BGridLayoutBuilder(padding, padding)
-                       .Add(fVersionView->LabelView(), 0, 0)
-                       .Add(fVersionView->TextView(), 1, 0)
-                       .Add(fDescriptionLabel->LabelView(), 0, 1)
-                       .Add(fDescriptionView, 1, 1, 2, 2)
-                       .SetInsets(padding, padding, padding, padding)
-       );
-       currentView->SetExplicitAlignment(fullWidthTopAlignment);
+       versionBox->AddChild(BGridLayoutBuilder(padding, padding)
+               .Add(fVersionView->LabelView(), 0, 0)
+               .Add(fVersionView->TextView(), 1, 0)
+               .Add(fDescriptionLabel->LabelView(), 0, 1)
+               .Add(fDescriptionView, 1, 1, 2, 2)
+               .SetInsets(padding, padding, padding, padding));
 
        // Launch and Tracker buttons
 
@@ -254,25 +249,27 @@
        fTrackerButton = new BButton(
                B_TRANSLATE("Show in Tracker" B_UTF8_ELLIPSIS));
 
-       AddChild(BGroupLayoutBuilder(B_HORIZONTAL, padding)
-               .Add(BGroupLayoutBuilder(B_VERTICAL, padding)
+       AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, padding)
+               .AddGroup(B_VERTICAL, padding, 3)
                        .Add(scrollView)
-                       .Add(button)
-                       .SetInsets(padding, padding, padding, padding)
-               , 3)
-               .Add(BGroupLayoutBuilder(B_VERTICAL, padding)
+                       .AddGroup(B_HORIZONTAL)
+                               .Add(button)
+                               .AddGlue()
+                               .End()
+                       .End()
+//                     .AddGlue())//, 3)
+               .AddGroup(B_VERTICAL, padding)
                        .Add(infoBox)
                        .Add(versionBox)
-                       .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
+                       .AddGroup(B_HORIZONTAL, padding)
+                               .AddGlue()
                                .Add(fEditButton)
                                .Add(fLaunchButton)
                                .Add(fTrackerButton)
-                       )
+                               .End()
                        .AddGlue()
-                       .SetInsets(padding, padding, padding, padding)
-               )
-               .SetInsets(padding, padding, padding, padding)
-       );
+                       .End()
+               .SetInsets(padding, padding, padding, padding));
 
        BMimeType::StartWatching(this);
        _SetType(NULL);

Modified: haiku/trunk/src/preferences/filetypes/AttributeWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/filetypes/AttributeWindow.cpp   2010-05-21 
03:56:31 UTC (rev 36881)
+++ haiku/trunk/src/preferences/filetypes/AttributeWindow.cpp   2010-05-21 
10:59:19 UTC (rev 36882)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2007, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights 
reserved.
+ * Copyright 2006-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
@@ -102,9 +102,7 @@
        fTarget(target),
        fMimeType(mimeType.Type())
 {
-       float padding = 3.0f;
-       //if (be_control_look)
-               //padding = be_control_look->DefaultItemSpacing();
+       float padding = be_control_look->DefaultItemSpacing();
 
        if (attributeItem != NULL)
                fAttribute = *attributeItem;
@@ -162,7 +160,8 @@
                item = new BMenuItem(kDisplayAsMap[i].name, message);
                menu->AddItem(item);
 
-               if (compare_display_as(kDisplayAsMap[i].identifier, 
fAttribute.DisplayAs()))
+               if (compare_display_as(kDisplayAsMap[i].identifier,
+                               fAttribute.DisplayAs()))
                        item->SetMarked(true);
        }
 
@@ -230,8 +229,8 @@
                B_TRANSLATE("Alignment:"), menu);
        fAlignmentMenuField->SetAlignment(B_ALIGN_RIGHT);
 
-       fAcceptButton = new BButton("add", item
-               ? B_TRANSLATE("Done") : B_TRANSLATE("Add"),
+       fAcceptButton = new BButton("add",
+               item ? B_TRANSLATE("Done") : B_TRANSLATE("Add"),
                new BMessage(kMsgAccept));
        fAcceptButton->SetEnabled(false);
 
@@ -242,16 +241,15 @@
        SetLayout(new BGroupLayout(B_VERTICAL));
        AddChild(BGroupLayoutBuilder(B_VERTICAL, padding)
                .SetInsets(padding, padding, padding, padding)
-               .Add(BGridLayoutBuilder(padding, padding)
+               .Add(BGridLayoutBuilder(padding, padding / 2)
                        .Add(fPublicNameControl->CreateLabelLayoutItem(), 0, 0)
                        .Add(fPublicNameControl->CreateTextViewLayoutItem(), 1, 
0)
                        .Add(fAttributeControl->CreateLabelLayoutItem(), 0, 1)
                        .Add(fAttributeControl->CreateTextViewLayoutItem(), 1, 
1)
                        .Add(typeMenuField->CreateLabelLayoutItem(), 0, 2)
-                       .Add(typeMenuField->CreateMenuBarLayoutItem(), 1, 2)
-               )
+                       .Add(typeMenuField->CreateMenuBarLayoutItem(), 1, 2))
                .Add(visibleBox = new BBox(B_FANCY_BORDER,
-                       BGridLayoutBuilder(padding, padding)
+                       BGridLayoutBuilder(padding, padding / 2)
                                
.Add(fDisplayAsMenuField->CreateLabelLayoutItem(), 0, 0)
                                
.Add(fDisplayAsMenuField->CreateMenuBarLayoutItem(), 1, 0)
                                .Add(fEditableCheckBox, 3, 0)
@@ -261,15 +259,12 @@
                                .Add(fWidthControl->CreateTextViewLayoutItem(), 
1, 2, 3)
                                
.Add(fAlignmentMenuField->CreateLabelLayoutItem(), 0, 3)
                                
.Add(fAlignmentMenuField->CreateMenuBarLayoutItem(), 1, 3, 3)
-                               .SetInsets(padding, padding, padding, padding)
-                       ))
+                               .SetInsets(padding, padding, padding, padding)))
                .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
                        .Add(BSpaceLayoutItem::CreateGlue())
                        .Add(BSpaceLayoutItem::CreateGlue())
                        .Add(cancelButton)
-                       .Add(fAcceptButton)
-               )
-       );
+                       .Add(fAcceptButton)));
        visibleBox->SetLabel(fVisibleCheckBox);
 
        fAcceptButton->MakeDefault(true);

Modified: haiku/trunk/src/preferences/filetypes/ExtensionWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/filetypes/ExtensionWindow.cpp   2010-05-21 
03:56:31 UTC (rev 36881)
+++ haiku/trunk/src/preferences/filetypes/ExtensionWindow.cpp   2010-05-21 
10:59:19 UTC (rev 36882)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved.
+ * Copyright 2006-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
@@ -122,10 +122,7 @@
 {
        SetLayout(new BGroupLayout(B_VERTICAL));
 
-       float padding = 3.0f;
-       //if (be_control_look)
-               // padding = be_control_look->DefaultItemSpacing();
-                       // this seems to be very large!
+       float padding = be_control_look->DefaultItemSpacing();
 
        fExtensionControl = new BTextControl(B_TRANSLATE("Extension:"),
                extension, NULL);

Modified: haiku/trunk/src/preferences/filetypes/FileTypeWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/filetypes/FileTypeWindow.cpp    2010-05-21 
03:56:31 UTC (rev 36881)
+++ haiku/trunk/src/preferences/filetypes/FileTypeWindow.cpp    2010-05-21 
10:59:19 UTC (rev 36882)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved.
+ * Copyright 2006-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
@@ -19,6 +19,7 @@
 #include <File.h>
 #include <GridLayoutBuilder.h>
 #include <GroupLayoutBuilder.h>
+#include <LayoutBuilder.h>
 #include <Locale.h>
 #include <MenuField.h>
 #include <MenuItem.h>
@@ -55,10 +56,7 @@
                B_NOT_V_RESIZABLE | B_NOT_ZOOMABLE
                        | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
 {
-       float padding = 3.0f;
-       // if (be_control_look)
-               // padding = be_control_look->DefaultItemSpacing();
-                       // too big!
+       float padding = be_control_look->DefaultItemSpacing();
 
        // "File Type" group
        BBox* fileTypeBox = new BBox("file type BBox");
@@ -84,8 +82,7 @@
                .Add(fTypeControl, 0, 0, 2, 1)
                .Add(fSelectTypeButton, 0, 1)
                .Add(fSameTypeAsButton, 1, 1)
-               .SetInsets(padding, padding, padding, padding)
-       );
+               .SetInsets(padding, padding, padding, padding));
 
        // "Icon" group
 
@@ -121,17 +118,15 @@
                .Add(fPreferredField, 0, 0, 2, 1)
                .Add(fSelectAppButton, 0, 1)
                .Add(fSameAppAsButton, 1, 1)
-               .Add(BSpaceLayoutItem::CreateGlue(), 3, 0, 1, 2)
-               .SetInsets(padding, padding, padding, padding)
-       );
+               .SetInsets(padding, padding, padding, padding));
 
-       SetLayout(new BGroupLayout(B_VERTICAL));
-       AddChild(BGridLayoutBuilder(padding, padding)
-               .Add(fileTypeBox, 0, 0, 1, 2)
-               .Add(iconBox, 1, 1, 1, 2)
-               .Add(preferredBox, 0, 2, 1, 2)
+       BLayoutBuilder::Group<>(this, B_HORIZONTAL, padding)
+               .AddGroup(B_VERTICAL, padding)
+                       .Add(fileTypeBox)
+                       .Add(preferredBox)
+                       .End()
                .SetInsets(padding, padding, padding, padding)
-       );
+               .Add(iconBox);
 
        fTypeControl->MakeFocus(true);
        BMimeType::StartWatching(this);

Modified: haiku/trunk/src/preferences/filetypes/FileTypesWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/filetypes/FileTypesWindow.cpp   2010-05-21 
03:56:31 UTC (rev 36881)
+++ haiku/trunk/src/preferences/filetypes/FileTypesWindow.cpp   2010-05-21 
10:59:19 UTC (rev 36882)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved.
+ * Copyright 2006-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
@@ -117,6 +117,7 @@
        : IconView(name)
 {
        ShowEmptyFrame(false);
+       SetIconSize(48);
 }
 
 
@@ -150,7 +151,8 @@
                        return;
        }
 
-       SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), 
B_DISABLED_LABEL_TINT));
+       SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
+               B_DISABLED_LABEL_TINT));
        SetLowColor(ViewColor());
 
        font_height fontHeight;
@@ -218,7 +220,8 @@
 
 ExtensionListView::ExtensionListView(const char* name,
                list_view_type type, uint32 flags)
-       : DropTargetListView(name, type, flags)
+       :
+       DropTargetListView(name, type, flags)
 {
 }
 
@@ -235,7 +238,8 @@
                // create extension list
                BList list;
                entry_ref ref;
-               for (int32 index = 0; message->FindRef("refs", index++, &ref) 
== B_OK; ) {
+               for (int32 index = 0; message->FindRef("refs", index, &ref) == 
B_OK;
+                               index++) {
                        const char* point = strchr(ref.name, '.');
                        if (point != NULL && point[1])
                                list.AddItem(strdup(++point));
@@ -261,7 +265,8 @@
        int32 count = 0;
        entry_ref ref;
 
-       for (int32 index = 0; message->FindRef("refs", index++, &ref) == B_OK; 
) {
+       for (int32 index = 0; message->FindRef("refs", index, &ref) == B_OK;
+                       index++) {
                const char* point = strchr(ref.name, '.');
                if (point != NULL && point[1])
                        count++;
@@ -298,25 +303,20 @@
                showRule = false;
 
        SetLayout(new BGroupLayout(B_VERTICAL));
-       float padding = 3.0f;
-       BAlignment labelAlignment = BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP);
-       if (be_control_look) {
-               // padding = be_control_look->DefaultItemSpacing();
-                       // this seems to be very large!
-               labelAlignment = be_control_look->DefaultLabelAlignment();
-       }
-       BAlignment fullAlignment =
-               BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
 
+       float padding = be_control_look->DefaultItemSpacing();
+       BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();
+       BAlignment fullAlignment(B_ALIGN_USE_FULL_WIDTH, 
B_ALIGN_USE_FULL_HEIGHT);
+
        // add the menu
        BMenuBar* menuBar = new BMenuBar("");
 
        BMenu* menu = new BMenu(B_TRANSLATE("File"));
-       BMenuItem* item;
-       menu->AddItem(item = new BMenuItem(
-               B_TRANSLATE("New resource file" B_UTF8_ELLIPSIS),
-               NULL, 'N', B_COMMAND_KEY));
+       BMenuItem* item = new BMenuItem(
+               B_TRANSLATE("New resource file" B_UTF8_ELLIPSIS), NULL, 'N',
+               B_COMMAND_KEY);
        item->SetEnabled(false);
+       menu->AddItem(item);
 
        BMenu* recentsMenu = BRecentFilesList::NewFileListMenu(
                B_TRANSLATE("Open" B_UTF8_ELLIPSIS), NULL, NULL,
@@ -365,6 +365,7 @@
 
        fTypeListView = new MimeTypeListView("typeview", NULL, showIcons, 
false);
        fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
+       fTypeListView->SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
 
        BScrollView* typeListScrollView = new BScrollView("scrollview",
                fTypeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
@@ -378,8 +379,7 @@
                .Add(BSpaceLayoutItem::CreateGlue(), 1)
                .Add(fIconView, 3)
                .Add(BSpaceLayoutItem::CreateGlue(), 1)
-               .SetInsets(padding, padding, padding, padding)
-       );
+               .SetInsets(padding, padding, padding, padding));
 
        // "File Recognition" group
 
@@ -392,6 +392,8 @@
 
        fAddExtensionButton = new BButton("add ext",
                B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new 
BMessage(kMsgAddExtension));
+       fAddExtensionButton->SetExplicitMaxSize(
+               BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
 
        fRemoveExtensionButton = new BButton("remove ext", 
B_TRANSLATE("Remove"),
                new BMessage(kMsgRemoveExtension));
@@ -411,14 +413,13 @@
        fRuleControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
        fRuleControl->Hide();
 
-       BView* recognitionBoxGrid =
-               BGridLayoutBuilder(padding, padding)
-                       .Add(fExtensionLabel->LabelView(), 0, 0)
-                       .Add(scrollView, 0, 1, 2, 3)
-                       .Add(fAddExtensionButton, 2, 1)
-                       .Add(fRemoveExtensionButton, 2, 2)
-                       .Add(fRuleControl, 0, 4, 3, 1)
-                       .SetInsets(padding, padding, padding, padding);
+       BView* recognitionBoxGrid = BGridLayoutBuilder(padding, padding / 2)
+               .Add(fExtensionLabel->LabelView(), 0, 0)
+               .Add(scrollView, 0, 1, 2, 3)
+               .Add(fAddExtensionButton, 2, 1)
+               .Add(fRemoveExtensionButton, 2, 2)
+               .Add(fRuleControl, 0, 4, 3, 1)
+               .SetInsets(padding, padding, padding, padding);
 
        recognitionBoxGrid->SetExplicitAlignment(fullAlignment);
        fRecognitionBox->AddChild(recognitionBoxGrid);
@@ -436,17 +437,15 @@
        fDescriptionControl = new BTextControl("description",
                B_TRANSLATE("Description:"), "", new 
BMessage(kMsgDescriptionEntered));
 
-       fDescriptionBox->AddChild(BGridLayoutBuilder(padding, padding)
+       fDescriptionBox->AddChild(BGridLayoutBuilder(padding / 2, padding / 2)
                .Add(fInternalNameView->LabelView(), 0, 0)
                .Add(fInternalNameView->TextView(), 1, 0)
                .Add(fTypeNameControl->CreateLabelLayoutItem(), 0, 1)
                .Add(fTypeNameControl->CreateTextViewLayoutItem(), 1, 1, 2)
                .Add(fDescriptionControl->CreateLabelLayoutItem(), 0, 2)
                .Add(fDescriptionControl->CreateTextViewLayoutItem(), 1, 2, 2)
-               .SetInsets(padding, padding, padding, padding)
-       );
+               .SetInsets(padding, padding, padding, padding));
 
-
        // "Preferred Application" group
 
        fPreferredBox = new BBox("preferred BBox");
@@ -466,20 +465,21 @@
                B_TRANSLATE("Same as" B_UTF8_ELLIPSIS),
                new BMessage(kMsgSamePreferredAppAs));
 
-       fPreferredBox->AddChild(
-               BGroupLayoutBuilder(B_HORIZONTAL, padding)
-                       .Add(fPreferredField)
-                       .Add(fSelectButton)
-                       .Add(fSameAsButton)
-                       .SetInsets(padding, padding, padding, padding)
-       );
+       fPreferredBox->AddChild(BGroupLayoutBuilder(B_HORIZONTAL, padding)
+               .Add(fPreferredField)
+               .Add(fSelectButton)
+               .Add(fSameAsButton)
+               .SetInsets(padding, padding, padding, padding));
 
        // "Extra Attributes" group
+
        fAttributeBox = new BBox("Attribute Box");
        fAttributeBox->SetLabel(B_TRANSLATE("Extra attributes"));
 
        fAddAttributeButton = new BButton("add attr",
                "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddAttribute));
+       fAddAttributeButton->SetExplicitMaxSize(
+               BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
 
        fRemoveAttributeButton = new BButton("remove attr", 
B_TRANSLATE("Remove"),
                new BMessage(kMsgRemoveAttribute));
@@ -493,32 +493,27 @@
        BScrollView* attributesScroller = new BScrollView("scrollview attr",
                fAttributeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
 
-       fAttributeBox->AddChild(BGridLayoutBuilder(padding, padding)
+       fAttributeBox->AddChild(BGridLayoutBuilder(padding, padding / 2)
                .Add(attributesScroller, 0, 0, 2, 3)
                .Add(fAddAttributeButton, 2, 0)
                .Add(fRemoveAttributeButton, 2, 1)
-               .SetInsets(padding, padding, padding, padding)
-       );
+               .SetInsets(padding, padding, padding, padding));
 
-
-       BView* topView =
-               BGroupLayoutBuilder(B_HORIZONTAL, padding)
+       BView* topView = BGroupLayoutBuilder(B_HORIZONTAL, padding)
                .SetInsets(padding, padding, padding, padding)
                .Add(BGroupLayoutBuilder(B_VERTICAL, padding)
                        .Add(typeListScrollView)
                        .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
-                               .Add(addTypeButton).Add(fRemoveTypeButton)
-                       )
-               )
+                               .Add(addTypeButton)
+                               .Add(fRemoveTypeButton)
+                               .AddGlue()))
                // Right side
                .Add(BGroupLayoutBuilder(B_VERTICAL, padding)
                        .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
-                               .Add(fIconBox, 1).Add(fRecognitionBox, 3)
-                       )
+                               .Add(fIconBox, 1).Add(fRecognitionBox, 3))
                        .Add(fDescriptionBox)
                        .Add(fPreferredBox)
-                       .Add(fAttributeBox, 5)
-               );
+                       .Add(fAttributeBox, 5));
 
        //topView->SetExplicitAlignment(fullAlignment);
        //topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

Modified: haiku/trunk/src/preferences/filetypes/NewFileTypeWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/filetypes/NewFileTypeWindow.cpp 2010-05-21 
03:56:31 UTC (rev 36881)
+++ haiku/trunk/src/preferences/filetypes/NewFileTypeWindow.cpp 2010-05-21 
10:59:19 UTC (rev 36882)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved.
+ * Copyright 2006-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
@@ -92,9 +92,7 @@
        fAddButton = new BButton(B_TRANSLATE("Add type"),
                new BMessage(kMsgAddType));
 
-       float padding = 3.0f;
-       // if (be_control_look)
-               // padding = be_control_look->DefaultItemSpacing();
+       float padding = be_control_look->DefaultItemSpacing();
 
        SetLayout(new BGroupLayout(B_VERTICAL));
        AddChild(BGridLayoutBuilder(padding, padding)
@@ -107,8 +105,7 @@
                .Add(new BButton(B_TRANSLATE("Cancel"),
                        new BMessage(B_QUIT_REQUESTED)), 1, 2)
                .Add(fAddButton, 2, 2)
-               .SetColumnWeight(0, 3)
-               );
+               .SetColumnWeight(0, 3));
 
        BAlignment fullSize = BAlignment(B_ALIGN_USE_FULL_WIDTH,
                B_ALIGN_USE_FULL_HEIGHT);

Modified: haiku/trunk/src/preferences/filetypes/TypeListWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/filetypes/TypeListWindow.cpp    2010-05-21 
03:56:31 UTC (rev 36881)
+++ haiku/trunk/src/preferences/filetypes/TypeListWindow.cpp    2010-05-21 
10:59:19 UTC (rev 36882)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved.
+ * Copyright 2006-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
@@ -25,8 +25,8 @@
 const uint32 kMsgSelected = 'seld';
 
 
-TypeListWindow::TypeListWindow(const char* currentType,
-       uint32 what, BWindow* target)
+TypeListWindow::TypeListWindow(const char* currentType, uint32 what,
+               BWindow* target)
        :
        BWindow(BRect(100, 100, 360, 440), B_TRANSLATE("Choose type"),
                B_MODAL_WINDOW,
@@ -34,10 +34,7 @@
        fTarget(target),
        fWhat(what)
 {
-       float padding = 3.0f;
-       //if (be_control_look)
-               // padding = be_control_look->DefaultItemSpacing();
-               // seems too big
+       float padding = be_control_look->DefaultItemSpacing();
 
        fSelectButton = new BButton("select", B_TRANSLATE("Done"),
                new BMessage(kMsgSelected));


Other related posts: