|
|
@@ -149,14 +149,14 @@ private: |
|
|
class Toolbar::MissingItemsComponent : public PopupMenu::CustomComponent
|
|
|
class Toolbar::MissingItemsComponent : public PopupMenu::CustomComponent
|
|
|
{
|
|
|
{
|
|
|
public:
|
|
|
public:
|
|
|
MissingItemsComponent (Toolbar& owner_, const int height_)
|
|
|
|
|
|
|
|
|
MissingItemsComponent (Toolbar& bar, const int h)
|
|
|
: PopupMenu::CustomComponent (true),
|
|
|
: PopupMenu::CustomComponent (true),
|
|
|
owner (&owner_),
|
|
|
|
|
|
height (height_)
|
|
|
|
|
|
|
|
|
owner (&bar),
|
|
|
|
|
|
height (h)
|
|
|
{
|
|
|
{
|
|
|
for (int i = owner_.items.size(); --i >= 0;)
|
|
|
|
|
|
|
|
|
for (int i = bar.items.size(); --i >= 0;)
|
|
|
{
|
|
|
{
|
|
|
ToolbarItemComponent* const tc = owner_.items.getUnchecked(i);
|
|
|
|
|
|
|
|
|
ToolbarItemComponent* const tc = bar.items.getUnchecked(i);
|
|
|
|
|
|
|
|
|
if (dynamic_cast <Spacer*> (tc) == nullptr && ! tc->isVisible())
|
|
|
if (dynamic_cast <Spacer*> (tc) == nullptr && ! tc->isVisible())
|
|
|
{
|
|
|
{
|
|
|
@@ -501,13 +501,15 @@ void Toolbar::updateAllItemPositions (const bool animate) |
|
|
else
|
|
|
else
|
|
|
newBounds.setBounds (pos, 0, size, getHeight());
|
|
|
newBounds.setBounds (pos, 0, size, getHeight());
|
|
|
|
|
|
|
|
|
|
|
|
ComponentAnimator& animator = Desktop::getInstance().getAnimator();
|
|
|
|
|
|
|
|
|
if (animate)
|
|
|
if (animate)
|
|
|
{
|
|
|
{
|
|
|
Desktop::getInstance().getAnimator().animateComponent (tc, newBounds, 1.0f, 200, false, 3.0, 0.0);
|
|
|
|
|
|
|
|
|
animator.animateComponent (tc, newBounds, 1.0f, 200, false, 3.0, 0.0);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
else
|
|
|
{
|
|
|
{
|
|
|
Desktop::getInstance().getAnimator().cancelAnimation (tc, false);
|
|
|
|
|
|
|
|
|
animator.cancelAnimation (tc, false);
|
|
|
tc->setBounds (newBounds);
|
|
|
tc->setBounds (newBounds);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -548,7 +550,7 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails) |
|
|
if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette)
|
|
|
if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette)
|
|
|
{
|
|
|
{
|
|
|
if (ToolbarItemPalette* const palette = tc->findParentComponentOfClass<ToolbarItemPalette>())
|
|
|
if (ToolbarItemPalette* const palette = tc->findParentComponentOfClass<ToolbarItemPalette>())
|
|
|
palette->replaceComponent (tc);
|
|
|
|
|
|
|
|
|
palette->replaceComponent (*tc);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
else
|
|
|
{
|
|
|
{
|
|
|
@@ -560,6 +562,8 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails) |
|
|
updateAllItemPositions (true);
|
|
|
updateAllItemPositions (true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ComponentAnimator& animator = Desktop::getInstance().getAnimator();
|
|
|
|
|
|
|
|
|
for (int i = getNumItems(); --i >= 0;)
|
|
|
for (int i = getNumItems(); --i >= 0;)
|
|
|
{
|
|
|
{
|
|
|
const int currentIndex = items.indexOf (tc);
|
|
|
const int currentIndex = items.indexOf (tc);
|
|
|
@@ -569,12 +573,11 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails) |
|
|
: (dragSourceDetails.localPosition.getX() - tc->dragOffsetX);
|
|
|
: (dragSourceDetails.localPosition.getX() - tc->dragOffsetX);
|
|
|
const int dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth());
|
|
|
const int dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth());
|
|
|
|
|
|
|
|
|
const Rectangle<int> current (Desktop::getInstance().getAnimator()
|
|
|
|
|
|
.getComponentDestination (getChildComponent (newIndex)));
|
|
|
|
|
|
|
|
|
const Rectangle<int> current (animator.getComponentDestination (getChildComponent (newIndex)));
|
|
|
|
|
|
|
|
|
if (ToolbarItemComponent* const prev = getNextActiveComponent (newIndex, -1))
|
|
|
if (ToolbarItemComponent* const prev = getNextActiveComponent (newIndex, -1))
|
|
|
{
|
|
|
{
|
|
|
const Rectangle<int> previousPos (Desktop::getInstance().getAnimator().getComponentDestination (prev));
|
|
|
|
|
|
|
|
|
const Rectangle<int> previousPos (animator.getComponentDestination (prev));
|
|
|
|
|
|
|
|
|
if (abs (dragObjectLeft - (vertical ? previousPos.getY() : previousPos.getX())
|
|
|
if (abs (dragObjectLeft - (vertical ? previousPos.getY() : previousPos.getX())
|
|
|
< abs (dragObjectRight - (vertical ? current.getBottom() : current.getRight()))))
|
|
|
< abs (dragObjectRight - (vertical ? current.getBottom() : current.getRight()))))
|
|
|
@@ -585,7 +588,7 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails) |
|
|
|
|
|
|
|
|
if (ToolbarItemComponent* const next = getNextActiveComponent (newIndex, 1))
|
|
|
if (ToolbarItemComponent* const next = getNextActiveComponent (newIndex, 1))
|
|
|
{
|
|
|
{
|
|
|
const Rectangle<int> nextPos (Desktop::getInstance().getAnimator().getComponentDestination (next));
|
|
|
|
|
|
|
|
|
const Rectangle<int> nextPos (animator.getComponentDestination (next));
|
|
|
|
|
|
|
|
|
if (abs (dragObjectLeft - (vertical ? current.getY() : current.getX())
|
|
|
if (abs (dragObjectLeft - (vertical ? current.getY() : current.getX())
|
|
|
> abs (dragObjectRight - (vertical ? nextPos.getBottom() : nextPos.getRight()))))
|
|
|
> abs (dragObjectRight - (vertical ? nextPos.getBottom() : nextPos.getRight()))))
|
|
|
@@ -625,21 +628,15 @@ void Toolbar::itemDropped (const SourceDetails& dragSourceDetails) |
|
|
tc->setState (Button::buttonNormal);
|
|
|
tc->setState (Button::buttonNormal);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
void Toolbar::mouseDown (const MouseEvent&)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
void Toolbar::mouseDown (const MouseEvent&) {}
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
//==============================================================================
|
|
|
class Toolbar::CustomisationDialog : public DialogWindow
|
|
|
class Toolbar::CustomisationDialog : public DialogWindow
|
|
|
{
|
|
|
{
|
|
|
public:
|
|
|
public:
|
|
|
CustomisationDialog (ToolbarItemFactory& factory,
|
|
|
|
|
|
Toolbar* const toolbar_,
|
|
|
|
|
|
const int optionFlags)
|
|
|
|
|
|
|
|
|
CustomisationDialog (ToolbarItemFactory& factory, Toolbar& bar, int optionFlags)
|
|
|
: DialogWindow (TRANS("Add/remove items from toolbar"), Colours::white, true, true),
|
|
|
: DialogWindow (TRANS("Add/remove items from toolbar"), Colours::white, true, true),
|
|
|
toolbar (toolbar_)
|
|
|
|
|
|
|
|
|
toolbar (bar)
|
|
|
{
|
|
|
{
|
|
|
setContentOwned (new CustomiserPanel (factory, toolbar, optionFlags), true);
|
|
|
setContentOwned (new CustomiserPanel (factory, toolbar, optionFlags), true);
|
|
|
setResizable (true, true);
|
|
|
setResizable (true, true);
|
|
|
@@ -649,7 +646,7 @@ public: |
|
|
|
|
|
|
|
|
~CustomisationDialog()
|
|
|
~CustomisationDialog()
|
|
|
{
|
|
|
{
|
|
|
toolbar->setEditingActive (false);
|
|
|
|
|
|
|
|
|
toolbar.setEditingActive (false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void closeButtonPressed() override
|
|
|
void closeButtonPressed() override
|
|
|
@@ -659,54 +656,51 @@ public: |
|
|
|
|
|
|
|
|
bool canModalEventBeSentToComponent (const Component* comp) override
|
|
|
bool canModalEventBeSentToComponent (const Component* comp) override
|
|
|
{
|
|
|
{
|
|
|
return toolbar->isParentOf (comp);
|
|
|
|
|
|
|
|
|
return toolbar.isParentOf (comp)
|
|
|
|
|
|
|| dynamic_cast <const ToolbarItemComponent::ItemDragAndDropOverlayComponent*> (comp) != nullptr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void positionNearBar()
|
|
|
void positionNearBar()
|
|
|
{
|
|
|
{
|
|
|
const Rectangle<int> screenSize (toolbar->getParentMonitorArea());
|
|
|
|
|
|
const int tbx = toolbar->getScreenX();
|
|
|
|
|
|
const int tby = toolbar->getScreenY();
|
|
|
|
|
|
|
|
|
const Rectangle<int> screenSize (toolbar.getParentMonitorArea());
|
|
|
|
|
|
const int tbx = toolbar.getScreenX();
|
|
|
|
|
|
const int tby = toolbar.getScreenY();
|
|
|
const int gap = 8;
|
|
|
const int gap = 8;
|
|
|
|
|
|
|
|
|
int x, y;
|
|
|
int x, y;
|
|
|
|
|
|
|
|
|
if (toolbar->isVertical())
|
|
|
|
|
|
|
|
|
if (toolbar.isVertical())
|
|
|
{
|
|
|
{
|
|
|
y = tby;
|
|
|
y = tby;
|
|
|
|
|
|
|
|
|
if (tbx > screenSize.getCentreX())
|
|
|
if (tbx > screenSize.getCentreX())
|
|
|
x = tbx - getWidth() - gap;
|
|
|
x = tbx - getWidth() - gap;
|
|
|
else
|
|
|
else
|
|
|
x = tbx + toolbar->getWidth() + gap;
|
|
|
|
|
|
|
|
|
x = tbx + toolbar.getWidth() + gap;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
else
|
|
|
{
|
|
|
{
|
|
|
x = tbx + (toolbar->getWidth() - getWidth()) / 2;
|
|
|
|
|
|
|
|
|
x = tbx + (toolbar.getWidth() - getWidth()) / 2;
|
|
|
|
|
|
|
|
|
if (tby > screenSize.getCentreY())
|
|
|
if (tby > screenSize.getCentreY())
|
|
|
y = tby - getHeight() - gap;
|
|
|
y = tby - getHeight() - gap;
|
|
|
else
|
|
|
else
|
|
|
y = tby + toolbar->getHeight() + gap;
|
|
|
|
|
|
|
|
|
y = tby + toolbar.getHeight() + gap;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
setTopLeftPosition (x, y);
|
|
|
setTopLeftPosition (x, y);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
private:
|
|
|
private:
|
|
|
Toolbar* const toolbar;
|
|
|
|
|
|
|
|
|
Toolbar& toolbar;
|
|
|
|
|
|
|
|
|
class CustomiserPanel : public Component,
|
|
|
class CustomiserPanel : public Component,
|
|
|
private ComboBoxListener, // (can't use ComboBox::Listener due to idiotic VC2005 bug)
|
|
|
private ComboBoxListener, // (can't use ComboBox::Listener due to idiotic VC2005 bug)
|
|
|
private ButtonListener
|
|
|
private ButtonListener
|
|
|
{
|
|
|
{
|
|
|
public:
|
|
|
public:
|
|
|
CustomiserPanel (ToolbarItemFactory& factory_,
|
|
|
|
|
|
Toolbar* const toolbar_,
|
|
|
|
|
|
const int optionFlags)
|
|
|
|
|
|
: factory (factory_),
|
|
|
|
|
|
toolbar (toolbar_),
|
|
|
|
|
|
palette (factory_, toolbar_),
|
|
|
|
|
|
|
|
|
CustomiserPanel (ToolbarItemFactory& tbf, Toolbar& bar, int optionFlags)
|
|
|
|
|
|
: factory (tbf), toolbar (bar), palette (tbf, bar),
|
|
|
instructions (String::empty, TRANS ("You can drag the items above and drop them onto a toolbar to add them.")
|
|
|
instructions (String::empty, TRANS ("You can drag the items above and drop them onto a toolbar to add them.")
|
|
|
+ "\n\n"
|
|
|
+ "\n\n"
|
|
|
+ TRANS ("Items on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them.")),
|
|
|
+ TRANS ("Items on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them.")),
|
|
|
@@ -726,7 +720,7 @@ private: |
|
|
if ((optionFlags & Toolbar::allowTextOnlyChoice) != 0) styleBox.addItem (TRANS("Show descriptions only"), 3);
|
|
|
if ((optionFlags & Toolbar::allowTextOnlyChoice) != 0) styleBox.addItem (TRANS("Show descriptions only"), 3);
|
|
|
|
|
|
|
|
|
int selectedStyle = 0;
|
|
|
int selectedStyle = 0;
|
|
|
switch (toolbar_->getStyle())
|
|
|
|
|
|
|
|
|
switch (bar.getStyle())
|
|
|
{
|
|
|
{
|
|
|
case Toolbar::iconsOnly: selectedStyle = 1; break;
|
|
|
case Toolbar::iconsOnly: selectedStyle = 1; break;
|
|
|
case Toolbar::iconsWithText: selectedStyle = 2; break;
|
|
|
case Toolbar::iconsWithText: selectedStyle = 2; break;
|
|
|
@@ -754,9 +748,9 @@ private: |
|
|
{
|
|
|
{
|
|
|
switch (styleBox.getSelectedId())
|
|
|
switch (styleBox.getSelectedId())
|
|
|
{
|
|
|
{
|
|
|
case 1: toolbar->setStyle (Toolbar::iconsOnly); break;
|
|
|
|
|
|
case 2: toolbar->setStyle (Toolbar::iconsWithText); break;
|
|
|
|
|
|
case 3: toolbar->setStyle (Toolbar::textOnly); break;
|
|
|
|
|
|
|
|
|
case 1: toolbar.setStyle (Toolbar::iconsOnly); break;
|
|
|
|
|
|
case 2: toolbar.setStyle (Toolbar::iconsWithText); break;
|
|
|
|
|
|
case 3: toolbar.setStyle (Toolbar::textOnly); break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
palette.resized(); // to make it update the styles
|
|
|
palette.resized(); // to make it update the styles
|
|
|
@@ -764,7 +758,7 @@ private: |
|
|
|
|
|
|
|
|
void buttonClicked (Button*) override
|
|
|
void buttonClicked (Button*) override
|
|
|
{
|
|
|
{
|
|
|
toolbar->addDefaultItems (factory);
|
|
|
|
|
|
|
|
|
toolbar.addDefaultItems (factory);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void paint (Graphics& g) override
|
|
|
void paint (Graphics& g) override
|
|
|
@@ -791,7 +785,7 @@ private: |
|
|
|
|
|
|
|
|
private:
|
|
|
private:
|
|
|
ToolbarItemFactory& factory;
|
|
|
ToolbarItemFactory& factory;
|
|
|
Toolbar* const toolbar;
|
|
|
|
|
|
|
|
|
Toolbar& toolbar;
|
|
|
|
|
|
|
|
|
ToolbarItemPalette palette;
|
|
|
ToolbarItemPalette palette;
|
|
|
Label instructions;
|
|
|
Label instructions;
|
|
|
@@ -804,6 +798,6 @@ void Toolbar::showCustomisationDialog (ToolbarItemFactory& factory, const int op |
|
|
{
|
|
|
{
|
|
|
setEditingActive (true);
|
|
|
setEditingActive (true);
|
|
|
|
|
|
|
|
|
(new CustomisationDialog (factory, this, optionFlags))
|
|
|
|
|
|
|
|
|
(new CustomisationDialog (factory, *this, optionFlags))
|
|
|
->enterModalState (true, nullptr, true);
|
|
|
->enterModalState (true, nullptr, true);
|
|
|
}
|
|
|
}
|