Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ void PropertiesEditor::addDecoratorProperties()
array.add (new StyleChoicePropertyComponent (builder, IDs::visibility, styleItem, builder.createPropertiesMenuLambda()));
array.add (new StyleTextPropertyComponent (builder, IDs::caption, styleItem));
array.add (new StyleTextPropertyComponent (builder, IDs::captionSize, styleItem));
array.add (new StyleTextPropertyComponent (builder, IDs::captionGap, styleItem));
array.add (new StyleColourPropertyComponent (builder, IDs::captionColour, styleItem));
array.add (new StyleChoicePropertyComponent (builder, IDs::captionPlacement, styleItem, getAllKeyNames (makeJustificationsChoices())));
array.add (new StyleTextPropertyComponent (builder, IDs::tooltip, styleItem));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace IDs
static juce::Identifier captionPlacement { "caption-placement" };
static juce::Identifier captionColour { "caption-color" };
static juce::Identifier captionSize { "caption-size" };
static juce::Identifier captionGap { "caption-gap" };
static juce::Identifier lookAndFeel { "lookAndFeel" };
static juce::Identifier tooltip { "tooltip" };
static juce::Identifier tooltipText { "tooltip-text" };
Expand Down
17 changes: 17 additions & 0 deletions modules/foleys_gui_magic/Layout/foleys_Decorator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,30 @@ Decorator::ClientBounds Decorator::getClientBounds (juce::Rectangle<int> overall
if (justification == juce::Justification::centred)
captionBox = overallBounds;
else if (justification.getOnlyVerticalFlags() & juce::Justification::top)
{
captionBox = box.removeFromTop (captionSize).toNearestInt();
box.removeFromTop (captionGap);
}
else if (justification.getOnlyVerticalFlags() & juce::Justification::bottom)
{
captionBox = box.removeFromBottom (captionSize).toNearestInt();
box.removeFromBottom (captionGap);
}
else
{
juce::Font f (juce::FontOptions().withHeight (captionSize * 0.8f));
auto w = float (f.getStringWidth (caption));

if (justification.getOnlyHorizontalFlags() & juce::Justification::left)
{
captionBox = box.removeFromLeft (w).toNearestInt();
box.removeFromLeft (captionGap);
}
else if (justification.getOnlyHorizontalFlags() & juce::Justification::right)
{
captionBox = box.removeFromRight (w).toNearestInt();
box.removeFromRight (captionGap);
}
}
}

Expand Down Expand Up @@ -182,6 +194,10 @@ void Decorator::configure (MagicGUIBuilder& builder, const juce::ValueTree& node
if (! sizeVar.isVoid())
captionSize = static_cast<float> (sizeVar);

auto gapVar = builder.getStyleProperty (IDs::captionGap, node);
if (! gapVar.isVoid())
captionGap = static_cast<float> (gapVar);

auto placementVar = builder.getStyleProperty (IDs::captionPlacement, node);
if (! placementVar.isVoid() && placementVar.toString().isNotEmpty())
justification = juce::Justification (makeJustificationsChoices()[placementVar.toString()]);
Expand Down Expand Up @@ -220,6 +236,7 @@ void Decorator::reset()
caption.clear();
justification = juce::Justification::centredTop;
captionSize = 20.0f;
captionGap = 0.0f;
captionColour = juce::Colours::silver;

tabCaption.clear();
Expand Down
1 change: 1 addition & 0 deletions modules/foleys_gui_magic/Layout/foleys_Decorator.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class Decorator
juce::String caption;
juce::Justification justification = juce::Justification::centredTop;
float captionSize = 20.0f;
float captionGap = 0.0f;
juce::Colour captionColour = juce::Colours::silver;

juce::String tabCaption;
Expand Down