[haiku-commits] r41200 - haiku/trunk/src/apps/showimage

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 8 Apr 2011 16:59:54 +0200 (CEST)

Author: stippi
Date: 2011-04-08 16:59:54 +0200 (Fri, 08 Apr 2011)
New Revision: 41200
Changeset: https://dev.haiku-os.org/changeset/41200

Modified:
   haiku/trunk/src/apps/showimage/ToolBarView.cpp
   haiku/trunk/src/apps/showimage/ToolBarView.h
Log:
 * Added AddGlue() method. If this is not used, the tool bar
   will stretch the icons across the available space. However,
   it's possible to still add items afterwards, which makes those
   items right-aligned.
 * Added SetActionVisible() to show or hide icons.


Modified: haiku/trunk/src/apps/showimage/ToolBarView.cpp
===================================================================
--- haiku/trunk/src/apps/showimage/ToolBarView.cpp      2011-04-08 12:21:53 UTC 
(rev 41199)
+++ haiku/trunk/src/apps/showimage/ToolBarView.cpp      2011-04-08 14:59:54 UTC 
(rev 41200)
@@ -19,8 +19,6 @@
        GroupLayout()->SetInsets(inset, 2, inset, 3);
        GroupLayout()->SetSpacing(inset);
 
-       GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
-
        SetFlags(Flags() | B_FRAME_EVENTS | B_PULSE_NEEDED);
 
        MoveTo(frame.LeftTop());
@@ -72,6 +70,13 @@
 
 
 void
+ToolBarView::AddGlue()
+{
+       GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
+}
+
+
+void
 ToolBarView::SetActionEnabled(uint32 command, bool enabled)
 {
        if (BIconButton* button = _FindIconButton(command))
@@ -88,6 +93,21 @@
 
 
 void
+ToolBarView::SetActionVisible(uint32 command, bool visible)
+{
+       BIconButton* button = _FindIconButton(command);
+       if (button == NULL)
+               return;
+       for (int32 i = 0; BLayoutItem* item = GroupLayout()->ItemAt(i); i++) {
+               if (item->View() != button)
+                       continue;
+               item->SetVisible(visible);
+               break;
+       }
+}
+
+
+void
 ToolBarView::Pulse()
 {
        // TODO: Perhaps this could/should be addressed in BView instead.
@@ -109,8 +129,7 @@
 void
 ToolBarView::_AddView(BView* view)
 {
-       // Add before the space layout item at the end
-       GroupLayout()->AddView(GroupLayout()->CountItems() - 1, view);
+       GroupLayout()->AddView(view);
 }
 
 

Modified: haiku/trunk/src/apps/showimage/ToolBarView.h
===================================================================
--- haiku/trunk/src/apps/showimage/ToolBarView.h        2011-04-08 12:21:53 UTC 
(rev 41199)
+++ haiku/trunk/src/apps/showimage/ToolBarView.h        2011-04-08 14:59:54 UTC 
(rev 41200)
@@ -29,9 +29,11 @@
                                                                        const 
BBitmap* icon,
                                                                        const 
char* toolTipText = NULL);
                        void                            AddSeparator();
+                       void                            AddGlue();
 
                        void                            SetActionEnabled(uint32 
command, bool enabled);
                        void                            SetActionPressed(uint32 
command, bool pressed);
+                       void                            SetActionVisible(uint32 
command, bool visible);
 
 private:
        virtual void                            Pulse();


Other related posts:

  • » [haiku-commits] r41200 - haiku/trunk/src/apps/showimage - superstippi