Sounds: rework layout of window

* Remove useless BBox
* Use unicode symbols for play/stop buttons instead of a label
* Since the buttons are smaller, put them on the same line as the file
selector.
This commit is contained in:
Adrien Destugues 2014-10-29 10:03:11 +01:00
parent f26118f286
commit c54aa3df3f
1 changed files with 19 additions and 25 deletions

View File

@ -97,10 +97,6 @@ HWindow::InitGUI()
fEventList->SetType(BMediaFiles::B_SOUNDS);
fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);
BGroupView* view = new BGroupView();
BBox* box = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS
| B_NAVIGABLE_JUMP | B_PULSE_NEEDED);
BMenu* menu = new BMenu("file");
menu->SetRadioMode(true);
menu->SetLabelFromMarked(true);
@ -114,38 +110,36 @@ HWindow::InitGUI()
BMenuField* menuField = new BMenuField("filemenu", label, menu);
menuField->SetDivider(menuField->StringWidth(label) + 10);
BButton* stopbutton = new BButton("stop", B_TRANSLATE("Stop"),
BSize buttonsSize(be_plain_font->Size() * 2.5, be_plain_font->Size() * 2.5);
BButton* stopbutton = new BButton("stop", "\xE2\x96\xA0",
new BMessage(M_STOP_MESSAGE));
stopbutton->SetEnabled(false);
stopbutton->SetExplicitSize(buttonsSize);
BButton* playbutton = new BButton("play", B_TRANSLATE("Play"),
// We need at least one view to trigger B_PULSE_NEEDED events which we will
// intercept in DispatchMessage to trigger the buttons enabling or disabling.
stopbutton->SetFlags(stopbutton->Flags() | B_PULSE_NEEDED);
BButton* playbutton = new BButton("play", "\xE2\x96\xB6",
new BMessage(M_PLAY_MESSAGE));
playbutton->SetEnabled(false);
playbutton->SetExplicitSize(buttonsSize);
const float kInset = be_control_look->DefaultItemSpacing();
view->SetLayout(new BGroupLayout(B_HORIZONTAL));
view->AddChild(BGroupLayoutBuilder(B_VERTICAL, kInset)
.AddGroup(B_HORIZONTAL)
.Add(menuField)
.AddGlue()
.End()
.AddGroup(B_HORIZONTAL, kInset)
.AddGlue()
.Add(playbutton)
.Add(stopbutton)
.End()
.SetInsets(kInset, kInset, kInset, kInset)
);
box->AddChild(view);
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL)
.AddGroup(B_VERTICAL, kInset)
.Add(fEventList)
.Add(box)
.End()
.SetInsets(kInset, kInset, kInset, kInset)
.Add(fEventList)
.AddGroup(B_HORIZONTAL)
.SetInsets(0, 0, 0, 0)
.Add(menuField)
.AddGroup(B_HORIZONTAL, 0)
.Add(playbutton)
.Add(stopbutton)
.End()
.End()
);
// setup file menu