mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Ensured that bubble messages are also transformed in the ComponentTransforms demo
This commit is contained in:
parent
9343e9b279
commit
9dfaca4035
2 changed files with 51 additions and 35 deletions
|
|
@ -53,7 +53,7 @@ class ComponentTransformsDemo : public Component
|
||||||
public:
|
public:
|
||||||
ComponentTransformsDemo()
|
ComponentTransformsDemo()
|
||||||
{
|
{
|
||||||
content.reset (new WidgetsDemo());
|
content.reset (new WidgetsDemo (true));
|
||||||
addAndMakeVisible (content.get());
|
addAndMakeVisible (content.get());
|
||||||
content->setSize (750, 500);
|
content->setSize (750, 500);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,26 +50,8 @@
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
static void showBubbleMessage (Component& targetComponent, const String& textToShow,
|
static void showBubbleMessage (Component& targetComponent, const String& textToShow,
|
||||||
std::unique_ptr<BubbleMessageComponent>& bmc)
|
std::unique_ptr<BubbleMessageComponent>& bmc,
|
||||||
{
|
bool isRunningComponentTransformDemo);
|
||||||
bmc.reset (new BubbleMessageComponent());
|
|
||||||
|
|
||||||
if (Desktop::canUseSemiTransparentWindows())
|
|
||||||
{
|
|
||||||
bmc->setAlwaysOnTop (true);
|
|
||||||
bmc->addToDesktop (0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
targetComponent.getTopLevelComponent()->addChildComponent (bmc.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
AttributedString text (textToShow);
|
|
||||||
text.setJustification (Justification::centred);
|
|
||||||
text.setColour (targetComponent.findColour (TextButton::textColourOffId));
|
|
||||||
|
|
||||||
bmc->showAt (&targetComponent, text, 2000, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** To demonstrate how sliders can have custom snapping applied to their values,
|
/** To demonstrate how sliders can have custom snapping applied to their values,
|
||||||
|
|
@ -272,7 +254,7 @@ private:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
struct ButtonsPage : public Component
|
struct ButtonsPage : public Component
|
||||||
{
|
{
|
||||||
ButtonsPage()
|
ButtonsPage (bool isRunningComponentTransformDemo)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto* group = addToList (new GroupComponent ("group", "Radio buttons"));
|
auto* group = addToList (new GroupComponent ("group", "Radio buttons"));
|
||||||
|
|
@ -374,14 +356,15 @@ struct ButtonsPage : public Component
|
||||||
down.setImage (getImageFromAssets ("juce_icon.png"));
|
down.setImage (getImageFromAssets ("juce_icon.png"));
|
||||||
down.setOverlayColour (Colours::black.withAlpha (0.3f));
|
down.setOverlayColour (Colours::black.withAlpha (0.3f));
|
||||||
|
|
||||||
auto popupMessageCallback = [this]
|
auto popupMessageCallback = [this, isRunningComponentTransformDemo]
|
||||||
{
|
{
|
||||||
if (auto* focused = Component::getCurrentlyFocusedComponent())
|
if (auto* focused = Component::getCurrentlyFocusedComponent())
|
||||||
showBubbleMessage (*focused,
|
showBubbleMessage (*focused,
|
||||||
"This is a demo of the BubbleMessageComponent, which lets you pop up a message pointing "
|
"This is a demo of the BubbleMessageComponent, which lets you pop up a message pointing "
|
||||||
"at a component or somewhere on the screen.\n\n"
|
"at a component or somewhere on the screen.\n\n"
|
||||||
"The message bubbles will disappear after a timeout period, or when the mouse is clicked.",
|
"The message bubbles will disappear after a timeout period, or when the mouse is clicked.",
|
||||||
this->bubbleMessage);
|
this->bubbleMessage,
|
||||||
|
isRunningComponentTransformDemo);
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -1277,19 +1260,20 @@ private:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
struct DemoTabbedComponent : public TabbedComponent
|
struct DemoTabbedComponent : public TabbedComponent
|
||||||
{
|
{
|
||||||
DemoTabbedComponent()
|
DemoTabbedComponent (bool isRunningComponenTransformsDemo)
|
||||||
: TabbedComponent (TabbedButtonBar::TabsAtTop)
|
: TabbedComponent (TabbedButtonBar::TabsAtTop)
|
||||||
{
|
{
|
||||||
auto colour = findColour (ResizableWindow::backgroundColourId);
|
auto colour = findColour (ResizableWindow::backgroundColourId);
|
||||||
|
|
||||||
addTab ("Buttons", colour, new ButtonsPage(), true);
|
addTab ("Buttons", colour, new ButtonsPage (isRunningComponenTransformsDemo), true);
|
||||||
addTab ("Sliders", colour, new SlidersPage(), true);
|
addTab ("Sliders", colour, new SlidersPage(), true);
|
||||||
addTab ("Toolbars", colour, new ToolbarDemoComp(), true);
|
addTab ("Toolbars", colour, new ToolbarDemoComp(), true);
|
||||||
addTab ("Misc", colour, new MiscPage(), true);
|
addTab ("Misc", colour, new MiscPage(), true);
|
||||||
addTab ("Tables", colour, new TableDemoComponent(), true);
|
addTab ("Tables", colour, new TableDemoComponent(), true);
|
||||||
addTab ("Drag & Drop", colour, new DragAndDropDemo(), true);
|
addTab ("Drag & Drop", colour, new DragAndDropDemo(), true);
|
||||||
|
|
||||||
getTabbedButtonBar().getTabButton (5)->setExtraComponent (new CustomTabButton(), TabBarButton::afterText);
|
getTabbedButtonBar().getTabButton (5)->setExtraComponent (new CustomTabButton (isRunningComponenTransformsDemo),
|
||||||
|
TabBarButton::afterText);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a small star button that is put inside one of the tabs. You can
|
// This is a small star button that is put inside one of the tabs. You can
|
||||||
|
|
@ -1297,7 +1281,8 @@ struct DemoTabbedComponent : public TabbedComponent
|
||||||
class CustomTabButton : public Component
|
class CustomTabButton : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CustomTabButton()
|
CustomTabButton (bool isRunningComponenTransformsDemo)
|
||||||
|
: runningComponenTransformsDemo (isRunningComponenTransformsDemo)
|
||||||
{
|
{
|
||||||
setSize (20, 20);
|
setSize (20, 20);
|
||||||
}
|
}
|
||||||
|
|
@ -1318,9 +1303,11 @@ struct DemoTabbedComponent : public TabbedComponent
|
||||||
"\n"
|
"\n"
|
||||||
"You can use these to implement things like close-buttons "
|
"You can use these to implement things like close-buttons "
|
||||||
"or status displays for your tabs.",
|
"or status displays for your tabs.",
|
||||||
bubbleMessage);
|
bubbleMessage,
|
||||||
|
runningComponenTransformsDemo);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
bool runningComponenTransformsDemo;
|
||||||
std::unique_ptr<BubbleMessageComponent> bubbleMessage;
|
std::unique_ptr<BubbleMessageComponent> bubbleMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1330,7 +1317,8 @@ struct DemoTabbedComponent : public TabbedComponent
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
struct WidgetsDemo : public Component
|
struct WidgetsDemo : public Component
|
||||||
{
|
{
|
||||||
WidgetsDemo()
|
WidgetsDemo (bool isRunningComponenTransformsDemo = false)
|
||||||
|
: tabs (isRunningComponenTransformsDemo)
|
||||||
{
|
{
|
||||||
setOpaque (true);
|
setOpaque (true);
|
||||||
addAndMakeVisible (tabs);
|
addAndMakeVisible (tabs);
|
||||||
|
|
@ -1352,3 +1340,31 @@ struct WidgetsDemo : public Component
|
||||||
|
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WidgetsDemo)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WidgetsDemo)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
void showBubbleMessage (Component& targetComponent, const String& textToShow,
|
||||||
|
std::unique_ptr<BubbleMessageComponent>& bmc,
|
||||||
|
bool isRunningComponentTransformDemo)
|
||||||
|
{
|
||||||
|
bmc.reset (new BubbleMessageComponent());
|
||||||
|
|
||||||
|
if (isRunningComponentTransformDemo)
|
||||||
|
{
|
||||||
|
targetComponent.findParentComponentOfClass<WidgetsDemo>()->addChildComponent (bmc.get());
|
||||||
|
}
|
||||||
|
else if (Desktop::canUseSemiTransparentWindows())
|
||||||
|
{
|
||||||
|
bmc->setAlwaysOnTop (true);
|
||||||
|
bmc->addToDesktop (0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
targetComponent.getTopLevelComponent()->addChildComponent (bmc.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
AttributedString text (textToShow);
|
||||||
|
text.setJustification (Justification::centred);
|
||||||
|
text.setColour (targetComponent.findColour (TextButton::textColourOffId));
|
||||||
|
|
||||||
|
bmc->showAt (&targetComponent, text, 2000, true, false);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue