* 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. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41200 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9b13c4181c
commit
11b2388364
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user