mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-07 04:10:08 +00:00
Minor clean-ups in TabbedComponent.
This commit is contained in:
parent
7373bfd3be
commit
21d7a993ab
3 changed files with 30 additions and 58 deletions
|
|
@ -106,10 +106,15 @@ public:
|
|||
virtual int getBestTabLength (int depth);
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown);
|
||||
/** @internal */
|
||||
void clicked (const ModifierKeys&);
|
||||
/** @internal */
|
||||
bool hitTest (int x, int y);
|
||||
/** @internal */
|
||||
void resized();
|
||||
/** @internal */
|
||||
void childBoundsChanged (Component*);
|
||||
|
||||
protected:
|
||||
|
|
@ -147,7 +152,6 @@ class JUCE_API TabbedButtonBar : public Component,
|
|||
public:
|
||||
//==============================================================================
|
||||
/** The placement of the tab-bar
|
||||
|
||||
@see setOrientation, getOrientation
|
||||
*/
|
||||
enum Orientation
|
||||
|
|
@ -159,8 +163,7 @@ public:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
/** Creates a TabbedButtonBar with a given placement.
|
||||
|
||||
/** Creates a TabbedButtonBar with a given orientation.
|
||||
You can change the orientation later if you need to.
|
||||
*/
|
||||
TabbedButtonBar (Orientation orientation);
|
||||
|
|
@ -195,7 +198,6 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Deletes all the tabs from the bar.
|
||||
|
||||
@see addTab
|
||||
*/
|
||||
void clearTabs();
|
||||
|
|
@ -209,14 +211,12 @@ public:
|
|||
int insertIndex);
|
||||
|
||||
/** Changes the name of one of the tabs. */
|
||||
void setTabName (int tabIndex,
|
||||
const String& newName);
|
||||
void setTabName (int tabIndex, const String& newName);
|
||||
|
||||
/** Gets rid of one of the tabs. */
|
||||
void removeTab (int tabIndex);
|
||||
|
||||
/** Moves a tab to a new index in the list.
|
||||
|
||||
Pass -1 as the index to move it to the end of the list.
|
||||
*/
|
||||
void moveTab (int currentIndex, int newIndex);
|
||||
|
|
@ -228,7 +228,6 @@ public:
|
|||
StringArray getTabNames() const;
|
||||
|
||||
/** Changes the currently selected tab.
|
||||
|
||||
This will send a change message and cause a synchronous callback to
|
||||
the currentTabChanged() method. (But if the given tab is already selected,
|
||||
nothing will be done).
|
||||
|
|
@ -238,19 +237,16 @@ public:
|
|||
void setCurrentTabIndex (int newTabIndex, bool sendChangeMessage = true);
|
||||
|
||||
/** Returns the name of the currently selected tab.
|
||||
|
||||
This could be an empty string if none are selected.
|
||||
*/
|
||||
String getCurrentTabName() const;
|
||||
|
||||
/** Returns the index of the currently selected tab.
|
||||
|
||||
This could return -1 if none are selected.
|
||||
*/
|
||||
int getCurrentTabIndex() const noexcept { return currentTabIndex; }
|
||||
int getCurrentTabIndex() const noexcept { return currentTabIndex; }
|
||||
|
||||
/** Returns the button for a specific tab.
|
||||
|
||||
The button that is returned may be deleted later by this component, so don't hang
|
||||
on to the pointer that is returned. A null pointer may be returned if the index is
|
||||
out of range.
|
||||
|
|
@ -262,26 +258,20 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Callback method to indicate the selected tab has been changed.
|
||||
|
||||
@see setCurrentTabIndex
|
||||
*/
|
||||
virtual void currentTabChanged (int newCurrentTabIndex,
|
||||
const String& newCurrentTabName);
|
||||
|
||||
/** Callback method to indicate that the user has right-clicked on a tab.
|
||||
|
||||
(Or ctrl-clicked on the Mac)
|
||||
*/
|
||||
/** Callback method to indicate that the user has right-clicked on a tab. */
|
||||
virtual void popupMenuClickOnTab (int tabIndex, const String& tabName);
|
||||
|
||||
/** Returns the colour of a tab.
|
||||
|
||||
This is the colour that was specified in addTab().
|
||||
*/
|
||||
Colour getTabBackgroundColour (int tabIndex);
|
||||
|
||||
/** Changes the background colour of a tab.
|
||||
|
||||
@see addTab, getTabBackgroundColour
|
||||
*/
|
||||
void setTabBackgroundColour (int tabIndex, const Colour& newColour);
|
||||
|
|
|
|||
|
|
@ -275,16 +275,17 @@ void TabbedComponent::lookAndFeelChanged()
|
|||
|
||||
void TabbedComponent::changeCallback (const int newCurrentTabIndex, const String& newTabName)
|
||||
{
|
||||
if (panelComponent != nullptr)
|
||||
{
|
||||
panelComponent->setVisible (false);
|
||||
removeChildComponent (panelComponent);
|
||||
panelComponent = nullptr;
|
||||
}
|
||||
Component* const newPanelComp = getTabContentComponent (getCurrentTabIndex());
|
||||
|
||||
if (getCurrentTabIndex() >= 0)
|
||||
if (newPanelComp != panelComponent)
|
||||
{
|
||||
panelComponent = getTabContentComponent (getCurrentTabIndex());
|
||||
if (panelComponent != nullptr)
|
||||
{
|
||||
panelComponent->setVisible (false);
|
||||
removeChildComponent (panelComponent);
|
||||
}
|
||||
|
||||
panelComponent = newPanelComp;
|
||||
|
||||
if (panelComponent != nullptr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ class JUCE_API TabbedComponent : public Component
|
|||
public:
|
||||
//==============================================================================
|
||||
/** Creates a TabbedComponent, specifying where the tabs should be placed.
|
||||
|
||||
Once created, add some tabs with the addTab() method.
|
||||
*/
|
||||
explicit TabbedComponent (TabbedButtonBar::Orientation orientation);
|
||||
|
|
@ -63,7 +62,6 @@ public:
|
|||
void setOrientation (TabbedButtonBar::Orientation orientation);
|
||||
|
||||
/** Returns the current tab placement.
|
||||
|
||||
@see setOrientation, TabbedButtonBar::getOrientation
|
||||
*/
|
||||
TabbedButtonBar::Orientation getOrientation() const noexcept;
|
||||
|
|
@ -77,7 +75,6 @@ public:
|
|||
void setTabBarDepth (int newDepth);
|
||||
|
||||
/** Returns the current thickness of the tab bar.
|
||||
|
||||
@see setTabBarDepth
|
||||
*/
|
||||
int getTabBarDepth() const noexcept { return tabDepth; }
|
||||
|
|
@ -92,23 +89,21 @@ public:
|
|||
void setOutline (int newThickness);
|
||||
|
||||
/** Specifies a gap to leave around the edge of the content component.
|
||||
|
||||
Each edge of the content component will be indented by the given number of pixels.
|
||||
*/
|
||||
void setIndent (int indentThickness);
|
||||
|
||||
//==============================================================================
|
||||
/** Removes all the tabs from the bar.
|
||||
|
||||
@see TabbedButtonBar::clearTabs
|
||||
*/
|
||||
void clearTabs();
|
||||
|
||||
/** Adds a tab to the tab-bar.
|
||||
|
||||
The component passed in will be shown for the tab, and if deleteComponentWhenNotNeeded
|
||||
is true, it will be deleted when the tab is removed or when this object is
|
||||
deleted.
|
||||
The component passed in will be shown for the tab. If deleteComponentWhenNotNeeded
|
||||
is true, then the TabbedComponent will take ownership of the component and will delete
|
||||
it when the tab is removed or when this object is deleted.
|
||||
|
||||
@see TabbedButtonBar::addTab
|
||||
*/
|
||||
|
|
@ -131,9 +126,8 @@ public:
|
|||
StringArray getTabNames() const;
|
||||
|
||||
/** Returns the content component that was added for the given index.
|
||||
|
||||
Be sure not to use or delete the components that are returned, as this may interfere
|
||||
with the TabbedComponent's use of them.
|
||||
Be careful not to reposition or delete the components that are returned, as
|
||||
this will interfere with the TabbedComponent's behaviour.
|
||||
*/
|
||||
Component* getTabContentComponent (int tabIndex) const noexcept;
|
||||
|
||||
|
|
@ -145,48 +139,36 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Changes the currently-selected tab.
|
||||
|
||||
To deselect all the tabs, pass -1 as the index.
|
||||
|
||||
@see TabbedButtonBar::setCurrentTabIndex
|
||||
*/
|
||||
void setCurrentTabIndex (int newTabIndex, bool sendChangeMessage = true);
|
||||
|
||||
/** Returns the index of the currently selected tab.
|
||||
|
||||
@see addTab, TabbedButtonBar::getCurrentTabIndex()
|
||||
*/
|
||||
int getCurrentTabIndex() const;
|
||||
|
||||
/** Returns the name of the currently selected tab.
|
||||
|
||||
@see addTab, TabbedButtonBar::getCurrentTabName()
|
||||
*/
|
||||
String getCurrentTabName() const;
|
||||
|
||||
/** Returns the current component that's filling the panel.
|
||||
|
||||
This will return 0 if there isn't one.
|
||||
This will return nullptr if there isn't one.
|
||||
*/
|
||||
Component* getCurrentContentComponent() const noexcept { return panelComponent; }
|
||||
|
||||
//==============================================================================
|
||||
/** Callback method to indicate the selected tab has been changed.
|
||||
|
||||
@see setCurrentTabIndex
|
||||
*/
|
||||
virtual void currentTabChanged (int newCurrentTabIndex,
|
||||
const String& newCurrentTabName);
|
||||
virtual void currentTabChanged (int newCurrentTabIndex, const String& newCurrentTabName);
|
||||
|
||||
/** Callback method to indicate that the user has right-clicked on a tab.
|
||||
/** Callback method to indicate that the user has right-clicked on a tab. */
|
||||
virtual void popupMenuClickOnTab (int tabIndex, const String& tabName);
|
||||
|
||||
(Or ctrl-clicked on the Mac)
|
||||
*/
|
||||
virtual void popupMenuClickOnTab (int tabIndex,
|
||||
const String& tabName);
|
||||
|
||||
/** Returns the tab button bar component that is being used.
|
||||
*/
|
||||
/** Returns the tab button bar component that is being used. */
|
||||
TabbedButtonBar& getTabbedButtonBar() const noexcept { return *tabs; }
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -206,7 +188,7 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics& g);
|
||||
void paint (Graphics&);
|
||||
/** @internal */
|
||||
void resized();
|
||||
/** @internal */
|
||||
|
|
@ -228,8 +210,7 @@ private:
|
|||
//==============================================================================
|
||||
Array <WeakReference<Component> > contentComponents;
|
||||
WeakReference<Component> panelComponent;
|
||||
int tabDepth;
|
||||
int outlineThickness, edgeIndent;
|
||||
int tabDepth, outlineThickness, edgeIndent;
|
||||
|
||||
class ButtonBar;
|
||||
friend class ButtonBar;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue