29const char*
const Toolbar::toolbarDragDescriptor =
"_toolbarItem_";
35 Spacer (
int itemID,
float sizeToUse,
bool shouldDrawBar)
37 fixedSize (sizeToUse),
38 drawBar (shouldDrawBar)
44 int& preferredSize,
int& minSize,
int& maxSize)
override
48 preferredSize = toolbarThickness * 2;
56 preferredSize = maxSize;
59 preferredSize = maxSize = toolbarThickness / (
drawBar ? 3 : 2);
87 auto thickness = 0.2f;
90 g.fillRect ((
float)
w * 0.1f, (
float)
h * (0.5f - thickness * 0.5f), (
float)
w * 0.8f, (
float)
h * thickness);
92 g.fillRect ((
float)
w * (0.5f - thickness * 0.5f), (
float)
h * 0.1f, (
float)
w * thickness, (
float)
h * 0.8f);
99 auto indentX =
jmin (2, (
w - 3) / 2);
100 auto indentY =
jmin (2, (
h - 3) / 2);
101 g.drawRect (indentX, indentY,
w - indentX * 2,
h - indentY * 2, 1);
105 float x1, y1, x2, y2, x3, y3, x4, y4, hw, hl;
109 x1 = (float)
w * 0.5f;
110 y1 = (float)
h * 0.4f;
112 y2 = (float) indentX * 2.0f;
115 y3 = (float)
h * 0.6f;
119 hw = (float)
w * 0.15f;
120 hl = (float)
w * 0.2f;
124 x1 = (float)
w * 0.4f;
125 y1 = (float)
h * 0.5f;
126 x2 = (float) indentX * 2.0f;
129 x3 = (float)
w * 0.6f;
134 hw = (float)
h * 0.15f;
135 hl = (float)
h * 0.2f;
139 p.addArrow ({ x1, y1, x2, y2 }, 1.5f, hw, hl);
140 p.addArrow ({ x3, y3, x4, y4 }, 1.5f, hw, hl);
162 for (
int i = bar.
items.size(); --
i >= 0;)
164 auto* tc = bar.items.getUnchecked(i);
166 if (tc != nullptr && dynamic_cast<Spacer*> (tc) == nullptr && ! tc->isVisible())
168 oldIndexes.insert (0, i);
169 addAndMakeVisible (tc, 0);
178 if (
owner !=
nullptr)
184 tc->setVisible (
false);
186 owner->addChildComponent (tc, index);
197 const int indent = 8;
206 int preferredSize = 1, minSize = 1, maxSize = 1;
208 if (tc->getToolbarItemSizes (
height,
false, preferredSize, minSize, maxSize))
210 if (
x + preferredSize > preferredWidth &&
x > indent)
216 tc->setBounds (
x,
y, preferredSize,
height);
280 const int insertIndex)
296 items.insert (insertIndex, tc);
322 items.remove (itemIndex);
328 if (
auto* tc =
items.removeAndReturn (itemIndex))
346 return tc->getItemId();
353 return items[itemIndex];
394 const String& savedVersion)
404 for (
auto&
t : tokens)
447 for (
auto* tc :
items)
454 auto* spacer =
dynamic_cast<Spacer*
> (tc);
456 int preferredSize = 1, minSize = 1, maxSize = 1;
459 preferredSize, minSize, maxSize))
462 resizer.
addItem (preferredSize, minSize, maxSize,
463 spacer !=
nullptr ? spacer->getResizeOrder() : 2);
467 tc->isActive =
false;
468 tc->setVisible (
false);
479 const bool itemsOffTheEnd = totalLength >
getLength();
497 int pos = 0, activeIndex = 0;
499 for (
auto* tc :
items)
516 animator.animateComponent (tc, newBounds, 1.0f, 200,
false, 3.0, 0.0);
520 animator.cancelAnimation (tc,
false);
521 tc->setBounds (newBounds);
525 tc->setVisible (pos <= maxLength
526 && ((! tc->isBeingDragged)
551 auto comp = std::make_unique<MissingItemsComponent> (*
this,
getThickness());
552 m.addCustomItem (1, std::move (
comp),
nullptr,
TRANS (
"Additional Items"));
567 if (!
items.contains (tc))
572 palette->replaceComponent (*tc);
588 auto currentIndex =
items.indexOf (tc);
589 auto newIndex = currentIndex;
593 auto dragObjectRight = dragObjectLeft + (
vertical ? tc->getHeight() : tc->getWidth());
599 auto previousPos = animator.getComponentDestination (prev);
601 if (std::abs (dragObjectLeft - (
vertical ? previousPos.getY() : previousPos.getX()))
602 < std::abs (dragObjectRight - (
vertical ? current.getBottom() : current.getRight())))
610 auto nextPos = animator.getComponentDestination (next);
612 if (std::abs (dragObjectLeft - (
vertical ? current.getY() : current.getX()))
613 > std::abs (dragObjectRight - (
vertical ? nextPos.getBottom() : nextPos.getRight())))
619 if (newIndex == currentIndex)
622 items.removeObject (tc,
false);
625 items.insert (newIndex, tc);
637 items.removeObject (tc,
false);
674 toolbar.setEditingActive (
false);
690 auto screenSize =
toolbar.getParentMonitorArea();
691 auto pos =
toolbar.getScreenPosition();
696 if (pos.x > screenSize.getCentreX())
699 pos.x +=
toolbar.getWidth() + gap;
705 if (pos.y > screenSize.getCentreY())
708 pos.y +=
toolbar.getHeight() + gap;
722 instructions ({},
TRANS (
"You can drag the items above and drop them onto a toolbar to add them.")
724 +
TRANS (
"Items on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them.")),
725 defaultButton (
TRANS (
"Restore to default set of items"))
734 styleBox.setEditableText (
false);
740 int selectedStyle = 0;
741 switch (bar.getStyle())
749 styleBox.setSelectedId (selectedStyle);
751 styleBox.onChange = [
this] { updateStyle(); };
754 if ((optionFlags & Toolbar::showResetToDefaultsButton) != 0)
756 addAndMakeVisible (defaultButton);
760 addAndMakeVisible (instructions);
761 instructions.setFont (Font (13.0f));
784 background = dw->getBackgroundColour();
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
Type jmax(const Type a, const Type b)
Definition MathsFunctions.h:48
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_Array.h:56
bool contains(ParameterType elementToLookFor) const
Definition juce_Array.h:400
Definition juce_Colour.h:38
Colour withAlpha(uint8 newAlpha) const noexcept
Definition juce_Colour.cpp:317
JUCE_NODISCARD Colour contrasting(float amount=1.0f) const noexcept
Definition juce_Colour.cpp:491
Definition juce_ComboBox.h:49
Definition juce_Component.h:2287
Definition juce_Component.h:36
int getNumChildComponents() const noexcept
Definition juce_Component.cpp:1643
int getIndexOfChildComponent(const Component *child) const noexcept
Definition juce_Component.cpp:1653
int getHeight() const noexcept
Definition juce_Component.h:274
void addAndMakeVisible(Component *child, int zOrder=-1)
Definition juce_Component.cpp:1554
Component() noexcept
Definition juce_Component.cpp:517
void removeChildComponent(Component *childToRemove)
Definition juce_Component.cpp:1569
Component * getChildComponent(int index) const noexcept
Definition juce_Component.cpp:1648
bool isParentOf(const Component *possibleChild) const noexcept
Definition juce_Component.cpp:1677
void setSize(int newWidth, int newHeight)
Definition juce_Component.cpp:1262
TargetClass * findParentComponentOfClass() const
Definition juce_Component.h:813
void enterModalState(bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
Definition juce_Component.cpp:1764
void setWantsKeyboardFocus(bool wantsFocus) noexcept
Definition juce_Component.cpp:2842
Colour findColour(int colourID, bool inheritFromParent=false) const
Definition juce_Component.cpp:2219
int getWidth() const noexcept
Definition juce_Component.h:271
LookAndFeel & getLookAndFeel() const noexcept
Definition juce_Component.cpp:2173
void setTopLeftPosition(int x, int y)
Definition juce_Component.cpp:1264
void addChildComponent(Component *child, int zOrder=-1)
Definition juce_Component.cpp:1548
const Array< Component * > & getChildren() const noexcept
Definition juce_Component.h:685
virtual void setVisible(bool shouldBeVisible)
Definition juce_Component.cpp:575
static Desktop &JUCE_CALLTYPE getInstance()
Definition juce_Desktop.cpp:50
DialogWindow(const String &name, Colour backgroundColour, bool escapeKeyTriggersCloseButton, bool addToDesktop=true, float desktopScale=1.0f)
Definition juce_DialogWindow.cpp:29
Definition juce_DragAndDropTarget.h:54
Point< int > localPosition
Definition juce_DragAndDropTarget.h:70
WeakReference< Component > sourceComponent
Definition juce_DragAndDropTarget.h:65
var description
Definition juce_DragAndDropTarget.h:62
Definition juce_GraphicsContext.h:45
Definition juce_Label.h:41
Definition juce_MouseEvent.h:39
Definition juce_Path.h:65
constexpr ValueType getX() const noexcept
Definition juce_Point.h:67
constexpr ValueType getY() const noexcept
Definition juce_Point.h:70
Definition juce_Rectangle.h:67
void setBounds(ValueType newX, ValueType newY, ValueType newWidth, ValueType newHeight) noexcept
Definition juce_Rectangle.h:191
void setResizable(bool shouldBeResizable, bool useBottomRightCornerResizer)
Definition juce_ResizableWindow.cpp:245
void setResizeLimits(int newMinimumWidth, int newMinimumHeight, int newMaximumWidth, int newMaximumHeight) noexcept
Definition juce_ResizableWindow.cpp:291
void setContentOwned(Component *newContentComponent, bool resizeToFitWhenContentChangesSize)
Definition juce_ResizableWindow.cpp:114
Definition juce_StretchableObjectResizer.h:47
void addItem(double currentSize, double minSize, double maxSize, int order=0)
Definition juce_StretchableObjectResizer.cpp:32
double getItemSize(int index) const noexcept
Definition juce_StretchableObjectResizer.cpp:48
int getNumItems() const noexcept
Definition juce_StretchableObjectResizer.h:81
void resizeToFit(double targetSize)
Definition juce_StretchableObjectResizer.cpp:54
Definition juce_StringArray.h:35
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Definition juce_StringArray.cpp:329
Definition juce_String.h:53
bool startsWith(StringRef text) const noexcept
Definition juce_String.cpp:1393
String substring(int startIndex, int endIndex) const
Definition juce_String.cpp:1498
Definition juce_TextButton.h:39
UINT_D64 w
Definition inflate.c:942
unsigned * m
Definition inflate.c:1559
struct huft * t
Definition inflate.c:943
int y
Definition inflate.c:1588
int g
Definition inflate.c:1573
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
unsigned x[BMAX+1]
Definition inflate.c:1586
static int int int maxX
Definition pugl.h:1628
#define TRANS(stringLiteral)
Definition juce_LocalisedStrings.h:208
static int JUCE_CDECL comp(const void *a, const void *b)
Definition lsp.c:298
Definition juce_Colours.h:38
Definition carla_juce.cpp:31
int roundToInt(const FloatType value) noexcept
Definition juce_MathsFunctions.h:465
@ group
Definition juce_AccessibilityRole.h:61
#define true
Definition ordinals.h:82
uch * p
Definition crypt.c:594
return c
Definition crypt.c:175
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
typedef int(UZ_EXP MsgFn)()
#define const
Definition zconf.h:137