[haiku-commits] haiku: hrev48143 - src/preferences/sounds

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 29 Oct 2014 10:55:34 +0100 (CET)

hrev48143 adds 3 changesets to branch 'master'
old head: f26118f2865c05534a45363091b2d1da01aa6982
new head: 57810fe9e0e25aa2fd6d035a9f6e3046ab688976
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=57810fe+%5Ef26118f

----------------------------------------------------------------------------

c54aa3d: 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.

3a8e734: Sounds: make private methods private.

57810fe: Sounds: zoom to fit instead of going fullscreen.
  
  Fixes #5588.

                                 [ Adrien Destugues <pulkomandy@xxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 131 insertions(+), 117 deletions(-)
src/preferences/sounds/HEventList.cpp |   2 +
src/preferences/sounds/HWindow.cpp    | 233 ++++++++++++++++--------------
src/preferences/sounds/HWindow.h      |  13 +-

############################################################################

Commit:      c54aa3df3f69a256c78315b0cf92bbbde70c3fd1
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c54aa3d
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Wed Oct 29 09:03:11 2014 UTC

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.

----------------------------------------------------------------------------

diff --git a/src/preferences/sounds/HWindow.cpp 
b/src/preferences/sounds/HWindow.cpp
index fe475a8..2aed305 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

############################################################################

Commit:      3a8e734bddb377b005c801ea65ede6d95c41727d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3a8e734
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Wed Oct 29 09:20:46 2014 UTC

Sounds: make private methods private.

----------------------------------------------------------------------------

diff --git a/src/preferences/sounds/HWindow.cpp 
b/src/preferences/sounds/HWindow.cpp
index 2aed305..8559842 100644
--- a/src/preferences/sounds/HWindow.cpp
+++ b/src/preferences/sounds/HWindow.cpp
@@ -50,7 +50,7 @@ HWindow::HWindow(BRect rect, const char* name)
        fFilePanel(NULL),
        fPlayer(NULL)
 {
-       InitGUI();
+       _InitGUI();
 
        fFilePanel = new BFilePanel();
        fFilePanel->SetTarget(this);
@@ -91,62 +91,11 @@ HWindow::~HWindow()
 
 
 void
-HWindow::InitGUI()
+HWindow::DispatchMessage(BMessage* message, BHandler* handler)
 {
-       fEventList = new HEventList();
-       fEventList->SetType(BMediaFiles::B_SOUNDS);
-       fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);
-
-       BMenu* menu = new BMenu("file");
-       menu->SetRadioMode(true);
-       menu->SetLabelFromMarked(true);
-       menu->AddSeparatorItem();
-       menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
-               new BMessage(M_NONE_MESSAGE)));
-       menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
-               new BMessage(M_OTHER_MESSAGE)));
-
-       BString label(B_TRANSLATE("Sound file:"));
-       BMenuField* menuField = new BMenuField("filemenu", label, menu);
-       menuField->SetDivider(menuField->StringWidth(label) + 10);
-
-       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);
-
-       // 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();
-
-       SetLayout(new BGroupLayout(B_HORIZONTAL));
-       AddChild(BGroupLayoutBuilder(B_VERTICAL)
-               .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
-       SetupMenuField();
-       BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
-       if (noneItem != NULL)
-               noneItem->SetMarked(true);
+       if (message->what == B_PULSE)
+               _Pulse();
+       BWindow::DispatchMessage(message, handler);
 }
 
 
@@ -299,8 +248,113 @@ HWindow::MessageReceived(BMessage* message)
 }
 
 
+bool
+HWindow::QuitRequested()
+{
+       fFrame = Frame();
+
+       fEventList->RemoveAll();
+       be_app->PostMessage(B_QUIT_REQUESTED);
+       return true;
+}
+
+
+void
+HWindow::_InitGUI()
+{
+       fEventList = new HEventList();
+       fEventList->SetType(BMediaFiles::B_SOUNDS);
+       fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);
+
+       BMenu* menu = new BMenu("file");
+       menu->SetRadioMode(true);
+       menu->SetLabelFromMarked(true);
+       menu->AddSeparatorItem();
+       menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
+               new BMessage(M_NONE_MESSAGE)));
+       menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
+               new BMessage(M_OTHER_MESSAGE)));
+
+       BString label(B_TRANSLATE("Sound file:"));
+       BMenuField* menuField = new BMenuField("filemenu", label, menu);
+       menuField->SetDivider(menuField->StringWidth(label) + 10);
+
+       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);
+
+       // 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();
+
+       SetLayout(new BGroupLayout(B_HORIZONTAL));
+       AddChild(BGroupLayoutBuilder(B_VERTICAL)
+               .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
+       _SetupMenuField();
+       BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
+       if (noneItem != NULL)
+               noneItem->SetMarked(true);
+}
+
+
+void
+HWindow::_Pulse()
+{
+       HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
+       BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu"));
+       BButton* button = dynamic_cast<BButton*>(FindView("play"));
+       BButton* stop = dynamic_cast<BButton*>(FindView("stop"));
+
+       if (menufield == NULL || button == NULL || stop == NULL)
+               return;
+
+       if (row != NULL) {
+               menufield->SetEnabled(true);
+
+               const char* path = row->Path();
+               if (path != NULL && strcmp(path, ""))
+                       button->SetEnabled(true);
+               else
+                       button->SetEnabled(false);
+       } else {
+               menufield->SetEnabled(false);
+               button->SetEnabled(false);
+       }
+
+       if (fPlayer != NULL) {
+               if (fPlayer->IsPlaying())
+                       stop->SetEnabled(true);
+               else
+                       stop->SetEnabled(false);
+       } else
+               stop->SetEnabled(false);
+}
+
+
 void
-HWindow::SetupMenuField()
+HWindow::_SetupMenuField()
 {
        BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu"));
        if (menufield == NULL)
@@ -360,57 +414,3 @@ HWindow::SetupMenuField()
                }
        }
 }
-
-
-void
-HWindow::Pulse()
-{
-       HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
-       BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu"));
-       BButton* button = dynamic_cast<BButton*>(FindView("play"));
-       BButton* stop = dynamic_cast<BButton*>(FindView("stop"));
-
-       if (menufield == NULL || button == NULL || stop == NULL)
-               return;
-
-       if (row != NULL) {
-               menufield->SetEnabled(true);
-
-               const char* path = row->Path();
-               if (path != NULL && strcmp(path, ""))
-                       button->SetEnabled(true);
-               else
-                       button->SetEnabled(false);
-       } else {
-               menufield->SetEnabled(false);
-               button->SetEnabled(false);
-       }
-
-       if (fPlayer != NULL) {
-               if (fPlayer->IsPlaying())
-                       stop->SetEnabled(true);
-               else
-                       stop->SetEnabled(false);
-       } else
-               stop->SetEnabled(false);
-}
-
-
-void
-HWindow::DispatchMessage(BMessage* message, BHandler* handler)
-{
-       if (message->what == B_PULSE)
-               Pulse();
-       BWindow::DispatchMessage(message, handler);
-}
-
-
-bool
-HWindow::QuitRequested()
-{
-       fFrame = Frame();
-
-       fEventList->RemoveAll();
-       be_app->PostMessage(B_QUIT_REQUESTED);
-       return true;
-}
diff --git a/src/preferences/sounds/HWindow.h b/src/preferences/sounds/HWindow.h
index da27a99..28a5afa 100644
--- a/src/preferences/sounds/HWindow.h
+++ b/src/preferences/sounds/HWindow.h
@@ -38,13 +38,15 @@ public:
                                                                HWindow(BRect 
rect, const char* name);
        virtual                                         ~HWindow();
 
-       virtual void                            MessageReceived(BMessage* 
message);
-       virtual bool                            QuitRequested();
        virtual void                            DispatchMessage(BMessage* 
message,
                                                                        
BHandler* handler);
-                       void                            InitGUI();
-                       void                            SetupMenuField();
-                       void                            Pulse();
+       virtual void                            MessageReceived(BMessage* 
message);
+       virtual bool                            QuitRequested();
+
+private:
+                       void                            _InitGUI();
+                       void                            _Pulse();
+                       void                            _SetupMenuField();
 
 private:
                        HEventList*                     fEventList;

############################################################################

Revision:    hrev48143
Commit:      57810fe9e0e25aa2fd6d035a9f6e3046ab688976
URL:         http://cgit.haiku-os.org/haiku/commit/?id=57810fe
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Wed Oct 29 09:55:04 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/5588

Sounds: zoom to fit instead of going fullscreen.

Fixes #5588.

----------------------------------------------------------------------------

diff --git a/src/preferences/sounds/HEventList.cpp 
b/src/preferences/sounds/HEventList.cpp
index ad971f4..5e7edd0 100644
--- a/src/preferences/sounds/HEventList.cpp
+++ b/src/preferences/sounds/HEventList.cpp
@@ -93,6 +93,8 @@ HEventList::SetType(const char* type)
                else
                        AddRow(new HEventRow(name.String(), path.Path()));
        }
+
+       ResizeAllColumnsToPreferred();
 }
 
 
diff --git a/src/preferences/sounds/HWindow.cpp 
b/src/preferences/sounds/HWindow.cpp
index 8559842..6fba417 100644
--- a/src/preferences/sounds/HWindow.cpp
+++ b/src/preferences/sounds/HWindow.cpp
@@ -224,6 +224,21 @@ HWindow::MessageReceived(BMessage* message)
                                        if (item != NULL)
                                                item->SetMarked(true);
                                }
+
+                               HEventRow* row = 
(HEventRow*)fEventList->CurrentSelection();
+                               BButton* button = 
dynamic_cast<BButton*>(FindView("play"));
+                               if (row != NULL) {
+                                       menufield->SetEnabled(true);
+
+                                       const char* path = row->Path();
+                                       if (path != NULL && strcmp(path, ""))
+                                               button->SetEnabled(true);
+                                       else
+                                               button->SetEnabled(false);
+                               } else {
+                                       menufield->SetEnabled(false);
+                                       button->SetEnabled(false);
+                               }
                        }
                        break;
                }
@@ -231,8 +246,10 @@ HWindow::MessageReceived(BMessage* message)
                case M_ITEM_MESSAGE:
                {
                        entry_ref ref;
-                       if (message->FindRef("refs", &ref) == B_OK)
+                       if (message->FindRef("refs", &ref) == B_OK) {
                                fEventList->SetPath(BPath(&ref).Path());
+                               _UpdateZoomLimits();
+                       }
                        break;
                }
 
@@ -316,33 +333,19 @@ HWindow::_InitGUI()
        BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
        if (noneItem != NULL)
                noneItem->SetMarked(true);
+
+       _UpdateZoomLimits();
 }
 
 
 void
 HWindow::_Pulse()
 {
-       HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
-       BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu"));
-       BButton* button = dynamic_cast<BButton*>(FindView("play"));
        BButton* stop = dynamic_cast<BButton*>(FindView("stop"));
 
-       if (menufield == NULL || button == NULL || stop == NULL)
+       if (stop == NULL)
                return;
 
-       if (row != NULL) {
-               menufield->SetEnabled(true);
-
-               const char* path = row->Path();
-               if (path != NULL && strcmp(path, ""))
-                       button->SetEnabled(true);
-               else
-                       button->SetEnabled(false);
-       } else {
-               menufield->SetEnabled(false);
-               button->SetEnabled(false);
-       }
-
        if (fPlayer != NULL) {
                if (fPlayer->IsPlaying())
                        stop->SetEnabled(true);
@@ -414,3 +417,15 @@ HWindow::_SetupMenuField()
                }
        }
 }
+
+
+void
+HWindow::_UpdateZoomLimits()
+{
+       const float kInset = be_control_look->DefaultItemSpacing();
+
+       BSize size = fEventList->PreferredSize();
+       SetZoomLimits(size.width + 2 * kInset + B_V_SCROLL_BAR_WIDTH,
+               size.height + 5 * kInset + 2 * B_H_SCROLL_BAR_HEIGHT
+                       + 2 * be_plain_font->Size() * 2.5);
+}
diff --git a/src/preferences/sounds/HWindow.h b/src/preferences/sounds/HWindow.h
index 28a5afa..7402340 100644
--- a/src/preferences/sounds/HWindow.h
+++ b/src/preferences/sounds/HWindow.h
@@ -47,6 +47,7 @@ private:
                        void                            _InitGUI();
                        void                            _Pulse();
                        void                            _SetupMenuField();
+                       void                            _UpdateZoomLimits();
 
 private:
                        HEventList*                     fEventList;


Other related posts: