From c54aa3df3f69a256c78315b0cf92bbbde70c3fd1 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 29 Oct 2014 10:03:11 +0100 Subject: [PATCH] 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. --- src/preferences/sounds/HWindow.cpp | 44 +++++++++++++----------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/src/preferences/sounds/HWindow.cpp b/src/preferences/sounds/HWindow.cpp index fe475a86f9..2aed30590c 100644 --- a/src/preferences/sounds/HWindow.cpp +++ b/src/preferences/sounds/HWindow.cpp @@ -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