From 614afb1ca6612a96d7081803c46038c56da7ee6e Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 2 Sep 2013 14:09:17 +0100 Subject: [PATCH] Added method Toolbar::removeAndReturnItem. --- modules/juce_gui_basics/widgets/juce_Toolbar.cpp | 12 ++++++++++++ modules/juce_gui_basics/widgets/juce_Toolbar.h | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp index 81cde9dfff..d16b712058 100644 --- a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp +++ b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp @@ -325,6 +325,18 @@ void Toolbar::removeToolbarItem (const int itemIndex) resized(); } +ToolbarItemComponent* Toolbar::removeAndReturnItem (const int itemIndex) +{ + if (ToolbarItemComponent* const tc = items.removeAndReturn (itemIndex)) + { + removeChildComponent (tc); + resized(); + return tc; + } + + return nullptr; +} + int Toolbar::getNumItems() const noexcept { return items.size(); diff --git a/modules/juce_gui_basics/widgets/juce_Toolbar.h b/modules/juce_gui_basics/widgets/juce_Toolbar.h index e0eeb81e77..d9505812fe 100644 --- a/modules/juce_gui_basics/widgets/juce_Toolbar.h +++ b/modules/juce_gui_basics/widgets/juce_Toolbar.h @@ -121,10 +121,12 @@ public: int itemId, int insertIndex = -1); - /** Deletes one of the items from the bar. - */ + /** Deletes one of the items from the bar. */ void removeToolbarItem (int itemIndex); + /** Removes an item from the bar and returns it. */ + ToolbarItemComponent* removeAndReturnItem (int itemIndex); + /** Returns the number of items currently on the toolbar. @see getItemId, getItemComponent