preferences/bluetooth: Use BLayoutBuilder instead of B*LayoutBuilder.

Fixes a bunch of window sizing issues and the weird space between
the window border and the contents.
This commit is contained in:
Augustin Cavalier 2016-05-05 18:09:16 -04:00
parent c9dba74273
commit deaef0eb2e
6 changed files with 64 additions and 95 deletions

View File

@ -11,7 +11,7 @@
#include <Bitmap.h>
#include <Catalog.h>
#include <GroupLayoutBuilder.h>
#include <LayoutBuilder.h>
#include <Locale.h>
#include <SpaceLayoutItem.h>
#include <StringView.h>
@ -21,17 +21,11 @@
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Device View"
BluetoothDeviceView::BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice,
uint32 resizingMode, uint32 flags)
BluetoothDeviceView::BluetoothDeviceView(BluetoothDevice* bDevice, uint32 flags)
:
BView(frame,"BluetoothDeviceView", resizingMode, flags | B_WILL_DRAW),
BView("BluetoothDeviceView", flags | B_WILL_DRAW),
fDevice(bDevice)
{
SetViewColor(B_TRANSPARENT_COLOR);
SetLowColor(0, 0, 0);
SetLayout(new BGroupLayout(B_VERTICAL));
fName = new BStringView("name", "");
fName->SetFont(be_bold_font);
fName->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
@ -64,40 +58,38 @@ BluetoothDeviceView::BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice,
fSCOBuffersProperties->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
B_ALIGN_MIDDLE));
fIcon = new BView(BRect(0, 0, 32 - 1, 32 - 1), "Icon", B_FOLLOW_ALL,
B_WILL_DRAW);
fIcon->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
SetBluetoothDevice(bDevice);
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 5)
.Add(fIcon)
.AddGlue()
.Add(BGroupLayoutBuilder(B_VERTICAL)
.Add(fName)
.AddGlue()
.Add(fBdaddr)
.AddGlue()
.Add(fClass)
.AddGlue()
.Add(fClassService)
.AddGlue()
.AddGlue()
.Add(fHCIVersionProperties)
.AddGlue()
.Add(fLMPVersionProperties)
.AddGlue()
.Add(fManufacturerProperties)
.AddGlue()
.Add(fACLBuffersProperties)
.AddGlue()
.Add(fSCOBuffersProperties)
.SetInsets(5, 5, 5, 5)
)
// .Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
.SetInsets(10, 10, 10, 10)
);
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 5)
.SetInsets(10)
.Add(fIcon)
.AddGlue()
.AddGroup(B_VERTICAL, 0)
.SetInsets(5)
.Add(fName)
.AddGlue()
.Add(fBdaddr)
.AddGlue()
.Add(fClass)
.AddGlue()
.Add(fClassService)
.AddGlue()
.Add(fHCIVersionProperties)
.AddGlue()
.Add(fLMPVersionProperties)
.AddGlue()
.Add(fManufacturerProperties)
.AddGlue()
.Add(fACLBuffersProperties)
.AddGlue()
.Add(fSCOBuffersProperties)
.End()
//.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
.End();
}

View File

@ -20,8 +20,7 @@ class BitmapView;
class BluetoothDeviceView : public BView
{
public:
BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
BluetoothDeviceView(BluetoothDevice* bDevice,
uint32 flags = B_WILL_DRAW);
~BluetoothDeviceView(void);

View File

@ -16,8 +16,7 @@
#include <Box.h>
#include <Catalog.h>
#include <GridLayoutBuilder.h>
#include <GroupLayoutBuilder.h>
#include <LayoutBuilder.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
@ -95,27 +94,21 @@ BluetoothSettingsView::BluetoothSettingsView(const char* name)
fClassMenuField = new BMenuField("class", B_TRANSLATE("Identify host as:"),
fClassMenu);
// controls pane
AddChild(BGridLayoutBuilder(10, 10)
BLayoutBuilder::Grid<>(this, 0)
.SetInsets(10)
.Add(fClassMenuField->CreateLabelLayoutItem(), 0, 0)
.Add(fClassMenuField->CreateMenuBarLayoutItem(), 1, 0)
.Add(fPolicyMenuField->CreateLabelLayoutItem(), 0, 1)
.Add(fPolicyMenuField->CreateMenuBarLayoutItem(), 1, 1)
.Add(BSpaceLayoutItem::CreateGlue(), 0, 2, 2)
.Add(fInquiryTimeControl, 0, 3, 2)
.Add(BSpaceLayoutItem::CreateGlue(), 0, 4, 2)
.Add(fInquiryTimeControl, 0, 2, 2)
.Add(fLocalDevicesMenuField->CreateLabelLayoutItem(), 0, 5)
.Add(fLocalDevicesMenuField->CreateMenuBarLayoutItem(), 1, 5)
.Add(fExtDeviceView, 0, 6, 2)
.Add(BSpaceLayoutItem::CreateGlue(), 0, 7, 2)
.SetInsets(10, 10, 10, 10)
);
.End();
}

View File

@ -39,8 +39,6 @@ BluetoothWindow::BluetoothWindow(BRect frame)
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Bluetooth"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
SetLayout(new BGroupLayout(B_HORIZONTAL));
fDefaultsButton = new BButton("defaults", B_TRANSLATE("Defaults"),
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
@ -93,16 +91,16 @@ BluetoothWindow::BluetoothWindow(BRect frame)
fRevertButton->SetEnabled(false);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(0)
.Add(fMenubar)
.AddStrut(B_USE_DEFAULT_SPACING)
.AddStrut(B_USE_HALF_ITEM_SPACING)
.Add(tabView)
.AddStrut(B_USE_DEFAULT_SPACING)
.AddGroup(B_HORIZONTAL, 0)
.Add(fRevertButton)
.AddGroup(B_HORIZONTAL, B_USE_HALF_ITEM_SPACING)
.AddGlue()
.Add(fDefaultsButton)
.End()
.SetInsets(B_USE_WINDOW_SPACING);
.Add(fRevertButton)
.End()
.End();
}

View File

@ -11,7 +11,7 @@
#include <Bitmap.h>
#include <Catalog.h>
#include <CheckBox.h>
#include <GroupLayoutBuilder.h>
#include <LayoutBuilder.h>
#include <SpaceLayoutItem.h>
#include <StringView.h>
@ -26,35 +26,28 @@ ExtendedLocalDeviceView::ExtendedLocalDeviceView(BRect frame,
fDevice(bDevice),
fScanMode(0)
{
SetViewColor(B_TRANSPARENT_COLOR);
SetLowColor(0, 0, 0);
BRect iDontCare(0, 0, 0, 0);
fDeviceView = new BluetoothDeviceView(bDevice);
SetLayout(new BGroupLayout(B_HORIZONTAL));
fDeviceView = new BluetoothDeviceView(BRect(0, 0, 5, 5), bDevice);
fDiscoverable = new BCheckBox(iDontCare, "Discoverable",
fDiscoverable = new BCheckBox("Discoverable",
B_TRANSLATE("Discoverable"), new BMessage(SET_DISCOVERABLE));
fVisible = new BCheckBox(iDontCare, "Visible",
fVisible = new BCheckBox("Visible",
B_TRANSLATE("Show name"), new BMessage(SET_VISIBLE));
fAuthentication = new BCheckBox(iDontCare, "Authenticate",
fAuthentication = new BCheckBox("Authenticate",
B_TRANSLATE("Authenticate"), new BMessage(SET_AUTHENTICATION));
SetEnabled(false);
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(fDeviceView)
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
.AddGlue()
.Add(fDiscoverable)
.Add(fVisible)
.SetInsets(5, 5, 5, 5)
)
.Add(fAuthentication)
.Add(BSpaceLayoutItem::CreateVerticalStrut(0))
.SetInsets(5, 5, 5, 5)
);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(5)
.Add(fDeviceView)
.AddGroup(B_HORIZONTAL, 0)
.SetInsets(5)
.AddGlue()
.Add(fDiscoverable)
.Add(fVisible)
.End()
.Add(fAuthentication)
.End();
}

View File

@ -13,7 +13,7 @@
#include <File.h>
#include <Path.h>
#include <GroupLayoutBuilder.h>
#include <LayoutBuilder.h>
#include <SpaceLayoutItem.h>
#include <PincodeWindow.h>
@ -41,8 +41,6 @@ using namespace Bluetooth;
RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags)
: BView(name, flags)
{
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
addButton = new BButton("add", B_TRANSLATE("Add" B_UTF8_ELLIPSIS),
new BMessage(kMsgAddDevices));
@ -66,15 +64,13 @@ RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags)
fDeviceList = new BListView("DeviceList", B_SINGLE_SELECTION_LIST);
fScrollView = new BScrollView("ScrollView", fDeviceList, 0, false, true);
fScrollView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
SetLayout(new BGroupLayout(B_VERTICAL));
// TODO: use all the additional height
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10)
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 10)
.SetInsets(5)
.Add(fScrollView)
//.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
.Add(BGroupLayoutBuilder(B_VERTICAL)
.AddGroup(B_VERTICAL)
.SetInsets(0, 15, 0, 15)
.Add(addButton)
.Add(removeButton)
.AddGlue()
@ -84,10 +80,8 @@ RemoteDevicesView::RemoteDevicesView(const char* name, uint32 flags)
.Add(disconnectButton)
.Add(blockButton)
.AddGlue()
.SetInsets(0, 15, 0, 15)
)
.SetInsets(5, 5, 5, 100)
);
.End()
.End();
fDeviceList->SetSelectionMessage(NULL);
}