mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-22 01:34:21 +00:00
Cleaned out some defunct ComponentBuilder code.
This commit is contained in:
parent
00ff36f0e6
commit
e3537ba57a
37 changed files with 34 additions and 608 deletions
|
|
@ -49,25 +49,4 @@ namespace BinaryData
|
|||
// If you provide the name of one of the binary resource variables above, this function will
|
||||
// return the corresponding data and its size (or a null pointer if the name isn't found).
|
||||
const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes) throw();
|
||||
|
||||
//==============================================================================
|
||||
// This class acts as an ImageProvider that will access the BinaryData images
|
||||
class ImageProvider : public juce::ComponentBuilder::ImageProvider
|
||||
{
|
||||
public:
|
||||
ImageProvider() noexcept {}
|
||||
|
||||
juce::Image getImageForIdentifier (const juce::var& imageIdentifier)
|
||||
{
|
||||
int dataSize = 0;
|
||||
const char* const data = getNamedResource (imageIdentifier.toString().toUTF8(), dataSize);
|
||||
|
||||
if (data != nullptr)
|
||||
return juce::ImageCache::getFromMemory (data, dataSize);
|
||||
|
||||
return juce::Image();
|
||||
}
|
||||
|
||||
juce::var getIdentifierForImage (const juce::Image&) { return juce::var(); }
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,34 +193,8 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream&
|
|||
|
||||
header << " // If you provide the name of one of the binary resource variables above, this function will" << newLine
|
||||
<< " // return the corresponding data and its size (or a null pointer if the name isn't found)." << newLine
|
||||
<< " const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes) throw();" << newLine;
|
||||
|
||||
if (containsAnyImages)
|
||||
{
|
||||
header << newLine
|
||||
<< " //==============================================================================" << newLine
|
||||
<< " // This class acts as an ImageProvider that will access the BinaryData images" << newLine
|
||||
<< " class ImageProvider : public juce::ComponentBuilder::ImageProvider" << newLine
|
||||
<< " {" << newLine
|
||||
<< " public:" << newLine
|
||||
<< " ImageProvider() noexcept {}" << newLine
|
||||
<< newLine
|
||||
<< " juce::Image getImageForIdentifier (const juce::var& imageIdentifier)" << newLine
|
||||
<< " {" << newLine
|
||||
<< " int dataSize = 0;" << newLine
|
||||
<< " const char* const data = getNamedResource (imageIdentifier.toString().toUTF8(), dataSize);" << newLine
|
||||
<< newLine
|
||||
<< " if (data != nullptr)" << newLine
|
||||
<< " return juce::ImageCache::getFromMemory (data, dataSize);" << newLine
|
||||
<< newLine
|
||||
<< " return juce::Image();" << newLine
|
||||
<< " }" << newLine
|
||||
<< newLine
|
||||
<< " juce::var getIdentifierForImage (const juce::Image&) { return juce::var(); }" << newLine
|
||||
<< " };" << newLine;
|
||||
}
|
||||
|
||||
header << "}" << newLine;
|
||||
<< " const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes) throw();" << newLine
|
||||
<< "}" << newLine;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ void Project::updateProjectSettings()
|
|||
|
||||
void Project::setMissingDefaultValues()
|
||||
{
|
||||
if (! projectRoot.hasProperty (ComponentBuilder::idProperty))
|
||||
projectRoot.setProperty (ComponentBuilder::idProperty, createAlphaNumericUID(), nullptr);
|
||||
if (! projectRoot.hasProperty (Ids::ID))
|
||||
projectRoot.setProperty (Ids::ID, createAlphaNumericUID(), nullptr);
|
||||
|
||||
// Create main file group if missing
|
||||
if (! projectRoot.getChildWithName (Tags::projectMainGroup).isValid())
|
||||
|
|
@ -431,8 +431,8 @@ Project::Item::Item (const Item& other)
|
|||
|
||||
Project::Item Project::Item::createCopy() { Item i (*this); i.state = i.state.createCopy(); return i; }
|
||||
|
||||
String Project::Item::getID() const { return state [ComponentBuilder::idProperty]; }
|
||||
void Project::Item::setID (const String& newID) { state.setProperty (ComponentBuilder::idProperty, newID, nullptr); }
|
||||
String Project::Item::getID() const { return state [Ids::ID]; }
|
||||
void Project::Item::setID (const String& newID) { state.setProperty (Ids::ID, newID, nullptr); }
|
||||
|
||||
String Project::Item::getImageFileID() const { return "id:" + getID(); }
|
||||
|
||||
|
|
@ -458,7 +458,7 @@ bool Project::Item::isImageFile() const { return isFile() && getFile().hasFi
|
|||
|
||||
Project::Item Project::Item::findItemWithID (const String& targetId) const
|
||||
{
|
||||
if (state [ComponentBuilder::idProperty] == targetId)
|
||||
if (state [Ids::ID] == targetId)
|
||||
return *this;
|
||||
|
||||
if (isGroup())
|
||||
|
|
@ -603,7 +603,7 @@ File Project::Item::determineGroupFolder() const
|
|||
|
||||
void Project::Item::initialiseMissingProperties()
|
||||
{
|
||||
if (! state.hasProperty (ComponentBuilder::idProperty))
|
||||
if (! state.hasProperty (Ids::ID))
|
||||
setID (createAlphaNumericUID());
|
||||
|
||||
if (isFile())
|
||||
|
|
@ -841,7 +841,7 @@ bool Project::isModuleEnabled (const String& moduleID) const
|
|||
ValueTree modules (projectRoot.getChildWithName (Tags::modulesGroup));
|
||||
|
||||
for (int i = 0; i < modules.getNumChildren(); ++i)
|
||||
if (modules.getChild(i) [ComponentBuilder::idProperty] == moduleID)
|
||||
if (modules.getChild(i) [Ids::ID] == moduleID)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
@ -849,13 +849,13 @@ bool Project::isModuleEnabled (const String& moduleID) const
|
|||
|
||||
Value Project::shouldShowAllModuleFilesInProject (const String& moduleID)
|
||||
{
|
||||
return getModulesNode().getChildWithProperty (ComponentBuilder::idProperty, moduleID)
|
||||
return getModulesNode().getChildWithProperty (Ids::ID, moduleID)
|
||||
.getPropertyAsValue (Ids::showAllCode, getUndoManagerFor (getModulesNode()));
|
||||
}
|
||||
|
||||
Value Project::shouldCopyModuleFilesLocally (const String& moduleID)
|
||||
{
|
||||
return getModulesNode().getChildWithProperty (ComponentBuilder::idProperty, moduleID)
|
||||
return getModulesNode().getChildWithProperty (Ids::ID, moduleID)
|
||||
.getPropertyAsValue (Ids::useLocalCopy, getUndoManagerFor (getModulesNode()));
|
||||
}
|
||||
|
||||
|
|
@ -864,7 +864,7 @@ void Project::addModule (const String& moduleID, bool shouldCopyFilesLocally)
|
|||
if (! isModuleEnabled (moduleID))
|
||||
{
|
||||
ValueTree module (Tags::module);
|
||||
module.setProperty (ComponentBuilder::idProperty, moduleID, nullptr);
|
||||
module.setProperty (Ids::ID, moduleID, nullptr);
|
||||
|
||||
ValueTree modules (getModulesNode());
|
||||
modules.addChild (module, -1, getUndoManagerFor (modules));
|
||||
|
|
@ -881,7 +881,7 @@ void Project::removeModule (const String& moduleID)
|
|||
ValueTree modules (getModulesNode());
|
||||
|
||||
for (int i = 0; i < modules.getNumChildren(); ++i)
|
||||
if (modules.getChild(i) [ComponentBuilder::idProperty] == moduleID)
|
||||
if (modules.getChild(i) [Ids::ID] == moduleID)
|
||||
modules.removeChild (i, getUndoManagerFor (modules));
|
||||
}
|
||||
|
||||
|
|
@ -899,7 +899,7 @@ int Project::getNumModules() const
|
|||
|
||||
String Project::getModuleID (int index) const
|
||||
{
|
||||
return projectRoot.getChildWithName (Tags::modulesGroup).getChild (index) [ComponentBuilder::idProperty].toString();
|
||||
return projectRoot.getChildWithName (Tags::modulesGroup).getChild (index) [Ids::ID].toString();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public:
|
|||
String getTitle() const;
|
||||
Value getProjectNameValue() { return getMainGroup().getNameValue(); }
|
||||
String getProjectFilenameRoot() { return File::createLegalFileName (getDocumentTitle()); }
|
||||
String getProjectUID() const { return projectRoot [ComponentBuilder::idProperty]; }
|
||||
String getProjectUID() const { return projectRoot [Ids::ID]; }
|
||||
|
||||
//==============================================================================
|
||||
template <class FileType>
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ namespace Ids
|
|||
DECLARE_ID (androidKeyAliasPass);
|
||||
DECLARE_ID (font);
|
||||
DECLARE_ID (colour);
|
||||
const Identifier ID ("id");
|
||||
const Identifier class_ ("class");
|
||||
|
||||
#undef DECLARE_ID
|
||||
|
|
|
|||
|
|
@ -25,25 +25,4 @@ namespace BinaryData
|
|||
// If you provide the name of one of the binary resource variables above, this function will
|
||||
// return the corresponding data and its size (or a null pointer if the name isn't found).
|
||||
const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes) throw();
|
||||
|
||||
//==============================================================================
|
||||
// This class acts as an ImageProvider that will access the BinaryData images
|
||||
class ImageProvider : public juce::ComponentBuilder::ImageProvider
|
||||
{
|
||||
public:
|
||||
ImageProvider() noexcept {}
|
||||
|
||||
juce::Image getImageForIdentifier (const juce::var& imageIdentifier)
|
||||
{
|
||||
int dataSize = 0;
|
||||
const char* const data = getNamedResource (imageIdentifier.toString().toUTF8(), dataSize);
|
||||
|
||||
if (data != nullptr)
|
||||
return juce::ImageCache::getFromMemory (data, dataSize);
|
||||
|
||||
return juce::Image();
|
||||
}
|
||||
|
||||
juce::var getIdentifierForImage (const juce::Image&) { return juce::var(); }
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,25 +22,4 @@ namespace BinaryData
|
|||
// If you provide the name of one of the binary resource variables above, this function will
|
||||
// return the corresponding data and its size (or a null pointer if the name isn't found).
|
||||
const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes) throw();
|
||||
|
||||
//==============================================================================
|
||||
// This class acts as an ImageProvider that will access the BinaryData images
|
||||
class ImageProvider : public juce::ComponentBuilder::ImageProvider
|
||||
{
|
||||
public:
|
||||
ImageProvider() noexcept {}
|
||||
|
||||
juce::Image getImageForIdentifier (const juce::var& imageIdentifier)
|
||||
{
|
||||
int dataSize = 0;
|
||||
const char* const data = getNamedResource (imageIdentifier.toString().toUTF8(), dataSize);
|
||||
|
||||
if (data != nullptr)
|
||||
return juce::ImageCache::getFromMemory (data, dataSize);
|
||||
|
||||
return juce::Image();
|
||||
}
|
||||
|
||||
juce::var getIdentifierForImage (const juce::Image&) { return juce::var(); }
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -457,7 +457,7 @@ public:
|
|||
void resized()
|
||||
{
|
||||
if (child != nullptr)
|
||||
child->setBounds (0, 0, getWidth(), getHeight());
|
||||
child->setBounds (getLocalBounds());
|
||||
}
|
||||
|
||||
var getObject() { return child->getJavascriptObject(); }
|
||||
|
|
|
|||
|
|
@ -663,29 +663,3 @@ Button::RepeatTimer& Button::getRepeatTimer()
|
|||
|
||||
return *repeatTimer;
|
||||
}
|
||||
|
||||
const Identifier Button::Ids::text ("text");
|
||||
const Identifier Button::Ids::radioGroup ("radioGroup");
|
||||
const Identifier Button::Ids::connectedLeft ("connectedLeft");
|
||||
const Identifier Button::Ids::connectedRight ("connectedRight");
|
||||
const Identifier Button::Ids::connectedTop ("connectedTop");
|
||||
const Identifier Button::Ids::connectedBottom ("connectedBottom");
|
||||
|
||||
void Button::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
setButtonText (state [Ids::text].toString());
|
||||
setRadioGroupId (state [Ids::radioGroup]);
|
||||
setConnectedEdges (getConnectedFlags (state));
|
||||
}
|
||||
|
||||
int Button::getConnectedFlags (const ValueTree& state)
|
||||
{
|
||||
int connected = 0;
|
||||
if (state [Button::Ids::connectedLeft]) connected |= Button::ConnectedOnLeft;
|
||||
if (state [Button::Ids::connectedRight]) connected |= Button::ConnectedOnRight;
|
||||
if (state [Button::Ids::connectedTop]) connected |= Button::ConnectedOnTop;
|
||||
if (state [Button::Ids::connectedBottom]) connected |= Button::ConnectedOnBottom;
|
||||
return connected;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
#include "../keyboard/juce_KeyListener.h"
|
||||
#include "../commands/juce_ApplicationCommandManager.h"
|
||||
#include "../windows/juce_TooltipWindow.h"
|
||||
#include "../layout/juce_ComponentBuilder.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -368,16 +367,6 @@ public:
|
|||
void setState (const ButtonState newState);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier text, radioGroup,
|
||||
connectedLeft, connectedRight, connectedTop, connectedBottom;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
static int getConnectedFlags (const ValueTree& state);
|
||||
|
||||
//==============================================================================
|
||||
// These are deprecated - please use addListener() and removeListener() instead!
|
||||
JUCE_DEPRECATED (void addButtonListener (Listener*));
|
||||
|
|
|
|||
|
|
@ -108,15 +108,3 @@ void HyperlinkButton::paintButton (Graphics& g,
|
|||
justification.getOnlyHorizontalFlags() | Justification::verticallyCentred,
|
||||
true);
|
||||
}
|
||||
|
||||
const Identifier HyperlinkButton::Ids::tagType ("HYPERLINKBUTTON");
|
||||
const Identifier HyperlinkButton::Ids::text ("text");
|
||||
const Identifier HyperlinkButton::Ids::url ("url");
|
||||
|
||||
void HyperlinkButton::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
setButtonText (state [Ids::text].toString());
|
||||
setURL (URL (state [Ids::url].toString()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,14 +93,6 @@ public:
|
|||
*/
|
||||
void changeWidthToFitText();
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType, text, url;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
|
||||
protected:
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
|
|
|
|||
|
|
@ -188,56 +188,3 @@ bool ImageButton::hitTest (int x, int y)
|
|||
&& alphaThreshold < im.getPixelAt (((x - imageBounds.getX()) * im.getWidth()) / imageBounds.getWidth(),
|
||||
((y - imageBounds.getY()) * im.getHeight()) / imageBounds.getHeight()).getAlpha());
|
||||
}
|
||||
|
||||
const Identifier ImageButton::Ids::tagType ("IMAGEBUTTON");
|
||||
const Identifier ImageButton::Ids::upImage ("upImage");
|
||||
const Identifier ImageButton::Ids::overImage ("overImage");
|
||||
const Identifier ImageButton::Ids::downImage ("downImage");
|
||||
const Identifier ImageButton::Ids::upOverlay ("upOverlay");
|
||||
const Identifier ImageButton::Ids::overOverlay ("overOverlay");
|
||||
const Identifier ImageButton::Ids::downOverlay ("downOverlay");
|
||||
const Identifier ImageButton::Ids::upOpacity ("upOpacity");
|
||||
const Identifier ImageButton::Ids::overOpacity ("overOpacity");
|
||||
const Identifier ImageButton::Ids::downOpacity ("downOpacity");
|
||||
|
||||
namespace ImageButtonHelpers
|
||||
{
|
||||
static Colour getColourFromVar (const var& col)
|
||||
{
|
||||
return col.isString() ? Colour::fromString (col.toString())
|
||||
: Colours::transparentBlack;
|
||||
}
|
||||
|
||||
static float getOpacityFromVar (const var& v)
|
||||
{
|
||||
return v.isVoid() ? 1.0f : static_cast<float> (v);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageButton::refreshFromValueTree (const ValueTree& state, ComponentBuilder& builder)
|
||||
{
|
||||
Button::refreshFromValueTree (state, builder);
|
||||
|
||||
const var upImageIdentifier (state [Ids::upImage]),
|
||||
overImageIdentifier (state [Ids::overImage]),
|
||||
downImageIdentifier (state [Ids::downImage]);
|
||||
|
||||
ComponentBuilder::ImageProvider* const imageProvider = builder.getImageProvider();
|
||||
jassert (imageProvider != nullptr || upImageIdentifier.isVoid());
|
||||
|
||||
Image newUpImage, newOverImage, newDownImage;
|
||||
|
||||
if (imageProvider != nullptr)
|
||||
{
|
||||
newUpImage = imageProvider->getImageForIdentifier (upImageIdentifier);
|
||||
newOverImage = imageProvider->getImageForIdentifier (overImageIdentifier);
|
||||
newDownImage = imageProvider->getImageForIdentifier (downImageIdentifier);
|
||||
}
|
||||
|
||||
using namespace ImageButtonHelpers;
|
||||
|
||||
setImages (false, true, true,
|
||||
newUpImage, getOpacityFromVar (state[Ids::upOpacity]), getColourFromVar (state[Ids::upOverlay]),
|
||||
newOverImage, getOpacityFromVar (state[Ids::overOpacity]), getColourFromVar (state[Ids::overOverlay]),
|
||||
newDownImage, getOpacityFromVar (state[Ids::downOpacity]), getColourFromVar (state[Ids::downOverlay]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,16 +127,6 @@ public:
|
|||
*/
|
||||
Image getDownImage() const;
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType, upImage, overImage, downImage,
|
||||
upOverlay, overOverlay, downOverlay,
|
||||
upOpacity, overOpacity, downOpacity;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
|
||||
protected:
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
|
|
|
|||
|
|
@ -67,5 +67,3 @@ void TextButton::changeWidthToFitText (const int newHeight)
|
|||
setSize (getFont().getStringWidth (getButtonText()) + getHeight(),
|
||||
getHeight());
|
||||
}
|
||||
|
||||
const Identifier TextButton::Ids::tagType ("TEXTBUTTON");
|
||||
|
|
|
|||
|
|
@ -89,12 +89,6 @@ public:
|
|||
*/
|
||||
virtual Font getFont();
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType;
|
||||
};
|
||||
|
||||
protected:
|
||||
/** @internal */
|
||||
void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown);
|
||||
|
|
@ -102,7 +96,6 @@ protected:
|
|||
void colourChanged();
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
ToggleButton::ToggleButton()
|
||||
: Button (String::empty)
|
||||
{
|
||||
setClickingTogglesState (true);
|
||||
}
|
||||
|
||||
ToggleButton::ToggleButton (const String& buttonText)
|
||||
: Button (buttonText)
|
||||
{
|
||||
|
|
@ -33,13 +39,9 @@ ToggleButton::~ToggleButton()
|
|||
{
|
||||
}
|
||||
|
||||
void ToggleButton::paintButton (Graphics& g,
|
||||
bool isMouseOverButton,
|
||||
bool isButtonDown)
|
||||
void ToggleButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown)
|
||||
{
|
||||
getLookAndFeel().drawToggleButton (g, *this,
|
||||
isMouseOverButton,
|
||||
isButtonDown);
|
||||
getLookAndFeel().drawToggleButton (g, *this, isMouseOverButton, isButtonDown);
|
||||
}
|
||||
|
||||
void ToggleButton::changeWidthToFitText()
|
||||
|
|
@ -51,5 +53,3 @@ void ToggleButton::colourChanged()
|
|||
{
|
||||
repaint();
|
||||
}
|
||||
|
||||
const Identifier ToggleButton::Ids::tagType ("TOGGLEBUTTON");
|
||||
|
|
|
|||
|
|
@ -42,20 +42,22 @@ class JUCE_API ToggleButton : public Button
|
|||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Creates a ToggleButton. */
|
||||
ToggleButton();
|
||||
|
||||
/** Creates a ToggleButton.
|
||||
|
||||
@param buttonText the text to put in the button (the component's name is also
|
||||
initially set to this string, but these can be changed later
|
||||
using the setName() and setButtonText() methods)
|
||||
*/
|
||||
explicit ToggleButton (const String& buttonText = String::empty);
|
||||
explicit ToggleButton (const String& buttonText);
|
||||
|
||||
/** Destructor. */
|
||||
~ToggleButton();
|
||||
|
||||
//==============================================================================
|
||||
/** Resizes the button to fit neatly around its current text.
|
||||
|
||||
The button's height won't be affected, only its width.
|
||||
*/
|
||||
void changeWidthToFitText();
|
||||
|
|
@ -73,23 +75,14 @@ public:
|
|||
textColourId = 0x1006501 /**< The colour to use for the button's text. */
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType;
|
||||
};
|
||||
|
||||
protected:
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paintButton (Graphics& g,
|
||||
bool isMouseOverButton,
|
||||
bool isButtonDown);
|
||||
|
||||
void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown);
|
||||
/** @internal */
|
||||
void colourChanged();
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleButton);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,6 @@ namespace ComponentBuilderHelpers
|
|||
|
||||
//=============================================================================
|
||||
const Identifier ComponentBuilder::idProperty ("id");
|
||||
const Identifier ComponentBuilder::positionID ("position");
|
||||
|
||||
ComponentBuilder::ComponentBuilder()
|
||||
: imageProvider (nullptr)
|
||||
|
|
@ -242,18 +241,6 @@ ComponentBuilder::TypeHandler* ComponentBuilder::getHandler (const int index) co
|
|||
void ComponentBuilder::registerStandardComponentTypes()
|
||||
{
|
||||
Drawable::registerDrawableTypeHandlers (*this);
|
||||
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <ComboBox>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <Slider>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <Label>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <Slider>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <TextEditor>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <GroupComponent>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <TextButton>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <ToggleButton>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <ImageButton>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <ImageComponent>());
|
||||
registerTypeHandler (new ComponentBuilderHelpers::StandardTypeHandler <HyperlinkButton>());
|
||||
}
|
||||
|
||||
void ComponentBuilder::setImageProvider (ImageProvider* newImageProvider) noexcept
|
||||
|
|
@ -321,12 +308,11 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree
|
|||
OwnedArray<Component> existingComponents;
|
||||
existingComponents.ensureStorageAllocated (numExistingChildComps);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < numExistingChildComps; ++i)
|
||||
for (int i = 0; i < numExistingChildComps; ++i)
|
||||
existingComponents.add (parent.getChildComponent (i));
|
||||
|
||||
const int newNumChildren = children.getNumChildren();
|
||||
for (i = 0; i < newNumChildren; ++i)
|
||||
for (int i = 0; i < newNumChildren; ++i)
|
||||
{
|
||||
const ValueTree childState (children.getChild (i));
|
||||
Component* c = removeComponentWithID (existingComponents, getStateId (childState));
|
||||
|
|
@ -362,80 +348,3 @@ static void updateMarkers (MarkerList* const list, const ValueTree& state)
|
|||
if (list != nullptr)
|
||||
MarkerList::ValueTreeWrapper (state).applyTo (*list);
|
||||
}
|
||||
|
||||
void ComponentBuilder::initialiseRecursively (Component& comp, const ValueTree& state)
|
||||
{
|
||||
refreshBasicComponentProperties (comp, state);
|
||||
|
||||
updateMarkers (comp.getMarkers (true), state.getChildWithName ("MARKERS_X"));
|
||||
updateMarkers (comp.getMarkers (false), state.getChildWithName ("MARKERS_Y"));
|
||||
|
||||
const ValueTree childList (state.getChildWithName ("COMPONENTS"));
|
||||
|
||||
if (childList.isValid())
|
||||
{
|
||||
updateChildComponents (comp, childList);
|
||||
|
||||
for (int i = 0; i < childList.getNumChildren(); ++i)
|
||||
{
|
||||
const ValueTree childState (childList.getChild(i));
|
||||
Component* const c = ComponentBuilderHelpers::findComponentWithID (comp, ComponentBuilderHelpers::getStateId (childState));
|
||||
|
||||
if (c != nullptr)
|
||||
{
|
||||
ComponentBuilder::TypeHandler* const type = getHandlerForState (childState);
|
||||
|
||||
if (type != nullptr)
|
||||
type->updateComponentFromState (c, childState);
|
||||
else
|
||||
initialiseRecursively (*c, childState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentBuilder::initialiseFromValueTree (Component& comp,
|
||||
const ValueTree& state,
|
||||
ImageProvider* const imageProvider)
|
||||
{
|
||||
ComponentBuilder builder;
|
||||
builder.setImageProvider (imageProvider);
|
||||
builder.registerStandardComponentTypes();
|
||||
builder.initialiseRecursively (comp, state);
|
||||
}
|
||||
|
||||
RelativeRectangle ComponentBuilder::getComponentBounds (const ValueTree& state)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RelativeRectangle (state [positionID].toString());
|
||||
}
|
||||
catch (Expression::ParseError&)
|
||||
{}
|
||||
|
||||
return RelativeRectangle();
|
||||
}
|
||||
|
||||
void ComponentBuilder::refreshBasicComponentProperties (Component& comp, const ValueTree& state)
|
||||
{
|
||||
static const Identifier focusOrderID ("focusOrder");
|
||||
static const Identifier tooltipID ("tooltip");
|
||||
static const Identifier nameID ("name");
|
||||
|
||||
comp.setName (state [nameID].toString());
|
||||
|
||||
if (state.hasProperty (positionID))
|
||||
getComponentBounds (state).applyToComponent (comp);
|
||||
|
||||
comp.setExplicitFocusOrder (state [focusOrderID]);
|
||||
const var tip (state [tooltipID]);
|
||||
|
||||
if (! tip.isVoid())
|
||||
{
|
||||
SettableTooltipClient* tooltipClient = dynamic_cast <SettableTooltipClient*> (&comp);
|
||||
if (tooltipClient != nullptr)
|
||||
tooltipClient->setTooltip (tip.toString());
|
||||
}
|
||||
|
||||
ComponentBuilderHelpers::updateComponentColours (comp, state.getChildWithName ("COLOURS"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,18 +227,6 @@ public:
|
|||
*/
|
||||
static const Identifier idProperty;
|
||||
|
||||
/**
|
||||
*/
|
||||
static void initialiseFromValueTree (Component& component,
|
||||
const ValueTree& state,
|
||||
ImageProvider* imageProvider);
|
||||
|
||||
//=============================================================================
|
||||
/** @internal */
|
||||
static void refreshBasicComponentProperties (Component&, const ValueTree&);
|
||||
/** @internal */
|
||||
static RelativeRectangle getComponentBounds (const ValueTree&);
|
||||
|
||||
private:
|
||||
//=============================================================================
|
||||
OwnedArray <TypeHandler> types;
|
||||
|
|
@ -254,9 +242,6 @@ private:
|
|||
void valueTreeChildOrderChanged (ValueTree&);
|
||||
void valueTreeParentChanged (ValueTree&);
|
||||
|
||||
static const Identifier positionID;
|
||||
void initialiseRecursively (Component&, const ValueTree&);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentBuilder);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -78,15 +78,3 @@ void GroupComponent::colourChanged()
|
|||
{
|
||||
repaint();
|
||||
}
|
||||
|
||||
const Identifier GroupComponent::Ids::tagType ("GROUPCOMPONENT");
|
||||
const Identifier GroupComponent::Ids::text ("text");
|
||||
const Identifier GroupComponent::Ids::justification ("justification");
|
||||
|
||||
void GroupComponent::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
setText (state [Ids::text].toString());
|
||||
setTextLabelPosition (static_cast <int> (state [Ids::justification]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,14 +85,6 @@ public:
|
|||
textColourId = 0x1005410 /**< The colour to use to draw the text label. */
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType, text, justification;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics& g);
|
||||
|
|
|
|||
|
|
@ -424,16 +424,3 @@ bool Viewport::keyPressed (const KeyPress& key)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const Identifier Viewport::Ids::showScrollBarV ("showScrollBarV");
|
||||
const Identifier Viewport::Ids::showScrollBarH ("showScrollBarH");
|
||||
const Identifier Viewport::Ids::scrollBarWidth ("scrollBarWidth");
|
||||
|
||||
void Viewport::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
setScrollBarsShown (state [Ids::showScrollBarV], state [Ids::showScrollBarH]);
|
||||
setScrollBarThickness (state [Ids::scrollBarWidth]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,14 +236,6 @@ public:
|
|||
ScrollBar* getHorizontalScrollBar() noexcept { return &horizontalScrollBar; }
|
||||
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier showScrollBarV, showScrollBarH, scrollBarWidth;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void resized();
|
||||
|
|
|
|||
|
|
@ -596,39 +596,3 @@ void ComboBox::handleAsyncUpdate()
|
|||
Component::BailOutChecker checker (this);
|
||||
listeners.callChecked (checker, &ComboBoxListener::comboBoxChanged, this); // (can't use ComboBox::Listener due to idiotic VC2005 bug)
|
||||
}
|
||||
|
||||
const Identifier ComboBox::Ids::tagType ("COMBOBOX");
|
||||
const Identifier ComboBox::Ids::items ("items");
|
||||
const Identifier ComboBox::Ids::editable ("editable");
|
||||
const Identifier ComboBox::Ids::textJustification ("textJustification");
|
||||
const Identifier ComboBox::Ids::unselectedText ("unselectedText");
|
||||
const Identifier ComboBox::Ids::noItemsText ("noItemsText");
|
||||
|
||||
void ComboBox::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
{
|
||||
StringArray items;
|
||||
items.addLines (state [Ids::items].toString());
|
||||
items.removeEmptyStrings (true);
|
||||
|
||||
StringArray existingItems;
|
||||
|
||||
for (int i = 0; i < getNumItems(); ++i)
|
||||
existingItems.add (getItemText (i));
|
||||
|
||||
if (existingItems != items)
|
||||
{
|
||||
clear();
|
||||
|
||||
for (int i = 0; i < items.size(); ++i)
|
||||
addItem (items[i], i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
setEditableText (state [Ids::editable]);
|
||||
setJustificationType ((int) state [Ids::textJustification]);
|
||||
setTextWhenNothingSelected (state [Ids::unselectedText].toString());
|
||||
setTextWhenNoChoicesAvailable (state [Ids::noItemsText].toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -338,14 +338,6 @@ public:
|
|||
arrowColourId = 0x1000e00, /**< The colour for the arrow shape that pops up the menu */
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType, items, editable, textJustification, unselectedText, noItemsText;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void labelTextChanged (Label*);
|
||||
|
|
|
|||
|
|
@ -76,28 +76,3 @@ void ImageComponent::paint (Graphics& g)
|
|||
g.setOpacity (1.0f);
|
||||
g.drawImageWithin (image, 0, 0, getWidth(), getHeight(), placement, false);
|
||||
}
|
||||
|
||||
const Identifier ImageComponent::Ids::tagType ("IMAGECOMPONENT");
|
||||
const Identifier ImageComponent::Ids::image ("image");
|
||||
const Identifier ImageComponent::Ids::placement ("placement");
|
||||
|
||||
void ImageComponent::refreshFromValueTree (const ValueTree& state, ComponentBuilder& builder)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
Image newImage;
|
||||
const var imageIdentifier (state [Ids::image]);
|
||||
|
||||
ComponentBuilder::ImageProvider* const imageProvider = builder.getImageProvider();
|
||||
jassert (imageProvider != nullptr || imageIdentifier.isVoid());
|
||||
|
||||
if (imageProvider != nullptr)
|
||||
newImage = imageProvider->getImageForIdentifier (imageIdentifier);
|
||||
|
||||
setImage (newImage, getPlacement (state));
|
||||
}
|
||||
|
||||
RectanglePlacement ImageComponent::getPlacement (const ValueTree& state)
|
||||
{
|
||||
return RectanglePlacement (static_cast <int> (state [Ids::placement]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,15 +67,6 @@ public:
|
|||
/** Returns the current image placement. */
|
||||
const RectanglePlacement getImagePlacement() const;
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType, image, placement;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
static RectanglePlacement getPlacement (const ValueTree& state);
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics& g);
|
||||
|
|
|
|||
|
|
@ -448,22 +448,3 @@ void Label::textEditorFocusLost (TextEditor& ed)
|
|||
{
|
||||
textEditorTextChanged (ed);
|
||||
}
|
||||
|
||||
|
||||
const Identifier Label::Ids::tagType ("LABEL");
|
||||
const Identifier Label::Ids::text ("text");
|
||||
const Identifier Label::Ids::font ("font");
|
||||
const Identifier Label::Ids::editMode ("editMode");
|
||||
const Identifier Label::Ids::justification ("justification");
|
||||
const Identifier Label::Ids::focusLossDiscardsChanges ("focusLossDiscardsChanges");
|
||||
|
||||
void Label::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
setText (state [Ids::text].toString(), false);
|
||||
setFont (Font::fromString (state [Ids::font]));
|
||||
const int editMode = static_cast <int> (state [Ids::editMode]);
|
||||
setEditable (editMode == 2, editMode == 3, static_cast <bool> (state [Ids::focusLossDiscardsChanges]));
|
||||
setJustificationType (static_cast <int> (state [Ids::justification]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,14 +253,6 @@ public:
|
|||
/** Returns true if the editor is currently focused and active. */
|
||||
bool isBeingEdited() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType, text, font, editMode, justification, focusLossDiscardsChanges;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
|
||||
protected:
|
||||
//==============================================================================
|
||||
/** Creates the TextEditor component that will be used when the user has clicked on the label.
|
||||
|
|
|
|||
|
|
@ -928,19 +928,6 @@ void ListBox::startDragAndDrop (const MouseEvent& e, const var& dragDescription,
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const Identifier ListBox::Ids::rowHeight ("rowHeight");
|
||||
const Identifier ListBox::Ids::borderThickness ("borderThickness");
|
||||
|
||||
void ListBox::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
setRowHeight (state.getProperty (Ids::rowHeight, defaultListRowHeight));
|
||||
setOutlineThickness (state.getProperty (Ids::borderThickness, 0));
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
Component* ListBoxModel::refreshComponentForRow (int, bool, Component* existingComponentToUpdate)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -525,14 +525,6 @@ public:
|
|||
*/
|
||||
Viewport* getViewport() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier rowHeight, borderThickness;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
bool keyPressed (const KeyPress&);
|
||||
|
|
|
|||
|
|
@ -1566,33 +1566,3 @@ void Slider::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel
|
|||
|
||||
void SliderListener::sliderDragStarted (Slider*) {} // (can't write Slider::Listener due to idiotic VC2005 bug)
|
||||
void SliderListener::sliderDragEnded (Slider*) {}
|
||||
|
||||
//==============================================================================
|
||||
const Identifier Slider::Ids::tagType ("SLIDER");
|
||||
const Identifier Slider::Ids::min ("min");
|
||||
const Identifier Slider::Ids::max ("max");
|
||||
const Identifier Slider::Ids::interval ("interval");
|
||||
const Identifier Slider::Ids::type ("type");
|
||||
const Identifier Slider::Ids::editable ("editable");
|
||||
const Identifier Slider::Ids::textBoxPos ("textBoxPos");
|
||||
const Identifier Slider::Ids::textBoxWidth ("textBoxWidth");
|
||||
const Identifier Slider::Ids::textBoxHeight ("textBoxHeight");
|
||||
const Identifier Slider::Ids::skew ("skew");
|
||||
|
||||
void Slider::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
setRange (static_cast <double> (state [Ids::min]),
|
||||
static_cast <double> (state [Ids::max]),
|
||||
static_cast <double> (state [Ids::interval]));
|
||||
|
||||
setSliderStyle ((SliderStyle) static_cast <int> (state [Ids::type]));
|
||||
|
||||
setTextBoxStyle ((TextEntryBoxPosition) static_cast <int> (state [Ids::textBoxPos]),
|
||||
! static_cast <bool> (state [Ids::editable]),
|
||||
static_cast <int> (state [Ids::textBoxWidth]),
|
||||
static_cast <int> (state [Ids::textBoxHeight]));
|
||||
|
||||
setSkewFactor (static_cast <double> (state [Ids::skew]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -780,15 +780,6 @@ public:
|
|||
textBoxOutlineColourId = 0x1001700 /**< The colour to use for a border around the text-editor box. */
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType, min, max, interval, type, editable,
|
||||
textBoxPos, textBoxWidth, textBoxHeight, skew;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
|
||||
protected:
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
|
|
|
|||
|
|
@ -2611,32 +2611,3 @@ void TextEditor::Listener::textEditorTextChanged (TextEditor&) {}
|
|||
void TextEditor::Listener::textEditorReturnKeyPressed (TextEditor&) {}
|
||||
void TextEditor::Listener::textEditorEscapeKeyPressed (TextEditor&) {}
|
||||
void TextEditor::Listener::textEditorFocusLost (TextEditor&) {}
|
||||
|
||||
//==============================================================================
|
||||
const Identifier TextEditor::Ids::tagType ("TEXTEDITOR");
|
||||
const Identifier TextEditor::Ids::text ("text");
|
||||
const Identifier TextEditor::Ids::font ("font");
|
||||
const Identifier TextEditor::Ids::mode ("mode");
|
||||
const Identifier TextEditor::Ids::readOnly ("readOnly");
|
||||
const Identifier TextEditor::Ids::scrollbarsShown ("scrollbarsShown");
|
||||
const Identifier TextEditor::Ids::caretVisible ("caretVisible");
|
||||
const Identifier TextEditor::Ids::popupMenuEnabled ("popupMenuEnabled");
|
||||
|
||||
void TextEditor::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
|
||||
{
|
||||
ComponentBuilder::refreshBasicComponentProperties (*this, state);
|
||||
|
||||
setReadOnly (state [Ids::readOnly]);
|
||||
setScrollbarsShown (state [Ids::scrollbarsShown]);
|
||||
setCaretVisible (state [Ids::caretVisible]);
|
||||
setPopupMenuEnabled (state [Ids::popupMenuEnabled]);
|
||||
const int mode = state [Ids::mode];
|
||||
setMultiLine (mode > 1, true);
|
||||
setReturnKeyStartsNewLine (mode != 3);
|
||||
|
||||
const Font font (Font::fromString (state [Ids::font]));
|
||||
if (getFont() != font)
|
||||
applyFontToAllText (font);
|
||||
|
||||
setText (state [Ids::text].toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -534,15 +534,6 @@ public:
|
|||
*/
|
||||
virtual void performPopupMenuAction (int menuItemID);
|
||||
|
||||
//==============================================================================
|
||||
struct Ids
|
||||
{
|
||||
static const Identifier tagType, text, font, mode, readOnly, scrollbarsShown,
|
||||
caretVisible, popupMenuEnabled;
|
||||
};
|
||||
|
||||
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics& g);
|
||||
|
|
|
|||
|
|
@ -501,7 +501,7 @@ void ResizableWindow::updateLastPos()
|
|||
void ResizableWindow::parentSizeChanged()
|
||||
{
|
||||
if (isFullScreen() && getParentComponent() != nullptr)
|
||||
setBounds (0, 0, getParentWidth(), getParentHeight());
|
||||
setBounds (getParentComponent()->getLocalBounds());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue