diff --git a/src/apps/showimage/ToolBarView.cpp b/src/apps/showimage/ToolBarView.cpp index cbf6fb3264..afe272f18c 100644 --- a/src/apps/showimage/ToolBarView.cpp +++ b/src/apps/showimage/ToolBarView.cpp @@ -19,8 +19,6 @@ ToolBarView::ToolBarView(BRect frame) GroupLayout()->SetInsets(inset, 2, inset, 3); GroupLayout()->SetSpacing(inset); - GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); - SetFlags(Flags() | B_FRAME_EVENTS | B_PULSE_NEEDED); MoveTo(frame.LeftTop()); @@ -71,6 +69,13 @@ ToolBarView::AddSeparator() } +void +ToolBarView::AddGlue() +{ + GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); +} + + void ToolBarView::SetActionEnabled(uint32 command, bool enabled) { @@ -87,6 +92,21 @@ ToolBarView::SetActionPressed(uint32 command, bool pressed) } +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() { @@ -109,8 +129,7 @@ ToolBarView::FrameResized(float width, float height) void ToolBarView::_AddView(BView* view) { - // Add before the space layout item at the end - GroupLayout()->AddView(GroupLayout()->CountItems() - 1, view); + GroupLayout()->AddView(view); } diff --git a/src/apps/showimage/ToolBarView.h b/src/apps/showimage/ToolBarView.h index 02857c24a9..b89d295071 100644 --- a/src/apps/showimage/ToolBarView.h +++ b/src/apps/showimage/ToolBarView.h @@ -29,9 +29,11 @@ public: 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();