Browse Source

Code clean-ups. Jucer development.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
1751beed57
100 changed files with 2039 additions and 1628 deletions
  1. +12
    -0
      extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp
  2. +2
    -2
      extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h
  3. +28
    -23
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_ComboBox.h
  4. +328
    -61
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_ComponentTypeManager.cpp
  5. +108
    -60
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_ComponentTypeManager.h
  6. +19
    -9
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_GenericComponent.h
  7. +19
    -14
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_GroupComponent.h
  8. +14
    -4
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_JucerComponent.h
  9. +26
    -22
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_Label.h
  10. +37
    -32
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_Slider.h
  11. +10
    -5
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_TabbedComponent.h
  12. +31
    -26
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_TextButton.h
  13. +30
    -25
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_TextEditor.h
  14. +19
    -14
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_ToggleButton.h
  15. +18
    -12
      extras/Jucer (experimental)/Source/model/Component/Types/jucer_Viewport.h
  16. +34
    -19
      extras/Jucer (experimental)/Source/model/Component/jucer_CodeGenerator.cpp
  17. +6
    -3
      extras/Jucer (experimental)/Source/model/Component/jucer_CodeGenerator.h
  18. +36
    -21
      extras/Jucer (experimental)/Source/model/Component/jucer_ComponentDocument.cpp
  19. +1
    -0
      extras/Jucer (experimental)/Source/model/Component/jucer_ComponentDocument.h
  20. +1
    -1
      extras/Jucer (experimental)/Source/model/Drawable/jucer_DrawableDocument.cpp
  21. +2
    -2
      extras/Jucer (experimental)/Source/model/Project/jucer_NewFileWizard.cpp
  22. +3
    -3
      extras/Jucer (experimental)/Source/model/Project/jucer_Project.cpp
  23. +1
    -1
      extras/Jucer (experimental)/Source/model/Project/jucer_Project.h
  24. +18
    -18
      extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_MSVC.h
  25. +2
    -2
      extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_Make.h
  26. +2
    -2
      extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_XCode.h
  27. +2
    -2
      extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExporter.cpp
  28. +7
    -7
      extras/Jucer (experimental)/Source/model/Project/jucer_ProjectSaver.h
  29. +28
    -28
      extras/Jucer (experimental)/Source/model/Project/jucer_ProjectWizard.cpp
  30. +13
    -86
      extras/Jucer (experimental)/Source/model/Project/jucer_ResourceFile.cpp
  31. +10
    -0
      extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.cpp
  32. +2
    -0
      extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.h
  33. +36
    -5
      extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h
  34. +30
    -5
      extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorToolbar.h
  35. +2
    -2
      extras/Jucer (experimental)/Source/ui/Editor Base/jucer_EditorCanvas.cpp
  36. +3
    -2
      extras/Jucer (experimental)/Source/ui/Editor Base/jucer_EditorPanel.h
  37. +111
    -86
      extras/Jucer (experimental)/Source/utility/jucer_ColourEditorComponent.h
  38. +27
    -10
      extras/Jucer (experimental)/Source/utility/jucer_Coordinate.cpp
  39. +6
    -3
      extras/Jucer (experimental)/Source/utility/jucer_Coordinate.h
  40. +6
    -2
      extras/Jucer (experimental)/Source/utility/jucer_MarkerListBase.h
  41. +2
    -2
      extras/Jucer (experimental)/Source/utility/jucer_RelativePath.h
  42. +3
    -3
      extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.cpp
  43. +417
    -455
      extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp
  44. +43
    -54
      extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.h
  45. +255
    -286
      juce_amalgamated.cpp
  46. +51
    -34
      juce_amalgamated.h
  47. +2
    -2
      src/application/juce_Application.cpp
  48. +1
    -1
      src/audio/audio_file_formats/juce_AiffAudioFormat.cpp
  49. +1
    -1
      src/audio/audio_file_formats/juce_AudioFormatManager.cpp
  50. +1
    -1
      src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp
  51. +1
    -1
      src/audio/devices/juce_AudioDeviceManager.cpp
  52. +2
    -2
      src/audio/devices/juce_AudioIODevice.cpp
  53. +2
    -2
      src/audio/dsp/juce_AudioDataConverters.cpp
  54. +1
    -1
      src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm
  55. +1
    -1
      src/audio/plugins/formats/juce_VSTPluginFormat.cpp
  56. +1
    -1
      src/audio/processors/juce_AudioProcessorGraph.cpp
  57. +1
    -1
      src/containers/juce_Array.h
  58. +3
    -3
      src/containers/juce_BitArray.cpp
  59. +1
    -1
      src/containers/juce_OwnedArray.h
  60. +1
    -1
      src/containers/juce_ReferenceCountedArray.h
  61. +1
    -1
      src/containers/juce_SortedSet.h
  62. +2
    -2
      src/containers/juce_ValueTree.cpp
  63. +3
    -3
      src/core/juce_PlatformDefs.h
  64. +1
    -1
      src/core/juce_PlatformUtilities.h
  65. +1
    -1
      src/cryptography/juce_Primes.cpp
  66. +1
    -1
      src/cryptography/juce_RSAKey.cpp
  67. +1
    -1
      src/gui/components/controls/juce_ListBox.cpp
  68. +1
    -1
      src/gui/components/controls/juce_Slider.cpp
  69. +1
    -1
      src/gui/components/controls/juce_TextEditor.cpp
  70. +2
    -2
      src/gui/components/controls/juce_TreeView.cpp
  71. +2
    -2
      src/gui/components/juce_Component.cpp
  72. +2
    -2
      src/gui/components/juce_Desktop.h
  73. +1
    -1
      src/gui/components/layout/juce_MultiDocumentPanel.cpp
  74. +2
    -2
      src/gui/components/layout/juce_ResizableBorderComponent.cpp
  75. +4
    -4
      src/gui/components/lookandfeel/juce_LookAndFeel.cpp
  76. +1
    -1
      src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp
  77. +2
    -2
      src/gui/components/menus/juce_PopupMenu.cpp
  78. +1
    -1
      src/gui/components/mouse/juce_MouseEvent.cpp
  79. +2
    -2
      src/gui/components/special/juce_ColourSelector.cpp
  80. +1
    -1
      src/gui/components/windows/juce_DocumentWindow.cpp
  81. +4
    -4
      src/gui/components/windows/juce_ResizableWindow.cpp
  82. +46
    -55
      src/gui/graphics/colour/juce_ColourGradient.cpp
  83. +16
    -8
      src/gui/graphics/colour/juce_ColourGradient.h
  84. +2
    -2
      src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp
  85. +11
    -12
      src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp
  86. +1
    -1
      src/gui/graphics/drawables/juce_DrawableComposite.cpp
  87. +8
    -10
      src/gui/graphics/drawables/juce_DrawablePath.cpp
  88. +2
    -2
      src/gui/graphics/drawables/juce_DrawableText.cpp
  89. +8
    -10
      src/gui/graphics/drawables/juce_SVGParser.cpp
  90. +4
    -4
      src/gui/graphics/geometry/juce_Path.cpp
  91. +13
    -4
      src/gui/graphics/geometry/juce_Point.h
  92. +1
    -1
      src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp
  93. +1
    -1
      src/gui/graphics/imaging/juce_Image.cpp
  94. +1
    -1
      src/gui/graphics/imaging/juce_ImageCache.cpp
  95. +3
    -3
      src/io/files/juce_File.cpp
  96. +1
    -1
      src/io/files/juce_FileOutputStream.cpp
  97. +1
    -1
      src/io/files/juce_TemporaryFile.cpp
  98. +1
    -1
      src/io/network/juce_Socket.cpp
  99. +1
    -1
      src/io/streams/juce_GZIPCompressorOutputStream.cpp
  100. +2
    -2
      src/io/streams/juce_InputStream.cpp

+ 12
- 0
extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp View File

@@ -659,9 +659,15 @@ static const unsigned char temp_73015554[] =
"//[MiscUserDefs] You can add your own user definitions and misc code here...\r\n"
"//[/MiscUserDefs]\r\n"
"\r\n"
"extern const unsigned char %%className%%_ComponentStateData[];\r\n"
"\r\n"
"//==============================================================================\r\n"
"%%className%%::%%className%% (%%constructorParams%%)\r\n"
"%%initialisers%%{\r\n"
" componentState = ValueTree::readFromData (%%className%%_ComponentStateData, %%statedatasize%%);\r\n"
" jassert (componentState.isValid());\r\n"
" const ValueTree componentStateList (componentState.getChildByName (\"COMPONENTS\"));\r\n"
"\r\n"
" %%constructor%%\r\n"
"\r\n"
" //[Constructor] You can add your own custom stuff here..\r\n"
@@ -688,6 +694,10 @@ static const unsigned char temp_73015554[] =
"%%staticMemberDefinitions%%\r\n"
"\r\n"
"//==============================================================================\r\n"
"/* This data contains the ValueTree that holds all the Jucer-generated settings for the components */\r\n"
"const unsigned char %%className%%_ComponentStateData[] = %%statedata%%;\r\n"
"\r\n"
"//==============================================================================\r\n"
"//======================= Jucer Information Section ==========================\r\n"
"//==============================================================================\r\n"
"#if 0\r\n"
@@ -760,6 +770,8 @@ static const unsigned char temp_b930c59[] =
" %%privateMemberDeclarations%%\r\n"
"\r\n"
" //==============================================================================\r\n"
" ValueTree componentState;\r\n"
" \r\n"
" // (prevent copy constructor and operator= being generated..)\r\n"
" %%className%% (const %%className%%&);\r\n"
" %%className%%& operator= (const %%className%%&);\r\n"


+ 2
- 2
extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h View File

@@ -26,10 +26,10 @@ namespace BinaryData
const int jucer_AudioPluginFilterTemplate_hSize = 2353;
extern const char* jucer_ComponentTemplate_cpp;
const int jucer_ComponentTemplate_cppSize = 1976;
const int jucer_ComponentTemplate_cppSize = 2534;
extern const char* jucer_ComponentTemplate_h;
const int jucer_ComponentTemplate_hSize = 2239;
const int jucer_ComponentTemplate_hSize = 2276;
extern const char* jucer_MainConsoleAppTemplate_cpp;
const int jucer_MainConsoleAppTemplate_cppSize = 749;


+ 28
- 23
extras/Jucer (experimental)/Source/model/Component/Types/jucer_ComboBox.h View File

@@ -34,7 +34,7 @@
class ComboBoxHandler : public ComponentTypeHelper<ComboBox>
{
public:
ComboBoxHandler() : ComponentTypeHelper<ComboBox> ("ComboBox", "COMBOBOX", "comboBox")
ComboBoxHandler() : ComponentTypeHelper<ComboBox> ("ComboBox", "ComboBox", "COMBOBOX", "comboBox")
{
addEditableColour (ComboBox::backgroundColourId, "Background", "backgroundColour");
addEditableColour (ComboBox::textColourId, "Text", "textColour");
@@ -45,16 +45,16 @@ public:
~ComboBoxHandler() {}
Component* createComponent() { return new ComboBox (String::empty); }
Component* createComponent() { return new ComboBox(); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 180, 24); }
void initialiseNew (ComponentDocument& document, ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
state.setProperty ("items", "Item 1\nItem 2", 0);
state.setProperty ("editable", false, 0);
state.setProperty ("textJustification", (int) Justification::centredLeft, 0);
state.setProperty ("unselectedText", "", 0);
state.setProperty ("noItemsText", "(No Choices)", 0);
item.set ("items", "Item 1\nItem 2");
item.set ("editable", false);
item.set ("textJustification", (int) Justification::centredLeft);
item.set ("unselectedText", "");
item.set ("noItemsText", "(No Choices)");
}
void updateItems (ComboBox* comp, const String& itemString)
@@ -77,29 +77,34 @@ public:
}
}
void update (ComponentDocument& document, ComboBox* comp, const ValueTree& state)
void update (ComponentTypeInstance& item, ComboBox* comp)
{
updateItems (comp, state ["items"]);
comp->setEditableText (state ["editable"]);
comp->setJustificationType ((int) state ["textJustification"]);
comp->setTextWhenNothingSelected (state ["unselectedText"].toString());
comp->setTextWhenNoChoicesAvailable (state ["noItemsText"].toString());
updateItems (comp, item ["items"]);
comp->setEditableText (item ["editable"]);
comp->setJustificationType ((int) item ["textJustification"]);
comp->setTextWhenNothingSelected (item ["unselectedText"].toString());
comp->setTextWhenNoChoicesAvailable (item ["noItemsText"].toString());
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
addTooltipProperty (document, state, props);
addFocusOrderProperty (document, state, props);
item.addTooltipProperty (props);
item.addFocusOrderProperty (props);
props.add (new TextPropertyComponent (getValue ("items", state, document), "Items", 16384, true));
props.add (new TextPropertyComponent (item.getValue ("items"), "Items", 16384, true));
props.getLast()->setTooltip ("A list of items to use to initialise the ComboBox");
props.add (new BooleanPropertyComponent (getValue ("editable", state, document), "Editable", "Text is editable"));
props.add (createJustificationProperty ("Text Position", getValue ("textJustification", state, document), false));
props.add (new TextPropertyComponent (getValue ("unselectedText", state, document), "Text when none selected", 512, false));
props.add (new TextPropertyComponent (getValue ("noItemsText", state, document), "Text when no items", 512, false));
props.add (new BooleanPropertyComponent (item.getValue ("editable"), "Editable", "Text is editable"));
item.addJustificationProperty (props, "Text Position", item.getValue ("textJustification"), false);
props.add (new TextPropertyComponent (item.getValue ("unselectedText"), "Text when none selected", 512, false));
props.add (new TextPropertyComponent (item.getValue ("noItemsText"), "Text when no items", 512, false));
addEditableColourProperties (document, state, props);
addEditableColourProperties (item, props);
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode << item.createConstructorStatement (String::empty);
}
};


+ 328
- 61
extras/Jucer (experimental)/Source/model/Component/Types/jucer_ComponentTypeManager.cpp View File

@@ -153,60 +153,76 @@ private:
}
};
//==============================================================================
ComponentTypeHandler::ComponentTypeHandler (const String& name_, const String& xmlTag_,
const String& memberNameRoot_)
: name (name_), xmlTag (xmlTag_),
memberNameRoot (memberNameRoot_)
ComponentTypeManager::ComponentTypeManager()
{
#define ADD_TO_LIST(HandlerType) handlers.add (new HandlerType());
#include "jucer_ComponentTypes.h"
#undef ADD_TO_LIST
}
ComponentTypeHandler::~ComponentTypeHandler()
ComponentTypeManager::~ComponentTypeManager()
{
}
Value ComponentTypeHandler::getValue (const var::identifier& name_, ValueTree& state, ComponentDocument& document) const
Component* ComponentTypeManager::createFromStoredType (ComponentDocument& document, const ValueTree& value)
{
return state.getPropertyAsValue (name_, document.getUndoManager());
ComponentTypeHandler* handler = getHandlerFor (value.getType());
if (handler == 0)
return 0;
Component* c = handler->createComponent();
if (c != 0)
{
ComponentTypeInstance item (document, value);
handler->updateComponent (item, c);
}
return c;
}
void ComponentTypeHandler::updateComponent (ComponentDocument& document, Component* comp, const ValueTree& state)
ComponentTypeHandler* ComponentTypeManager::getHandlerFor (const String& type)
{
RectangleCoordinates pos (state [ComponentDocument::compBoundsProperty].toString());
comp->setBounds (pos.resolve (document));
for (int i = handlers.size(); --i >= 0;)
if (handlers.getUnchecked(i)->getXmlTag() == type)
return handlers.getUnchecked(i);
comp->setName (state [ComponentDocument::compNameProperty]);
return 0;
}
comp->setExplicitFocusOrder (state [ComponentDocument::compFocusOrderProperty]);
const StringArray ComponentTypeManager::getDisplayNames() const
{
StringArray s;
for (int i = 0; i < handlers.size(); ++i)
s.add (handlers.getUnchecked(i)->getDisplayName());
SettableTooltipClient* tooltipClient = dynamic_cast <SettableTooltipClient*> (comp);
if (tooltipClient != 0)
tooltipClient->setTooltip (state [ComponentDocument::compTooltipProperty]);
return s;
}
void ComponentTypeHandler::initialiseNewItem (ComponentDocument& document, ValueTree& state)
{
state.setProperty (ComponentDocument::compNameProperty, String::empty, 0);
state.setProperty (ComponentDocument::memberNameProperty, document.getNonexistentMemberName (getMemberNameRoot()), 0);
juce_ImplementSingleton_SingleThreaded (ComponentTypeManager);
const Rectangle<int> bounds (getDefaultSize().withPosition (Point<int> (Random::getSystemRandom().nextInt (100) + 100,
Random::getSystemRandom().nextInt (100) + 100)));
state.setProperty (ComponentDocument::compBoundsProperty,
RectangleCoordinates (bounds.toFloat(),
state [ComponentDocument::memberNameProperty]).toString(), 0);
//==============================================================================
ComponentTypeHandler::ComponentTypeHandler (const String& displayName_, const String& className_,
const String& xmlTag_, const String& memberNameRoot_)
: displayName (displayName_), className (className_), xmlTag (xmlTag_),
memberNameRoot (memberNameRoot_)
{
}
ComponentTypeHandler::~ComponentTypeHandler()
{
}
//==============================================================================
class CompMemberNameValueSource : public Value::ValueSource,
public Value::Listener
{
public:
CompMemberNameValueSource (ComponentDocument& document_, const ValueTree& state)
: sourceValue (state.getPropertyAsValue (ComponentDocument::memberNameProperty, document_.getUndoManager())),
document (document_)
CompMemberNameValueSource (ComponentTypeInstance& item_)
: sourceValue (item_.getValue (ComponentDocument::memberNameProperty)),
item (item_)
{
sourceValue.addListener (this);
}
@@ -221,74 +237,325 @@ public:
if (newValue == sourceValue)
return;
const String name (document.getNonexistentMemberName (newValue));
const String name (item.getDocument().getNonexistentMemberName (newValue));
if (sourceValue != name)
{
document.renameAnchor (sourceValue.toString(), name);
item.getDocument().renameAnchor (sourceValue.toString(), name);
sourceValue = name;
}
}
private:
Value sourceValue;
ComponentDocument& document;
ComponentTypeInstance& item;
CompMemberNameValueSource (const CompMemberNameValueSource&);
const CompMemberNameValueSource& operator= (const CompMemberNameValueSource&);
};
void ComponentTypeHandler::createPropertyEditors (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
//==============================================================================
ComponentTypeInstance::ComponentTypeInstance (ComponentDocument& document_, const ValueTree& state_)
: document (document_), state (state_)
{
props.add (new TextPropertyComponent (Value (new CompMemberNameValueSource (document, state)), "Member Name", 256, false));
}
props.add (new ComponentBoundsEditor (document, "Left", ComponentBoundsEditor::left, state, getValue (ComponentDocument::compBoundsProperty, state, document)));
props.add (new ComponentBoundsEditor (document, "Right", ComponentBoundsEditor::right, state, getValue (ComponentDocument::compBoundsProperty, state, document)));
props.add (new ComponentBoundsEditor (document, "Top", ComponentBoundsEditor::top, state, getValue (ComponentDocument::compBoundsProperty, state, document)));
props.add (new ComponentBoundsEditor (document, "Bottom", ComponentBoundsEditor::bottom, state, getValue (ComponentDocument::compBoundsProperty, state, document)));
Value ComponentTypeInstance::getValue (const var::identifier& name) const
{
return state.getPropertyAsValue (name, document.getUndoManager());
}
void ComponentTypeInstance::set (const var::identifier& name, const var& value)
{
state.setProperty (name, value, 0);
}
ComponentTypeHandler* ComponentTypeInstance::getHandler() const
{
ComponentTypeHandler* const handler = ComponentTypeManager::getInstance()->getHandlerFor (state.getType());
jassert (handler != 0);
return handler;
}
void ComponentTypeInstance::updateComponent (Component* comp)
{
getHandler()->updateComponent (*this, comp);
}
void ComponentTypeInstance::createProperties (Array <PropertyComponent*>& props)
{
getHandler()->createPropertyEditors (*this, props);
}
void ComponentTypeInstance::createCode (CodeGenerator& code)
{
code.addPrivateMember (getHandler()->getClassName (*this) + "*", getMemberName());
getHandler()->createCode (*this, code);
}
//==============================================================================
ComponentTypeManager::ComponentTypeManager()
void ComponentTypeInstance::initialiseNewItemBasics()
{
#define ADD_TO_LIST(HandlerType) handlers.add (new HandlerType());
#include "jucer_ComponentTypes.h"
#undef ADD_TO_LIST
ComponentTypeHandler* handler = getHandler();
set (ComponentDocument::compNameProperty, String::empty);
set (ComponentDocument::memberNameProperty, document.getNonexistentMemberName (handler->getMemberNameRoot()));
Rectangle<int> bounds (handler->getDefaultSize());
int cw = document.getCanvasWidth().getValue();
int ch = document.getCanvasHeight().getValue();
bounds.setPosition (Random::getSystemRandom().nextInt (cw / 3) + cw / 4,
Random::getSystemRandom().nextInt (ch / 3) + ch / 4);
set (ComponentDocument::compBoundsProperty, RectangleCoordinates (bounds.toFloat(), getMemberName()).toString());
}
ComponentTypeManager::~ComponentTypeManager()
void ComponentTypeInstance::updateComponentBasics (Component* comp)
{
RectangleCoordinates pos (state [ComponentDocument::compBoundsProperty].toString());
comp->setBounds (pos.resolve (document));
comp->setName (state [ComponentDocument::compNameProperty]);
comp->setExplicitFocusOrder (state [ComponentDocument::compFocusOrderProperty]);
SettableTooltipClient* tooltipClient = dynamic_cast <SettableTooltipClient*> (comp);
if (tooltipClient != 0)
tooltipClient->setTooltip (state [ComponentDocument::compTooltipProperty]);
}
Component* ComponentTypeManager::createFromStoredType (ComponentDocument& document, const ValueTree& value)
void ComponentTypeInstance::addMemberNameProperty (Array <PropertyComponent*>& props)
{
ComponentTypeHandler* handler = getHandlerFor (value.getType());
if (handler == 0)
return 0;
props.add (new TextPropertyComponent (Value (new CompMemberNameValueSource (*this)),
"Member Name", 256, false));
}
Component* c = handler->createComponent();
if (c != 0)
handler->updateComponent (document, c, value);
void ComponentTypeInstance::addBoundsProperties (Array <PropertyComponent*>& props)
{
const Value bounds (getValue (ComponentDocument::compBoundsProperty));
props.add (new ComponentBoundsEditor (document, "Left", ComponentBoundsEditor::left, state, bounds));
props.add (new ComponentBoundsEditor (document, "Right", ComponentBoundsEditor::right, state, bounds));
props.add (new ComponentBoundsEditor (document, "Top", ComponentBoundsEditor::top, state, bounds));
props.add (new ComponentBoundsEditor (document, "Bottom", ComponentBoundsEditor::bottom, state, bounds));
}
return c;
void ComponentTypeInstance::addTooltipProperty (Array <PropertyComponent*>& props)
{
props.add (new TextPropertyComponent (getValue (ComponentDocument::compTooltipProperty),
"Tooltip", 4096, false));
}
ComponentTypeHandler* ComponentTypeManager::getHandlerFor (const String& type)
void ComponentTypeInstance::addFocusOrderProperty (Array <PropertyComponent*>& props)
{
for (int i = handlers.size(); --i >= 0;)
if (handlers.getUnchecked(i)->getXmlTag() == type)
return handlers.getUnchecked(i);
props.add (new TextPropertyComponent (Value (new NumericValueSource<int> (getValue (ComponentDocument::compFocusOrderProperty))),
"Focus Order", 10, false));
}
return 0;
void ComponentTypeInstance::addColourProperty (Array <PropertyComponent*>& props, int colourId, const String& name, const String& propertyName)
{
props.add (new ColourPropertyComponent (document, name, getValue (propertyName),
LookAndFeel::getDefaultLookAndFeel().findColour (colourId), true));
}
const StringArray ComponentTypeManager::getTypeNames() const
//==============================================================================
class FontNameValueSource : public Value::ValueSource,
public Value::Listener
{
StringArray s;
for (int i = 0; i < handlers.size(); ++i)
s.add (handlers.getUnchecked(i)->getName());
public:
FontNameValueSource (const Value& source)
: sourceValue (source)
{
sourceValue.addListener (this);
}
return s;
~FontNameValueSource() {}
void valueChanged (Value&) { sendChangeMessage (true); }
const var getValue() const
{
const String fontName (Font::fromString (sourceValue.toString()).getTypefaceName());
const int index = StoredSettings::getInstance()->getFontNames().indexOf (fontName);
if (index >= 0) return 4 + index;
else if (fontName == Font::getDefaultSansSerifFontName()) return 1;
else if (fontName == Font::getDefaultSerifFontName()) return 2;
else if (fontName == Font::getDefaultMonospacedFontName()) return 3;
return 1;
}
void setValue (const var& newValue)
{
Font font (Font::fromString (sourceValue.toString()));
const int index = newValue;
if (index <= 1) font.setTypefaceName (Font::getDefaultSansSerifFontName());
else if (index == 2) font.setTypefaceName (Font::getDefaultSerifFontName());
else if (index == 3) font.setTypefaceName (Font::getDefaultMonospacedFontName());
else font.setTypefaceName (StoredSettings::getInstance()->getFontNames() [index - 4]);
sourceValue = font.toString();
}
static ChoicePropertyComponent* createProperty (const String& title, const Value& value)
{
StringArray fontNames;
fontNames.add (Font::getDefaultSansSerifFontName());
fontNames.add (Font::getDefaultSerifFontName());
fontNames.add (Font::getDefaultMonospacedFontName());
fontNames.add (String::empty);
fontNames.addArray (StoredSettings::getInstance()->getFontNames());
return new ChoicePropertyComponent (Value (new FontNameValueSource (value)), title, fontNames);
}
private:
Value sourceValue;
};
class FontSizeValueSource : public Value::ValueSource,
public Value::Listener
{
public:
FontSizeValueSource (const Value& source)
: sourceValue (source)
{
sourceValue.addListener (this);
}
~FontSizeValueSource() {}
void valueChanged (Value&) { sendChangeMessage (true); }
const var getValue() const
{
return Font::fromString (sourceValue.toString()).getHeight();
}
void setValue (const var& newValue)
{
Font font (Font::fromString (sourceValue.toString()));
font.setHeight (newValue);
sourceValue = font.toString();
}
static PropertyComponent* createProperty (const String& title, const Value& value)
{
return new SliderPropertyComponent (Value (new FontSizeValueSource (value)), title, 1.0, 150.0, 0.1, 0.5);
}
private:
Value sourceValue;
};
class FontStyleValueSource : public Value::ValueSource,
public Value::Listener
{
public:
FontStyleValueSource (const Value& source)
: sourceValue (source)
{
sourceValue.addListener (this);
}
~FontStyleValueSource() {}
void valueChanged (Value&) { sendChangeMessage (true); }
const var getValue() const
{
const Font f (Font::fromString (sourceValue.toString()));
if (f.isBold() && f.isItalic()) return getStyles() [3];
if (f.isBold()) return getStyles() [1];
if (f.isItalic()) return getStyles() [2];
return getStyles() [0];
}
void setValue (const var& newValue)
{
Font font (Font::fromString (sourceValue.toString()));
font.setBold (newValue.toString().containsIgnoreCase ("Bold"));
font.setItalic (newValue.toString().containsIgnoreCase ("Italic"));
sourceValue = font.toString();
}
static PropertyComponent* createProperty (const String& title, const Value& value)
{
return StringListValueSource::create (title, Value (new FontStyleValueSource (value)), StringArray (getStyles()));
}
static const char* const* getStyles()
{
static const char* const fontStyles[] = { "Normal", "Bold", "Italic", "Bold + Italic", 0 };
return fontStyles;
}
private:
Value sourceValue;
};
void ComponentTypeInstance::addFontProperties (Array <PropertyComponent*>& props, const var::identifier& name)
{
Value v (getValue (name));
props.add (FontNameValueSource::createProperty ("Font", v));
props.add (FontSizeValueSource::createProperty ("Font Size", v));
props.add (FontStyleValueSource::createProperty ("Font Style", v));
}
juce_ImplementSingleton_SingleThreaded (ComponentTypeManager);
//==============================================================================
void ComponentTypeInstance::addJustificationProperty (Array <PropertyComponent*>& props, const String& name, const Value& value, bool onlyHorizontal)
{
ValueRemapperSource* remapper = new ValueRemapperSource (value);
StringArray strings;
if (onlyHorizontal)
{
const char* const layouts[] = { "Left", "Centred", "Right", 0 };
const int justifications[] = { Justification::left, Justification::centred, Justification::right, 0 };
for (int i = 0; i < numElementsInArray (justifications) - 1; ++i)
remapper->addMapping (justifications[i], i + 1);
strings = StringArray (layouts);
}
else
{
const char* const layouts[] = { "Centred", "Centred-left", "Centred-right", "Centred-top", "Centred-bottom", "Top-left",
"Top-right", "Bottom-left", "Bottom-right", 0 };
const int justifications[] = { Justification::centred, Justification::centredLeft, Justification::centredRight,
Justification::centredTop, Justification::centredBottom, Justification::topLeft,
Justification::topRight, Justification::bottomLeft, Justification::bottomRight, 0 };
for (int i = 0; i < numElementsInArray (justifications) - 1; ++i)
remapper->addMapping (justifications[i], i + 1);
strings = StringArray (layouts);
}
props.add (new ChoicePropertyComponent (Value (remapper), name, strings));
}
//==============================================================================
const String ComponentTypeInstance::createConstructorStatement (const String& params)
{
String s;
s << "addAndMakeVisible (" << getMemberName()
<< " = new " << getHandler()->getClassName (*this);
if (params.isEmpty())
s << "());" << newLine;
else
{
s << " (";
s << CodeFormatting::indent (params.trim(), s.length(), false) << "));" << newLine;
}
// s << getMemberName() << "->updateStateFrom (componentStateList.getChild ("
// << document.getComponentGroup().indexOf (state) << ");" << newLine;
return s;
}

+ 108
- 60
extras/Jucer (experimental)/Source/model/Component/Types/jucer_ComponentTypeManager.h View File

@@ -29,6 +29,70 @@
#include "../../../jucer_Headers.h"
#include "../jucer_ComponentDocument.h"
#include "../../../utility/jucer_ColourEditorComponent.h"
class ComponentTypeHandler;
class JucerState
{
public:
JucerState (const ValueTree& state_)
: state (state_)
{
}
~JucerState()
{
}
private:
ValueTree state;
};
//==============================================================================
/** Temporary wrapper around a document and a component's ValueTree, providing lots of useful
functions that can be performed on the component.
*/
class ComponentTypeInstance
{
public:
ComponentTypeInstance (ComponentDocument& document_, const ValueTree& state_);
//==============================================================================
ComponentDocument& getDocument() throw() { return document; }
ValueTree& getState() throw() { return state; }
Value getValue (const var::identifier& name) const;
void set (const var::identifier& name, const var& value);
const var operator[] (const var::identifier& name) const { return state [name] ;}
const String getMemberName() const { return state [ComponentDocument::memberNameProperty]; }
const String getComponentName() const { return state [ComponentDocument::compNameProperty]; }
//==============================================================================
void initialiseNewItemBasics();
void updateComponentBasics (Component* comp);
void addMemberNameProperty (Array <PropertyComponent*>& props);
void addBoundsProperties (Array <PropertyComponent*>& props);
void addTooltipProperty (Array <PropertyComponent*>& props);
void addFocusOrderProperty (Array <PropertyComponent*>& props);
void addColourProperty (Array <PropertyComponent*>& props, int colourId, const String& name, const String& propertyName);
void addFontProperties (Array <PropertyComponent*>& props, const var::identifier& name);
void addJustificationProperty (Array <PropertyComponent*>& props, const String& name, const Value& value, bool onlyHorizontal);
//==============================================================================
const String createConstructorStatement (const String& params);
//==============================================================================
ComponentTypeHandler* getHandler() const;
void updateComponent (Component* comp);
void createProperties (Array <PropertyComponent*>& props);
void createCode (CodeGenerator& code);
private:
//==============================================================================
ComponentDocument& document;
ValueTree state;
};
//==============================================================================
@@ -36,25 +100,25 @@ class ComponentTypeHandler
{
public:
//==============================================================================
ComponentTypeHandler (const String& name_, const String& xmlTag_, const String& memberNameRoot_);
ComponentTypeHandler (const String& displayName_, const String& className_, const String& xmlTag_, const String& memberNameRoot_);
virtual ~ComponentTypeHandler();
const String& getName() const { return name; }
const String& getDisplayName() const { return displayName; }
const String& getXmlTag() const { return xmlTag; }
const String& getMemberNameRoot() const { return memberNameRoot; }
virtual Component* createComponent() = 0;
virtual const Rectangle<int> getDefaultSize() = 0;
virtual void updateComponent (ComponentDocument& document, Component* comp, const ValueTree& state);
virtual void initialiseNewItem (ComponentDocument& document, ValueTree& state);
virtual void createPropertyEditors (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props);
Value getValue (const var::identifier& name, ValueTree& state, ComponentDocument& document) const;
virtual void initialiseNewItem (ComponentTypeInstance& item) = 0;
virtual void updateComponent (ComponentTypeInstance& item, Component* comp) = 0;
virtual void createPropertyEditors (ComponentTypeInstance& item, Array <PropertyComponent*>& props) = 0;
virtual void createCode (ComponentTypeInstance& item, CodeGenerator& code) = 0;
virtual const String getClassName (ComponentTypeInstance& item) const { return className; }
protected:
//==============================================================================
const String name, xmlTag, memberNameRoot;
const String displayName, className, xmlTag, memberNameRoot;
private:
ComponentTypeHandler (const ComponentTypeHandler&);
@@ -79,7 +143,7 @@ public:
ComponentTypeHandler* getHandler (const int index) const { return handlers[index]; }
ComponentTypeHandler* getHandlerFor (const String& type);
const StringArray getTypeNames() const;
const StringArray getDisplayNames() const;
private:
//==============================================================================
@@ -93,74 +157,46 @@ class ComponentTypeHelper : public ComponentTypeHandler
{
public:
//==============================================================================
ComponentTypeHelper (const String& name_, const String& xmlTag_, const String& memberNameRoot_)
: ComponentTypeHandler (name_, xmlTag_, memberNameRoot_)
ComponentTypeHelper (const String& displayName_, const String& className_, const String& xmlTag_, const String& memberNameRoot_)
: ComponentTypeHandler (displayName_, className_, xmlTag_, memberNameRoot_)
{
}
virtual void update (ComponentDocument& document, ComponentClass* comp, const ValueTree& state) = 0;
virtual void initialiseNew (ComponentTypeInstance& item) = 0;
virtual void update (ComponentTypeInstance& item, ComponentClass* comp) = 0;
virtual void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props) = 0;
void updateComponent (ComponentDocument& document, Component* comp, const ValueTree& state)
void initialiseNewItem (ComponentTypeInstance& item)
{
ComponentTypeHandler::updateComponent (document, comp, state);
ComponentClass* const c = dynamic_cast <ComponentClass*> (comp);
jassert (c != 0);
updateComponentColours (state, c);
update (document, c, state);
item.initialiseNewItemBasics();
initialiseNew (item);
}
virtual void initialiseNew (ComponentDocument& document, ValueTree& state) = 0;
void initialiseNewItem (ComponentDocument& document, ValueTree& state)
void updateComponent (ComponentTypeInstance& item, Component* comp)
{
ComponentTypeHandler::initialiseNewItem (document, state);
initialiseNew (document, state);
}
item.updateComponentBasics (comp);
virtual void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props) = 0;
ComponentClass* const c = dynamic_cast <ComponentClass*> (comp);
jassert (c != 0);
updateComponentColours (item, c);
void createPropertyEditors (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
{
ComponentTypeHandler::createPropertyEditors (document, state, props);
createProperties (document, state, props);
update (item, c);
}
protected:
//==============================================================================
void addTooltipProperty (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createPropertyEditors (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
props.add (new TextPropertyComponent (getValue (ComponentDocument::compTooltipProperty, state, document),
"Tooltip", 4096, false));
}
item.addMemberNameProperty (props);
item.addBoundsProperties (props);
void addFocusOrderProperty (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
{
props.add (new TextPropertyComponent (Value (new NumericValueSource<int> (getValue (ComponentDocument::compFocusOrderProperty,
state, document))),
"Focus Order", 10, false));
createProperties (item, props);
}
protected:
//==============================================================================
struct EditableColour
{
int colourId;
String name, propertyName;
PropertyComponent* createProperty (ComponentTypeHelper& type, ComponentDocument& document, ValueTree& state)
{
return new ColourPropertyComponent (document, name, type.getValue (propertyName, state, document),
LookAndFeel::getDefaultLookAndFeel().findColour (colourId), true);
}
void updateComponent (const ValueTree& state, Component* component)
{
const String colour (state [propertyName].toString());
if (colour.isNotEmpty())
component->setColour (colourId, Colour::fromString (colour));
else
component->removeColour (colourId);
}
};
Array <EditableColour> editableColours;
@@ -174,16 +210,28 @@ protected:
editableColours.add (ec);
}
void addEditableColourProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void addEditableColourProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
for (int i = 0; i < editableColours.size(); ++i)
props.add (editableColours.getReference(i).createProperty (*this, document, state));
{
const EditableColour& ec = editableColours.getReference(i);
item.addColourProperty (props, ec.colourId, ec.name, ec.propertyName);
}
}
void updateComponentColours (const ValueTree& state, Component* component)
void updateComponentColours (ComponentTypeInstance& item, Component* component)
{
for (int i = 0; i < editableColours.size(); ++i)
editableColours.getReference(i).updateComponent (state, component);
{
const EditableColour& ec = editableColours.getReference(i);
const String colour (item.getState() [ec.propertyName].toString());
if (colour.isNotEmpty())
component->setColour (ec.colourId, Colour::fromString (colour));
else
component->removeColour (ec.colourId);
}
}
};


+ 19
- 9
extras/Jucer (experimental)/Source/model/Component/Types/jucer_GenericComponent.h View File

@@ -34,7 +34,7 @@
class GenericComponentHandler : public ComponentTypeHelper<Component>
{
public:
GenericComponentHandler() : ComponentTypeHelper<Component> ("Generic Component", "COMPONENT", "component") {}
GenericComponentHandler() : ComponentTypeHelper<Component> ("Generic Component", "Component", "COMPONENT", "component") {}
~GenericComponentHandler() {}
//==============================================================================
@@ -66,24 +66,34 @@ public:
Component* createComponent() { return new PlaceholderComp(); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 180, 24); }
void update (ComponentDocument& document, Component* comp, const ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
static_cast<PlaceholderComp*> (comp)->setDetails (state [ComponentDocument::memberNameProperty],
state ["class"]);
item.set ("class", "Component");
}
void initialiseNew (ComponentDocument& document, ValueTree& state)
void update (ComponentTypeInstance& item, Component* comp)
{
state.setProperty ("class", "Component", 0);
static_cast<PlaceholderComp*> (comp)->setDetails (item [ComponentDocument::memberNameProperty],
item ["class"]);
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
addFocusOrderProperty (document, state, props);
item.addFocusOrderProperty (props);
props.add (new TextPropertyComponent (getValue ("class", state, document), "Class", 256, false));
props.add (new TextPropertyComponent (item.getValue ("class"), "Class", 256, false));
props.getLast()->setTooltip ("The class that this component is an instance of.");
}
const String getClassName (ComponentTypeInstance& item) const
{
return item ["class"];
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode << item.createConstructorStatement (String::empty);
}
};
#endif

+ 19
- 14
extras/Jucer (experimental)/Source/model/Component/Types/jucer_GroupComponent.h View File

@@ -34,7 +34,7 @@
class GroupComponentHandler : public ComponentTypeHelper<GroupComponent>
{
public:
GroupComponentHandler() : ComponentTypeHelper<GroupComponent> ("GroupComponent", "GROUPCOMPONENT", "group")
GroupComponentHandler() : ComponentTypeHelper<GroupComponent> ("GroupComponent", "GroupComponent", "GROUPCOMPONENT", "group")
{
addEditableColour (GroupComponent::outlineColourId, "Outline", "outlineColour");
addEditableColour (GroupComponent::textColourId, "Text Colour", "textColour");
@@ -42,31 +42,36 @@ public:
~GroupComponentHandler() {}
Component* createComponent() { return new GroupComponent (String::empty, String::empty); }
Component* createComponent() { return new GroupComponent(); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 200, 200); }
void update (ComponentDocument& document, GroupComponent* comp, const ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
comp->setText (state ["text"].toString());
comp->setTextLabelPosition ((int) state ["justification"]);
item.set ("text", "Group");
item.set ("justification", (int) Justification::left);
}
void initialiseNew (ComponentDocument& document, ValueTree& state)
void update (ComponentTypeInstance& item, GroupComponent* comp)
{
state.setProperty ("text", "Group", 0);
state.setProperty ("justification", (int) Justification::left, 0);
comp->setText (item ["text"].toString());
comp->setTextLabelPosition ((int) item ["justification"]);
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
addTooltipProperty (document, state, props);
addFocusOrderProperty (document, state, props);
item.addTooltipProperty (props);
item.addFocusOrderProperty (props);
props.add (new TextPropertyComponent (getValue ("text", state, document), "Label", 512, false));
props.add (new TextPropertyComponent (item.getValue ("text"), "Label", 512, false));
props.getLast()->setTooltip ("The group's display name.");
props.add (createJustificationProperty ("Text Position", state.getPropertyAsValue ("justification", document.getUndoManager()), true));
addEditableColourProperties (document, state, props);
item.addJustificationProperty (props, "Text Position", item.getValue ("justification"), true);
addEditableColourProperties (item, props);
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode << item.createConstructorStatement (String::empty);
}
};


+ 14
- 4
extras/Jucer (experimental)/Source/model/Component/Types/jucer_JucerComponent.h View File

@@ -57,24 +57,34 @@ private:
class JucerComponentHandler : public ComponentTypeHelper<JucerComponent>
{
public:
JucerComponentHandler() : ComponentTypeHelper<JucerComponent> ("Jucer Component", "JUCERCOMPONENT", "jucerComp") {}
JucerComponentHandler() : ComponentTypeHelper<JucerComponent> ("Jucer Component", "Component", "JUCERCOMPONENT", "jucerComp") {}
~JucerComponentHandler() {}
//==============================================================================
Component* createComponent() { return new JucerComponent(); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 150, 150); }
void update (ComponentDocument& document, JucerComponent* comp, const ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
}
void initialiseNew (ComponentDocument& document, ValueTree& state)
void update (ComponentTypeInstance& item, JucerComponent* comp)
{
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
}
const String getClassName (ComponentTypeInstance& item) const
{
return "xxx";
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode << item.createConstructorStatement (String::empty);
}
};
#endif

+ 26
- 22
extras/Jucer (experimental)/Source/model/Component/Types/jucer_Label.h View File

@@ -34,7 +34,7 @@
class LabelHandler : public ComponentTypeHelper<Label>
{
public:
LabelHandler() : ComponentTypeHelper<Label> ("Label", "LABEL", "label")
LabelHandler() : ComponentTypeHelper<Label> ("Label", "Label", "LABEL", "label")
{
addEditableColour (Label::backgroundColourId, "Background", "backgroundColour");
addEditableColour (Label::textColourId, "Text Colour", "textColour");
@@ -43,43 +43,47 @@ public:
~LabelHandler() {}
Component* createComponent() { return new Label (String::empty, String::empty); }
Component* createComponent() { return new Label(); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 180, 24); }
void update (ComponentDocument& document, Label* comp, const ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
comp->setText (state ["text"].toString(), false);
comp->setFont (getFontFromState (state, "fontName", "fontSize", "fontStyle"));
int editMode = (int) state ["editMode"];
comp->setEditable (editMode == 2, editMode == 3, false);
comp->setJustificationType ((int) state ["justification"]);
item.set ("text", "New Label");
item.set ("font", Font (14.0f).toString());
item.set ("editMode", 1);
item.set ("justification", (int) Justification::centredLeft);
}
void initialiseNew (ComponentDocument& document, ValueTree& state)
void update (ComponentTypeInstance& item, Label* comp)
{
state.setProperty ("text", "New Label", 0);
state.setProperty ("fontSize", 14, 0);
state.setProperty ("editMode", 1, 0);
state.setProperty ("justification", (int) Justification::centredLeft, 0);
comp->setText (item ["text"].toString(), false);
comp->setFont (Font::fromString (item ["font"]));
int editMode = (int) item ["editMode"];
comp->setEditable (editMode == 2, editMode == 3, false);
comp->setJustificationType ((int) item ["justification"]);
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
addTooltipProperty (document, state, props);
addFocusOrderProperty (document, state, props);
item.addTooltipProperty (props);
item.addFocusOrderProperty (props);
props.add (new TextPropertyComponent (getValue ("text", state, document), "Text", 16384, true));
props.add (new TextPropertyComponent (item.getValue ("text"), "Text", 16384, true));
props.getLast()->setTooltip ("The label's text.");
props.add (createJustificationProperty ("Layout", state.getPropertyAsValue ("justification", document.getUndoManager()), false));
item.addJustificationProperty (props, "Layout", item.getValue ("justification"), false);
const char* const editModes[] = { "Read-only", "Edit on Single-Click", "Edit on Double-Click", 0 };
props.add (new ChoicePropertyComponent (state.getPropertyAsValue ("editMode", document.getUndoManager()),
"Edit Mode", StringArray (editModes)));
props.add (new ChoicePropertyComponent (item.getValue ("editMode"), "Edit Mode", StringArray (editModes)));
createFontProperties (props, state, "fontName", "fontSize", "fontStyle", document.getUndoManager());
item.addFontProperties (props, "font");
addEditableColourProperties (document, state, props);
addEditableColourProperties (item, props);
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode << item.createConstructorStatement (String::empty);
}
};


+ 37
- 32
extras/Jucer (experimental)/Source/model/Component/Types/jucer_Slider.h View File

@@ -34,7 +34,7 @@
class SliderHandler : public ComponentTypeHelper<Slider>
{
public:
SliderHandler() : ComponentTypeHelper<Slider> ("Slider", "SLIDER", "slider")
SliderHandler() : ComponentTypeHelper<Slider> ("Slider", "Slider", "SLIDER", "slider")
{
addEditableColour (Slider::backgroundColourId, "Background", "backgroundColour");
addEditableColour (Slider::thumbColourId, "Thumb", "thumbColour");
@@ -49,54 +49,59 @@ public:
~SliderHandler() {}
Component* createComponent() { return new Slider (String::empty); }
Component* createComponent() { return new Slider(); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 200, 24); }
void initialiseNew (ComponentDocument& document, ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
state.setProperty ("min", 0, 0);
state.setProperty ("max", 100, 0);
state.setProperty ("interval", 1, 0);
state.setProperty ("type", 1 + Slider::LinearHorizontal, 0);
state.setProperty ("textBoxPos", 2, 0);
state.setProperty ("editable", true, 0);
state.setProperty ("textBoxWidth", 80, 0);
state.setProperty ("textBoxHeight", 20, 0);
state.setProperty ("skew", 1, 0);
item.set ("min", 0);
item.set ("max", 100);
item.set ("interval", 1);
item.set ("type", 1 + Slider::LinearHorizontal);
item.set ("textBoxPos", 2);
item.set ("editable", true);
item.set ("textBoxWidth", 80);
item.set ("textBoxHeight", 20);
item.set ("skew", 1);
}
void update (ComponentDocument& document, Slider* comp, const ValueTree& state)
void update (ComponentTypeInstance& item, Slider* comp)
{
comp->setRange ((double) state ["min"], (double) state ["max"], (double) state ["interval"]);
comp->setSliderStyle ((Slider::SliderStyle) ((int) state ["type"] - 1));
comp->setTextBoxStyle ((Slider::TextEntryBoxPosition) ((int) state ["textBoxPos"] - 1),
! (bool) state ["editable"],
(int) state ["textBoxWidth"], (int) state ["textBoxHeight"]);
comp->setSkewFactor ((double) state ["skew"]);
comp->setRange ((double) item ["min"], (double) item ["max"], (double) item ["interval"]);
comp->setSliderStyle ((Slider::SliderStyle) ((int) item ["type"] - 1));
comp->setTextBoxStyle ((Slider::TextEntryBoxPosition) ((int) item ["textBoxPos"] - 1),
! (bool) item ["editable"],
(int) item ["textBoxWidth"], (int) item ["textBoxHeight"]);
comp->setSkewFactor ((double) item ["skew"]);
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
addTooltipProperty (document, state, props);
addFocusOrderProperty (document, state, props);
item.addTooltipProperty (props);
item.addFocusOrderProperty (props);
props.add (new TextPropertyComponent (Value (new NumericValueSource<double> (getValue ("min", state, document))), "Minimum", 16, false));
props.add (new TextPropertyComponent (Value (new NumericValueSource<double> (getValue ("max", state, document))), "Maximum", 16, false));
props.add (new TextPropertyComponent (Value (new NumericValueSource<double> (getValue ("interval", state, document))), "Interval", 16, false));
props.add (new TextPropertyComponent (Value (new NumericValueSource<double> (item.getValue ("min"))), "Minimum", 16, false));
props.add (new TextPropertyComponent (Value (new NumericValueSource<double> (item.getValue ("max"))), "Maximum", 16, false));
props.add (new TextPropertyComponent (Value (new NumericValueSource<double> (item.getValue ("interval"))), "Interval", 16, false));
const char* const types[] = { "LinearHorizontal", "LinearVertical", "LinearBar", "Rotary", "RotaryHorizontalDrag", "RotaryVerticalDrag",
"IncDecButtons", "TwoValueHorizontal", "TwoValueVertical", "ThreeValueHorizontal", "ThreeValueVertical", 0 };
props.add (new ChoicePropertyComponent (state.getPropertyAsValue ("type", document.getUndoManager()), "Type", StringArray (types)));
props.add (new ChoicePropertyComponent (item.getValue ("type"), "Type", StringArray (types)));
const char* const textBoxPositions[] = { "NoTextBox", "TextBoxLeft", "TextBoxRight", "TextBoxAbove", "TextBoxBelow", 0 };
props.add (new ChoicePropertyComponent (state.getPropertyAsValue ("textBoxPos", document.getUndoManager()), "Text Box", StringArray (textBoxPositions)));
props.add (new ChoicePropertyComponent (item.getValue ("textBoxPos"), "Text Box", StringArray (textBoxPositions)));
props.add (new BooleanPropertyComponent (getValue ("editable", state, document), "Editable", "Value can be edited"));
props.add (new TextPropertyComponent (Value (new NumericValueSource<int> (getValue ("textBoxWidth", state, document))), "Text Box Width", 8, false));
props.add (new TextPropertyComponent (Value (new NumericValueSource<int> (getValue ("textBoxHeight", state, document))), "Text Box Height", 8, false));
props.add (new BooleanPropertyComponent (item.getValue ("editable"), "Editable", "Value can be edited"));
props.add (new TextPropertyComponent (Value (new NumericValueSource<int> (item.getValue ("textBoxWidth"))), "Text Box Width", 8, false));
props.add (new TextPropertyComponent (Value (new NumericValueSource<int> (item.getValue ("textBoxHeight"))), "Text Box Height", 8, false));
props.add (new TextPropertyComponent (Value (new NumericValueSource<double> (getValue ("skew", state, document))), "Skew Factor", 16, false));
addEditableColourProperties (document, state, props);
props.add (new TextPropertyComponent (Value (new NumericValueSource<double> (item.getValue ("skew"))), "Skew Factor", 16, false));
addEditableColourProperties (item, props);
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode << item.createConstructorStatement (CodeFormatting::stringLiteral (item.getComponentName()));
}
};


+ 10
- 5
extras/Jucer (experimental)/Source/model/Component/Types/jucer_TabbedComponent.h View File

@@ -34,7 +34,7 @@
class TabbedComponentHandler : public ComponentTypeHelper<TabbedComponent>
{
public:
TabbedComponentHandler() : ComponentTypeHelper<TabbedComponent> ("TabbedComponent", "TABBEDCOMPONENT", "tabbedComponent")
TabbedComponentHandler() : ComponentTypeHelper<TabbedComponent> ("TabbedComponent", "TabbedComponent", "TABBEDCOMPONENT", "tabbedComponent")
{
addEditableColour (TabbedComponent::backgroundColourId, "Background", "backgroundColour");
addEditableColour (TabbedComponent::outlineColourId, "Outline", "outlineColour");
@@ -45,17 +45,22 @@ public:
Component* createComponent() { return new TabbedComponent (TabbedButtonBar::TabsAtTop); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 300, 200); }
void update (ComponentDocument& document, TabbedComponent* comp, const ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
}
void initialiseNew (ComponentDocument& document, ValueTree& state)
void update (ComponentTypeInstance& item, TabbedComponent* comp)
{
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
addEditableColourProperties (document, state, props);
addEditableColourProperties (item, props);
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode << item.createConstructorStatement ("TabbedButtonBar::TabsAtTop");
}
};


+ 31
- 26
extras/Jucer (experimental)/Source/model/Component/Types/jucer_TextButton.h View File

@@ -34,7 +34,7 @@
class TextButtonHandler : public ComponentTypeHelper<TextButton>
{
public:
TextButtonHandler() : ComponentTypeHelper<TextButton> ("TextButton", "TEXTBUTTON", "textButton")
TextButtonHandler() : ComponentTypeHelper<TextButton> ("TextButton", "TextButton", "TEXTBUTTON", "textButton")
{
addEditableColour (TextButton::buttonColourId, "Background", "backgroundColour");
addEditableColour (TextButton::textColourOffId, "Text Colour", "textColour");
@@ -42,50 +42,55 @@ public:
~TextButtonHandler() {}
Component* createComponent() { return new TextButton (String::empty); }
Component* createComponent() { return new TextButton(); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 150, 24); }
void initialiseNew (ComponentDocument& document, ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
state.setProperty ("text", "New Button", 0);
state.setProperty ("radioGroup", 0, 0);
state.setProperty ("connectedLeft", false, 0);
state.setProperty ("connectedRight", false, 0);
state.setProperty ("connectedTop", false, 0);
state.setProperty ("connectedBottom", false, 0);
item.set ("text", "New Button");
item.set ("radioGroup", 0);
item.set ("connectedLeft", false);
item.set ("connectedRight", false);
item.set ("connectedTop", false);
item.set ("connectedBottom", false);
}
void update (ComponentDocument& document, TextButton* comp, const ValueTree& state)
void update (ComponentTypeInstance& item, TextButton* comp)
{
comp->setButtonText (state ["text"].toString());
comp->setRadioGroupId (state ["radioGroup"]);
comp->setButtonText (item ["text"].toString());
comp->setRadioGroupId (item ["radioGroup"]);
int connected = 0;
if (state ["connectedLeft"]) connected |= TextButton::ConnectedOnLeft;
if (state ["connectedRight"]) connected |= TextButton::ConnectedOnRight;
if (state ["connectedTop"]) connected |= TextButton::ConnectedOnTop;
if (state ["connectedBottom"]) connected |= TextButton::ConnectedOnBottom;
if (item ["connectedLeft"]) connected |= TextButton::ConnectedOnLeft;
if (item ["connectedRight"]) connected |= TextButton::ConnectedOnRight;
if (item ["connectedTop"]) connected |= TextButton::ConnectedOnTop;
if (item ["connectedBottom"]) connected |= TextButton::ConnectedOnBottom;
comp->setConnectedEdges (connected);
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
addTooltipProperty (document, state, props);
addFocusOrderProperty (document, state, props);
item.addTooltipProperty (props);
item.addFocusOrderProperty (props);
props.add (new TextPropertyComponent (getValue ("text", state, document), "Button Text", 1024, false));
props.add (new TextPropertyComponent (item.getValue ("text"), "Button Text", 1024, false));
props.getLast()->setTooltip ("The button's text.");
props.add (new TextPropertyComponent (Value (new NumericValueSource<int> (getValue ("radioGroup", state, document))), "Radio Group", 8, false));
props.add (new TextPropertyComponent (Value (new NumericValueSource<int> (item.getValue ("radioGroup"))), "Radio Group", 8, false));
props.getLast()->setTooltip ("The radio group that this button is a member of.");
props.add (new BooleanPropertyComponent (getValue ("connectedLeft", state, document), "Connected left", "Connected"));
props.add (new BooleanPropertyComponent (getValue ("connectedRight", state, document), "Connected right", "Connected"));
props.add (new BooleanPropertyComponent (getValue ("connectedTop", state, document), "Connected top", "Connected"));
props.add (new BooleanPropertyComponent (getValue ("connectedBottom", state, document), "Connected bottom", "Connected"));
props.add (new BooleanPropertyComponent (item.getValue ("connectedLeft"), "Connected left", "Connected"));
props.add (new BooleanPropertyComponent (item.getValue ("connectedRight"), "Connected right", "Connected"));
props.add (new BooleanPropertyComponent (item.getValue ("connectedTop"), "Connected top", "Connected"));
props.add (new BooleanPropertyComponent (item.getValue ("connectedBottom"), "Connected bottom", "Connected"));
addEditableColourProperties (document, state, props);
addEditableColourProperties (item, props);
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode += item.createConstructorStatement (String::empty);
}
};


+ 30
- 25
extras/Jucer (experimental)/Source/model/Component/Types/jucer_TextEditor.h View File

@@ -34,7 +34,7 @@
class TextEditorHandler : public ComponentTypeHelper<TextEditor>
{
public:
TextEditorHandler() : ComponentTypeHelper<TextEditor> ("TextEditor", "TEXTEDITOR", "textEditor")
TextEditorHandler() : ComponentTypeHelper<TextEditor> ("TextEditor", "TextEditor", "TEXTEDITOR", "textEditor")
{
addEditableColour (TextEditor::backgroundColourId, "Background", "backgroundColour");
addEditableColour (TextEditor::textColourId, "Text", "textColour");
@@ -51,45 +51,50 @@ public:
Component* createComponent() { return new TextEditor(); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 180, 24); }
void initialiseNew (ComponentDocument& document, ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
state.setProperty ("text", "Text Editor Content", 0);
state.setProperty ("readOnly", false, 0);
state.setProperty ("scrollbarsShown", true, 0);
state.setProperty ("caretVisible", true, 0);
state.setProperty ("popupMenuEnabled", true, 0);
state.setProperty ("mode", 1, 0);
item.set ("text", "Text Editor Content");
item.set ("readOnly", false);
item.set ("scrollbarsShown", true);
item.set ("caretVisible", true);
item.set ("popupMenuEnabled", true);
item.set ("mode", 1);
}
void update (ComponentDocument& document, TextEditor* comp, const ValueTree& state)
void update (ComponentTypeInstance& item, TextEditor* comp)
{
comp->setReadOnly (state["readOnly"]);
comp->setScrollbarsShown (state ["scrollbarsShown"]);
comp->setCaretVisible (state ["caretVisible"]);
comp->setPopupMenuEnabled (state ["popupMenuEnabled"]);
int mode = state ["mode"];
comp->setReadOnly (item ["readOnly"]);
comp->setScrollbarsShown (item ["scrollbarsShown"]);
comp->setCaretVisible (item ["caretVisible"]);
comp->setPopupMenuEnabled (item ["popupMenuEnabled"]);
int mode = item ["mode"];
comp->setMultiLine (mode > 1, true);
comp->setReturnKeyStartsNewLine (mode != 3);
comp->setText (state ["text"].toString());
comp->setText (item ["text"].toString());
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
addTooltipProperty (document, state, props);
addFocusOrderProperty (document, state, props);
item.addTooltipProperty (props);
item.addFocusOrderProperty (props);
props.add (new TextPropertyComponent (getValue ("text", state, document), "Text", 16384, true));
props.add (new TextPropertyComponent (item.getValue ("text"), "Text", 16384, true));
props.getLast()->setTooltip ("The editor's initial content.");
const char* const modes[] = { "Single-Line", "Multi-Line (Return key starts new line)", "Multi-Line (Return key disabled)", 0 };
props.add (new ChoicePropertyComponent (getValue ("mode", state, document), "Mode", StringArray (modes)));
props.add (new ChoicePropertyComponent (item.getValue ("mode"), "Mode", StringArray (modes)));
props.add (new BooleanPropertyComponent (getValue ("readOnly", state, document), "Read-Only", "Read-Only"));
props.add (new BooleanPropertyComponent (getValue ("scrollbarsShown", state, document), "Scrollbars", "Scrollbars Shown"));
props.add (new BooleanPropertyComponent (getValue ("caretVisible", state, document), "Caret", "Caret Visible"));
props.add (new BooleanPropertyComponent (getValue ("popupMenuEnabled", state, document), "Popup Menu", "Popup Menu Enabled"));
props.add (new BooleanPropertyComponent (item.getValue ("readOnly"), "Read-Only", "Read-Only"));
props.add (new BooleanPropertyComponent (item.getValue ("scrollbarsShown"), "Scrollbars", "Scrollbars Shown"));
props.add (new BooleanPropertyComponent (item.getValue ("caretVisible"), "Caret", "Caret Visible"));
props.add (new BooleanPropertyComponent (item.getValue ("popupMenuEnabled"), "Popup Menu", "Popup Menu Enabled"));
addEditableColourProperties (document, state, props);
addEditableColourProperties (item, props);
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode += item.createConstructorStatement (String::empty);
}
};


+ 19
- 14
extras/Jucer (experimental)/Source/model/Component/Types/jucer_ToggleButton.h View File

@@ -34,39 +34,44 @@
class ToggleButtonHandler : public ComponentTypeHelper<ToggleButton>
{
public:
ToggleButtonHandler() : ComponentTypeHelper<ToggleButton> ("ToggleButton", "TOGGLEBUTTON", "toggleButton")
ToggleButtonHandler() : ComponentTypeHelper<ToggleButton> ("ToggleButton", "ToggleButton", "TOGGLEBUTTON", "toggleButton")
{
addEditableColour (ToggleButton::textColourId, "Text Colour", "textColour");
}
~ToggleButtonHandler() {}
Component* createComponent() { return new ToggleButton (String::empty); }
Component* createComponent() { return new ToggleButton(); }
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 180, 24); }
void initialiseNew (ComponentDocument& document, ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
state.setProperty ("text", "New Toggle Button", 0);
state.setProperty ("initialState", false, 0);
item.set ("text", "New Toggle Button");
item.set ("initialState", false);
}
void update (ComponentDocument& document, ToggleButton* comp, const ValueTree& state)
void update (ComponentTypeInstance& item, ToggleButton* comp)
{
comp->setButtonText (state ["text"].toString());
comp->setToggleState (state ["initialState"], false);
comp->setButtonText (item ["text"].toString());
comp->setToggleState (item ["initialState"], false);
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
addTooltipProperty (document, state, props);
addFocusOrderProperty (document, state, props);
item.addTooltipProperty (props);
item.addFocusOrderProperty (props);
props.add (new TextPropertyComponent (getValue ("text", state, document), "Button Text", 1024, false));
props.add (new TextPropertyComponent (item.getValue ("text"), "Button Text", 1024, false));
props.getLast()->setTooltip ("The button's text.");
props.add (new BooleanPropertyComponent (getValue ("initialState", state, document), "Initial State", "Enabled initially"));
props.add (new BooleanPropertyComponent (item.getValue ("initialState"), "Initial State", "Enabled initially"));
addEditableColourProperties (document, state, props);
addEditableColourProperties (item, props);
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode += item.createConstructorStatement (String::empty);
}
};


+ 18
- 12
extras/Jucer (experimental)/Source/model/Component/Types/jucer_Viewport.h View File

@@ -34,7 +34,7 @@
class ViewportHandler : public ComponentTypeHelper<Viewport>
{
public:
ViewportHandler() : ComponentTypeHelper<Viewport> ("Viewport", "VIEWPORT", "viewport") {}
ViewportHandler() : ComponentTypeHelper<Viewport> ("Viewport", "Viewport", "VIEWPORT", "viewport") {}
~ViewportHandler() {}
class DemoContentComponent : public Component
@@ -60,24 +60,30 @@ public:
const Rectangle<int> getDefaultSize() { return Rectangle<int> (0, 0, 300, 200); }
void initialiseNew (ComponentDocument& document, ValueTree& state)
void initialiseNew (ComponentTypeInstance& item)
{
state.setProperty ("scrollBarV", true, 0);
state.setProperty ("scrollBarH", true, 0);
state.setProperty ("scrollbarWidth", 18, 0);
item.set ("scrollBarV", true);
item.set ("scrollBarH", true);
item.set ("scrollbarWidth", 18);
}
void update (ComponentDocument& document, Viewport* comp, const ValueTree& state)
void update (ComponentTypeInstance& item, Viewport* comp)
{
comp->setScrollBarsShown (state ["scrollBarV"], state ["scrollBarH"]);
comp->setScrollBarThickness (state ["scrollbarWidth"]);
comp->setScrollBarsShown (item ["scrollBarV"], item ["scrollBarH"]);
comp->setScrollBarThickness (item ["scrollbarWidth"]);
}
void createProperties (ComponentDocument& document, ValueTree& state, Array <PropertyComponent*>& props)
void createProperties (ComponentTypeInstance& item, Array <PropertyComponent*>& props)
{
props.add (new BooleanPropertyComponent (getValue ("scrollBarV", state, document), "Scrollbar V", "Vertical scrollbar shown"));
props.add (new BooleanPropertyComponent (getValue ("scrollBarH", state, document), "Scrollbar H", "Horizontal scrollbar shown"));
props.add (new SliderPropertyComponent (getValue ("scrollbarWidth", state, document), "Scrollbar Thickness", 3, 40, 1));
props.add (new BooleanPropertyComponent (item.getValue ("scrollBarV"), "Scrollbar V", "Vertical scrollbar shown"));
props.add (new BooleanPropertyComponent (item.getValue ("scrollBarH"), "Scrollbar H", "Horizontal scrollbar shown"));
props.add (new SliderPropertyComponent (item.getValue ("scrollbarWidth"), "Scrollbar Thickness", 3, 40, 1));
addEditableColourProperties (item, props);
}
void createCode (ComponentTypeInstance& item, CodeGenerator& code)
{
code.constructorCode << item.createConstructorStatement (CodeFormatting::stringLiteral (item.getComponentName()));
}
};


+ 34
- 19
extras/Jucer (experimental)/Source/model/Component/jucer_CodeGenerator.cpp View File

@@ -40,6 +40,12 @@ int CodeGenerator::getUniqueSuffix()
return ++suffix;
}
//==============================================================================
void CodeGenerator::addPrivateMember (const String& type, const String& name)
{
privateMemberDeclarations << type << " " << name << ";" << newLine;
}
//==============================================================================
String& CodeGenerator::getCallbackCode (const String& requiredParentClass,
const String& returnType,
@@ -121,8 +127,8 @@ const String CodeGenerator::getCallbackDefinitions() const
{
CallbackMethod* const cm = callbacks.getUnchecked(i);
const String userCodeBlockName ("User" + makeValidCppIdentifier (cm->prototype.upToFirstOccurrenceOf ("(", false, false),
true, true, false).trim());
const String userCodeBlockName ("User" + CodeFormatting::makeValidIdentifier (cm->prototype.upToFirstOccurrenceOf ("(", false, false),
true, true, false).trim());
if (userCodeBlockName.isNotEmpty() && cm->hasPrePostUserSections)
{
@@ -132,7 +138,7 @@ const String CodeGenerator::getCallbackDefinitions() const
<< " //[" << userCodeBlockName << "_Pre]" << newLine
<< " //[/" << userCodeBlockName
<< "_Pre]" << newLine << newLine
<< " " << indentCode (cm->content.trim(), 4) << newLine
<< " " << CodeFormatting::indent (cm->content.trim(), 4, false) << newLine
<< newLine
<< " //[" << userCodeBlockName << "_Post]" << newLine
<< " //[/" << userCodeBlockName << "_Post]" << newLine
@@ -143,7 +149,7 @@ const String CodeGenerator::getCallbackDefinitions() const
{
s << cm->returnType << " " << className << "::" << cm->prototype << newLine
<< "{" << newLine
<< " " << indentCode (cm->content.trim(), 4) << newLine
<< " " << CodeFormatting::indent (cm->content.trim(), 4, false) << newLine
<< "}" << newLine
<< newLine;
}
@@ -222,7 +228,7 @@ static const String getIncludeFileCode (StringArray files)
}
//==============================================================================
static void replaceTemplate (String& text, const String& itemName, const String& value)
static void replaceTemplate (String& text, const String& itemName, const String& value, bool indent = true)
{
for (;;)
{
@@ -233,16 +239,18 @@ static void replaceTemplate (String& text, const String& itemName, const String&
int indentLevel = 0;
for (int i = index; --i >= 0;)
if (indent)
{
if (text[i] == '\n')
break;
for (int i = index; --i >= 0;)
{
if (text[i] == '\n')
break;
++indentLevel;
++indentLevel;
}
}
text = text.replaceSection (index, itemName.length() + 4,
indentCode (value, indentLevel));
text = text.replaceSection (index, itemName.length() + 4, CodeFormatting::indent (value, indentLevel, false));
}
}
@@ -251,7 +259,7 @@ void CodeGenerator::applyToCode (String& code, const File& targetFile,
bool isForPreview, Project* project) const
{
replaceTemplate (code, "juceVersion", SystemStats::getJUCEVersion());
replaceTemplate (code, "headerGuard", makeHeaderGuardName (targetFile));
replaceTemplate (code, "headerGuard", CodeFormatting::makeHeaderGuardName (targetFile));
replaceTemplate (code, "className", className);
replaceTemplate (code, "constructorParams", constructorParams);
@@ -264,7 +272,7 @@ void CodeGenerator::applyToCode (String& code, const File& targetFile,
replaceTemplate (code, "methodDefinitions", getCallbackDefinitions());
if (project != 0)
replaceTemplate (code, "defaultJuceInclude", createIncludeStatement (project->getAppIncludeFile(), targetFile));
replaceTemplate (code, "defaultJuceInclude", CodeFormatting::createIncludeStatement (project->getAppIncludeFile(), targetFile));
else
replaceTemplate (code, "defaultJuceInclude", "#include \"juce_amalgamated.h\"");
@@ -284,6 +292,14 @@ void CodeGenerator::applyToCode (String& code, const File& targetFile,
replaceTemplate (code, "metadata", " << Metadata isn't shown in the code preview >>" + String (newLine));
replaceTemplate (code, "staticMemberDefinitions", "// Static member declarations and resources would go here... (these aren't shown in the code preview)");
}
{
MemoryOutputStream compDataCpp;
CodeFormatting::writeDataAsCppLiteral (componentStateData, compDataCpp);
replaceTemplate (code, "statedata", compDataCpp.toUTF8(), false);
replaceTemplate (code, "statedatasize", String ((int) componentStateData.getSize()));
}
}
@@ -389,11 +405,10 @@ void CodeGenerator::CustomCodeList::reloadFrom (const String& fileContent)
CodeDocumentRef::Ptr doc (getDocumentFor (tag, false));
if (doc == 0)
{
CodeDocument* const codeDoc = new CodeDocument();
doc = new CodeDocumentRef (codeDoc);
codeDoc->replaceAllContent (content);
codeDoc->clearUndoHistory();
codeDoc->setSavePoint();
doc = new CodeDocumentRef();
doc->getDocument().replaceAllContent (content);
doc->getDocument().clearUndoHistory();
doc->getDocument().setSavePoint();
}
newContent.add (doc);
@@ -493,7 +508,7 @@ const CodeGenerator::CustomCodeList::CodeDocumentRef::Ptr CodeGenerator::CustomC
{
sectionNames.add (sectionName);
const CodeDocumentRef::Ptr doc (new CodeDocumentRef (new CodeDocument()));
const CodeDocumentRef::Ptr doc (new CodeDocumentRef());
sectionContent.add (doc);
return doc;
}


+ 6
- 3
extras/Jucer (experimental)/Source/model/Component/jucer_CodeGenerator.h View File

@@ -51,6 +51,7 @@ public:
String destructorCode;
String staticMemberDefinitions;
String jucerMetadata;
MemoryBlock componentStateData;
struct CallbackMethod
{
@@ -60,6 +61,8 @@ public:
OwnedArray<CallbackMethod> callbacks;
void addPrivateMember (const String& type, const String& name);
String& getCallbackCode (const String& requiredParentClass,
const String& returnType,
const String& prototype,
@@ -90,13 +93,13 @@ public:
class CodeDocumentRef : public ReferenceCountedObject
{
public:
CodeDocumentRef (CodeDocument* doc_) : doc (doc_) {}
CodeDocument& getDocument() const throw() { return *doc; }
CodeDocumentRef() {}
CodeDocument& getDocument() throw() { return doc; }
typedef ReferenceCountedObjectPtr<CodeDocumentRef> Ptr;
private:
CodeDocument* const doc;
CodeDocument doc;
CodeDocumentRef (const CodeDocumentRef&);
CodeDocumentRef& operator= (const CodeDocumentRef&);


+ 36
- 21
extras/Jucer (experimental)/Source/model/Component/jucer_ComponentDocument.cpp View File

@@ -142,6 +142,17 @@ void ComponentDocument::writeCode (OutputStream& cpp, OutputStream& header)
codeGen.className = getClassName().toString();
codeGen.parentClasses = "public Component";
{
MemoryOutputStream stateStream (1024, 1024, &codeGen.componentStateData);
root.writeToStream (stateStream);
}
for (int i = 0; i < getNumComponents(); ++i)
{
ComponentTypeInstance item (*this, getComponent (i));
item.createCode (codeGen);
}
{
MemoryOutputStream metaData;
writeMetadata (metaData);
@@ -185,8 +196,8 @@ bool ComponentDocument::save()
MemoryOutputStream cpp, header;
writeCode (cpp, header);
bool savedOk = overwriteFileWithNewDataIfDifferent (cppFile, cpp)
&& overwriteFileWithNewDataIfDifferent (cppFile.withFileExtension (".h"), header);
bool savedOk = FileUtils::overwriteFileWithNewDataIfDifferent (cppFile, cpp)
&& FileUtils::overwriteFileWithNewDataIfDifferent (cppFile.withFileExtension (".h"), header);
if (savedOk)
changedSinceSaved = false;
@@ -298,6 +309,9 @@ void ComponentDocument::checkRootObject()
if ((int) getCanvasHeight().getValue() <= 0)
getCanvasHeight() = 480;
if (! root.hasProperty ("background"))
getBackgroundColour() = Colours::white.toString();
}
void ComponentDocument::setUsingTemporaryCanvasSize (bool b)
@@ -317,22 +331,27 @@ Value ComponentDocument::getCanvasHeight() const
return usingTemporaryCanvasSize ? tempCanvasHeight : getRootValueNonUndoable ("height");
}
Value ComponentDocument::getBackgroundColour() const
{
return getRootValueUndoable ("background");
}
//==============================================================================
const int menuItemOffset = 0x63451fa4;
void ComponentDocument::addNewComponentMenuItems (PopupMenu& menu) const
{
const StringArray typeNames (ComponentTypeManager::getInstance()->getTypeNames());
const StringArray displayNames (ComponentTypeManager::getInstance()->getDisplayNames());
for (int i = 0; i < typeNames.size(); ++i)
menu.addItem (i + menuItemOffset, "New " + typeNames[i]);
for (int i = 0; i < displayNames.size(); ++i)
menu.addItem (i + menuItemOffset, "New " + displayNames[i]);
}
const ValueTree ComponentDocument::performNewComponentMenuItem (int menuResultCode)
{
const StringArray typeNames (ComponentTypeManager::getInstance()->getTypeNames());
const StringArray displayNames (ComponentTypeManager::getInstance()->getDisplayNames());
if (menuResultCode >= menuItemOffset && menuResultCode < menuItemOffset + typeNames.size())
if (menuResultCode >= menuItemOffset && menuResultCode < menuItemOffset + displayNames.size())
{
ComponentTypeHandler* handler = ComponentTypeManager::getInstance()->getHandler (menuResultCode - menuItemOffset);
jassert (handler != 0);
@@ -341,7 +360,9 @@ const ValueTree ComponentDocument::performNewComponentMenuItem (int menuResultCo
{
ValueTree state (handler->getXmlTag());
state.setProperty (idProperty, createAlphaNumericUID(), 0);
handler->initialiseNewItem (*this, state);
ComponentTypeInstance comp (*this, state);
handler->initialiseNewItem (comp);
getComponentGroup().addChild (state, -1, getUndoManager());
@@ -541,7 +562,7 @@ bool ComponentDocument::setCoordsFor (ValueTree& state, const RectangleCoordinat
const String ComponentDocument::getNonexistentMemberName (String name)
{
String n (makeValidCppIdentifier (name, false, true, false));
String n (CodeFormatting::makeValidIdentifier (name, false, true, false));
int suffix = 2;
while (markersX->getMarkerNamed (n).isValid() || markersY->getMarkerNamed (n).isValid()
@@ -558,7 +579,7 @@ void ComponentDocument::renameAnchor (const String& oldName, const String& newNa
{
ValueTree v (getComponent(i));
RectangleCoordinates coords (getCoordsFor (v));
coords.renameAnchorIfUsed (oldName, newName);
coords.renameAnchorIfUsed (oldName, newName, *this);
setCoordsFor (v, coords);
}
@@ -664,11 +685,8 @@ void ComponentDocument::updateComponent (Component* comp)
if (v.isValid())
{
ComponentTypeHandler* handler = ComponentTypeManager::getInstance()->getHandlerFor (v.getType());
jassert (handler != 0);
if (handler != 0)
handler->updateComponent (*this, comp, v);
ComponentTypeInstance item (*this, v);
item.updateComponent (comp);
}
}
@@ -706,6 +724,7 @@ bool ComponentDocument::isStateForComponent (const ValueTree& storedState, Compo
void ComponentDocument::removeComponent (const ValueTree& state)
{
jassert (state.isAChildOf (getComponentGroup()));
renameAnchor (state [memberNameProperty], String::empty);
getComponentGroup().removeChild (state, getUndoManager());
}
@@ -810,12 +829,8 @@ bool ComponentDocument::createItemProperties (Array <PropertyComponent*>& props,
if (comp.isValid())
{
ComponentTypeHandler* handler = ComponentTypeManager::getInstance()->getHandlerFor (comp.getType());
jassert (handler != 0);
if (handler != 0)
handler->createPropertyEditors (*this, comp, props);
ComponentTypeInstance item (*this, comp);
item.createProperties (props);
return true;
}


+ 1
- 0
extras/Jucer (experimental)/Source/model/Component/jucer_ComponentDocument.h View File

@@ -63,6 +63,7 @@ public:
void setUsingTemporaryCanvasSize (bool b);
Value getCanvasWidth() const;
Value getCanvasHeight() const;
Value getBackgroundColour() const;
void createClassProperties (Array <PropertyComponent*>& props);


+ 1
- 1
extras/Jucer (experimental)/Source/model/Drawable/jucer_DrawableDocument.cpp View File

@@ -392,7 +392,7 @@ const String DrawableDocument::MarkerList::getNonexistentMarkerName (const Strin
const String DrawableDocument::getNonexistentMarkerName (const String& name)
{
String n (makeValidCppIdentifier (name, false, true, false));
String n (CodeFormatting::makeValidIdentifier (name, false, true, false));
int suffix = 2;
while (markersX->getMarkerNamed (n).isValid() || markersY->getMarkerNamed (n).isValid())


+ 2
- 2
extras/Jucer (experimental)/Source/model/Project/jucer_NewFileWizard.cpp View File

@@ -35,9 +35,9 @@ static bool fillInNewCppFileTemplate (const File& file, const Project::Item& ite
.replace ("FILENAME", file.getFileName(), false)
.replace ("DATE", Time::getCurrentTime().toString (true, true, true), false)
.replace ("AUTHOR", SystemStats::getFullUserName(), false)
.replace ("HEADERGUARD", makeHeaderGuardName (file), false);
.replace ("HEADERGUARD", CodeFormatting::makeHeaderGuardName (file), false);
return overwriteFileWithNewDataIfDifferent (file, s);
return FileUtils::overwriteFileWithNewDataIfDifferent (file, s);
}
//==============================================================================


+ 3
- 3
extras/Jucer (experimental)/Source/model/Project/jucer_Project.cpp View File

@@ -122,7 +122,7 @@ void Project::setMissingDefaultValues()
if (! projectRoot.getChildWithName (Tags::exporters).isValid())
createDefaultExporters();
const String sanitisedProjectName (makeValidCppIdentifier (getProjectName().toString(), false, true, false));
const String sanitisedProjectName (CodeFormatting::makeValidIdentifier (getProjectName().toString(), false, true, false));
if (! projectRoot.hasProperty ("buildVST"))
{
@@ -184,7 +184,7 @@ const String Project::saveDocument (const File& file)
getJuceConfigFlags (flags);
}
if (isJuceFolder (getLocalJuceFolder()))
if (FileUtils::isJuceFolder (getLocalJuceFolder()))
StoredSettings::getInstance()->setLastKnownJuceFolder (getLocalJuceFolder().getFullPathName());
StoredSettings::getInstance()->recentFiles.addFile (file);
@@ -310,7 +310,7 @@ const File Project::getLocalJuceFolder()
{
File f (resolveFilename (exp->getJuceFolder().toString()));
if (isJuceFolder (f))
if (FileUtils::isJuceFolder (f))
return f;
}


+ 1
- 1
extras/Jucer (experimental)/Source/model/Project/jucer_Project.h View File

@@ -85,7 +85,7 @@ public:
Value getVersion() const { return getProjectValue ("version"); }
Value getBundleIdentifier() const { return getProjectValue ("bundleIdentifier"); }
void setBundleIdentifierToDefault() { getBundleIdentifier() = "com.yourcompany." + makeValidCppIdentifier (getProjectName().toString(), false, true, false); }
void setBundleIdentifierToDefault() { getBundleIdentifier() = "com.yourcompany." + CodeFormatting::makeValidIdentifier (getProjectName().toString(), false, true, false); }
//==============================================================================
enum JuceLinkage


+ 18
- 18
extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_MSVC.h View File

@@ -130,7 +130,7 @@ public:
MemoryOutputStream mo;
writeVC6Project (mo);
if (! overwriteFileWithNewDataIfDifferent (getDSPFile(), mo))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (getDSPFile(), mo))
return "Can't write to the VC project file: " + getDSPFile().getFullPathName();
}
@@ -138,7 +138,7 @@ public:
MemoryOutputStream mo;
writeDSWFile (mo);
if (! overwriteFileWithNewDataIfDifferent (getDSWFile(), mo))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (getDSWFile(), mo))
return "Can't write to the VC solution file: " + getDSWFile().getFullPathName();
}
}
@@ -153,7 +153,7 @@ public:
MemoryOutputStream mo;
masterXml.writeToStream (mo, String::empty, false, true, "UTF-8", 10);
if (! overwriteFileWithNewDataIfDifferent (getVCProjFile(), mo))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (getVCProjFile(), mo))
return "Can't write to the VC project file: " + getVCProjFile().getFullPathName();
}
@@ -161,7 +161,7 @@ public:
MemoryOutputStream mo;
writeSolutionFile (mo);
if (! overwriteFileWithNewDataIfDifferent (getSLNFile(), mo))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (getSLNFile(), mo))
return "Can't write to the VC solution file: " + getSLNFile().getFullPathName();
}
}
@@ -352,8 +352,8 @@ private:
{
RelativePath rtasFolder (getRTASFolder().toString(), RelativePath::unknown);
defines.add ("JucePlugin_WinBag_path="
+ replaceCEscapeChars (rtasFolder.getChildFile ("WinBag")
.toWindowsStyle().quoted()));
+ CodeFormatting::addEscapeChars (rtasFolder.getChildFile ("WinBag")
.toWindowsStyle().quoted()));
}
defines.addArray (config.parsePreprocessorDefs());
@@ -424,8 +424,8 @@ private:
const String binaryName (File::createLegalFileName (config.getTargetBinaryName().toString()));
xml.setAttribute ("Name", createConfigName (config));
xml.setAttribute ("OutputDirectory", windowsStylePath (binariesPath));
xml.setAttribute ("IntermediateDirectory", windowsStylePath (intermediatesPath));
xml.setAttribute ("OutputDirectory", FileUtils::windowsStylePath (binariesPath));
xml.setAttribute ("IntermediateDirectory", FileUtils::windowsStylePath (intermediatesPath));
xml.setAttribute ("ConfigurationType", (project.isAudioPlugin() || project.isBrowserPlugin())
? "2" : (project.isLibrary() ? "4" : "1"));
xml.setAttribute ("UseOfMFC", "0");
@@ -457,7 +457,7 @@ private:
midl->setAttribute ("MkTypLibCompatible", "true");
midl->setAttribute ("SuppressStartupBanner", "true");
midl->setAttribute ("TargetEnvironment", "1");
midl->setAttribute ("TypeLibraryName", windowsStylePath (intermediatesPath + "/" + binaryName + ".tlb"));
midl->setAttribute ("TypeLibraryName", FileUtils::windowsStylePath (intermediatesPath + "/" + binaryName + ".tlb"));
midl->setAttribute ("HeaderFileName", "");
}
@@ -484,10 +484,10 @@ private:
: (isDebug ? 1 : 0)); // MT static
compiler->setAttribute ("RuntimeTypeInfo", "true");
compiler->setAttribute ("UsePrecompiledHeader", "0");
compiler->setAttribute ("PrecompiledHeaderFile", windowsStylePath (intermediatesPath + "/" + binaryName + ".pch"));
compiler->setAttribute ("AssemblerListingLocation", windowsStylePath (intermediatesPath + "/"));
compiler->setAttribute ("ObjectFile", windowsStylePath (intermediatesPath + "/"));
compiler->setAttribute ("ProgramDataBaseFileName", windowsStylePath (intermediatesPath + "/"));
compiler->setAttribute ("PrecompiledHeaderFile", FileUtils::windowsStylePath (intermediatesPath + "/" + binaryName + ".pch"));
compiler->setAttribute ("AssemblerListingLocation", FileUtils::windowsStylePath (intermediatesPath + "/"));
compiler->setAttribute ("ObjectFile", FileUtils::windowsStylePath (intermediatesPath + "/"));
compiler->setAttribute ("ProgramDataBaseFileName", FileUtils::windowsStylePath (intermediatesPath + "/"));
compiler->setAttribute ("WarningLevel", "3");
compiler->setAttribute ("SuppressStartupBanner", "true");
@@ -508,7 +508,7 @@ private:
{
XmlElement* linker = createToolElement (xml, "VCLinkerTool");
linker->setAttribute ("OutputFile", windowsStylePath (binariesPath + "/" + config.getTargetBinaryName().toString() + getTargetBinarySuffix()));
linker->setAttribute ("OutputFile", FileUtils::windowsStylePath (binariesPath + "/" + config.getTargetBinaryName().toString() + getTargetBinarySuffix()));
linker->setAttribute ("SuppressStartupBanner", "true");
if (project.getJuceLinkageMode() == Project::useLinkedJuce)
@@ -516,7 +516,7 @@ private:
linker->setAttribute ("IgnoreDefaultLibraryNames", isDebug ? "libcmt.lib, msvcrt.lib" : "");
linker->setAttribute ("GenerateDebugInformation", isDebug ? "true" : "false");
linker->setAttribute ("ProgramDatabaseFile", windowsStylePath (intermediatesPath + "/" + binaryName + ".pdb"));
linker->setAttribute ("ProgramDatabaseFile", FileUtils::windowsStylePath (intermediatesPath + "/" + binaryName + ".pdb"));
linker->setAttribute ("SubSystem", project.isCommandLineApp() ? "1" : "2");
if (! isDebug)
@@ -546,7 +546,7 @@ private:
{
XmlElement* librarian = createToolElement (xml, "VCLibrarianTool");
librarian->setAttribute ("OutputFile", windowsStylePath (binariesPath + "/" + config.getTargetBinaryName().toString() + getTargetBinarySuffix()));
librarian->setAttribute ("OutputFile", FileUtils::windowsStylePath (binariesPath + "/" + config.getTargetBinaryName().toString() + getTargetBinarySuffix()));
librarian->setAttribute ("IgnoreDefaultLibraryNames", isDebug ? "libcmt.lib, msvcrt.lib" : "");
}
@@ -557,7 +557,7 @@ private:
{
XmlElement* bscMake = createToolElement (xml, "VCBscMakeTool");
bscMake->setAttribute ("SuppressStartupBanner", "true");
bscMake->setAttribute ("OutputFile", windowsStylePath (intermediatesPath + "/" + binaryName + ".bsc"));
bscMake->setAttribute ("OutputFile", FileUtils::windowsStylePath (intermediatesPath + "/" + binaryName + ".bsc"));
}
createToolElement (xml, "VCFxCopTool");
@@ -683,7 +683,7 @@ private:
targetList << "# Name \"" << configName << '"' << newLine;
const String binariesPath (getConfigTargetPath (config));
const String targetBinary (windowsStylePath (binariesPath + "/" + config.getTargetBinaryName().toString() + getTargetBinarySuffix()));
const String targetBinary (FileUtils::windowsStylePath (binariesPath + "/" + config.getTargetBinaryName().toString() + getTargetBinarySuffix()));
const String optimisationFlag (((int) config.getOptimisationLevel().getValue() <= 1) ? "Od" : (config.getOptimisationLevel() == 2 ? "O2" : "O3"));
const String defines (getPreprocessorDefs (config, " /D "));
const bool isDebug = (bool) config.isDebug().getValue();


+ 2
- 2
extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_Make.h View File

@@ -101,7 +101,7 @@ public:
writeMakefile (mo, files);
const File makefile (getTargetFolder().getChildFile ("Makefile"));
if (! overwriteFileWithNewDataIfDifferent (makefile, mo))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (makefile, mo))
return "Can't write to the Makefile: " + makefile.getFullPathName();
return String::empty;
@@ -151,7 +151,7 @@ private:
headerPaths.insert (0, "/usr/include");
for (int i = 0; i < headerPaths.size(); ++i)
out << " -I " << unixStylePath (headerPaths[i]).quoted();
out << " -I " << FileUtils::unixStylePath (headerPaths[i]).quoted();
}
void writeCppFlags (OutputStream& out, const Project::BuildConfiguration& config)


+ 2
- 2
extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExport_XCode.h View File

@@ -122,7 +122,7 @@ public:
MemoryOutputStream mo;
writeProjectFile (mo);
if (! overwriteFileWithNewDataIfDifferent (projectFile, mo))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (projectFile, mo))
return "Can't write to file: " + projectFile.getFullPathName();
}
@@ -266,7 +266,7 @@ private:
MemoryOutputStream mo;
plist.writeToStream (mo, "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
return overwriteFileWithNewDataIfDifferent (infoPlistFile, mo);
return FileUtils::overwriteFileWithNewDataIfDifferent (infoPlistFile, mo);
}
const StringArray getHeaderSearchPaths (const Project::BuildConfiguration& config)


+ 2
- 2
extras/Jucer (experimental)/Source/model/Project/jucer_ProjectExporter.cpp View File

@@ -75,7 +75,7 @@ ProjectExporter* ProjectExporter::createNewExporter (Project& project, const int
File juceFolder (StoredSettings::getInstance()->getLastKnownJuceFolder());
File target (exp->getTargetFolder());
if (shouldPathsBeRelative (juceFolder.getFullPathName(), project.getFile().getFullPathName()))
if (FileUtils::shouldPathsBeRelative (juceFolder.getFullPathName(), project.getFile().getFullPathName()))
exp->getJuceFolder() = juceFolder.getRelativePathFrom (project.getFile().getParentDirectory());
else
exp->getJuceFolder() = juceFolder.getFullPathName();
@@ -121,7 +121,7 @@ const String ProjectExporter::getIncludePathForFileInJuceFolder (const String& p
if (juceFolderPath.startsWithChar ('<'))
{
juceFolderPath = unixStylePath (File::addTrailingSeparator (juceFolderPath.substring (1).dropLastCharacters(1)));
juceFolderPath = FileUtils::unixStylePath (File::addTrailingSeparator (juceFolderPath.substring (1).dropLastCharacters(1)));
if (juceFolderPath == "/")
juceFolderPath = String::empty;


+ 7
- 7
extras/Jucer (experimental)/Source/model/Project/jucer_ProjectSaver.h View File

@@ -123,7 +123,7 @@ private:
MemoryOutputStream mo;
xml->writeToStream (mo, String::empty);
if (! overwriteFileWithNewDataIfDifferent (projectFile, mo))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (projectFile, mo))
errors.add ("Couldn't write to the target file!");
}
}
@@ -192,7 +192,7 @@ private:
<< newLine
<< "*/"
<< newLine << newLine
<< createIncludeStatement (appConfigFile, appConfigFile) << newLine;
<< CodeFormatting::createIncludeStatement (appConfigFile, appConfigFile) << newLine;
if (fileNumber == 0)
writeInclude (out, project.isUsingFullyAmalgamatedFile() ? "juce_amalgamated.cpp"
@@ -216,7 +216,7 @@ private:
<< "#define " << headerGuard << newLine << newLine;
if (hasAppConfigFile)
out << createIncludeStatement (appConfigFile, appConfigFile) << newLine;
out << CodeFormatting::createIncludeStatement (appConfigFile, appConfigFile) << newLine;
if (project.getJuceLinkageMode() != Project::notLinkedToJuce)
{
@@ -228,13 +228,13 @@ private:
}
if (binaryDataCpp.exists())
out << createIncludeStatement (binaryDataCpp.withFileExtension (".h"), appConfigFile) << newLine;
out << CodeFormatting::createIncludeStatement (binaryDataCpp.withFileExtension (".h"), appConfigFile) << newLine;
out << newLine
<< "namespace ProjectInfo" << newLine
<< "{" << newLine
<< " const char* const projectName = " << replaceCEscapeChars (project.getProjectName().toString()).quoted() << ";" << newLine
<< " const char* const versionString = " << replaceCEscapeChars (project.getVersion().toString()).quoted() << ";" << newLine
<< " const char* const projectName = " << CodeFormatting::addEscapeChars (project.getProjectName().toString()).quoted() << ";" << newLine
<< " const char* const versionString = " << CodeFormatting::addEscapeChars (project.getVersion().toString()).quoted() << ";" << newLine
<< " const int versionNumber = " << createVersionCode (project.getVersion().toString()) << ";" << newLine
<< "}" << newLine
<< newLine
@@ -370,7 +370,7 @@ private:
bool replaceFileIfDifferent (const File& f, const MemoryOutputStream& newData)
{
if (! overwriteFileWithNewDataIfDifferent (f, newData))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (f, newData))
{
errors.add ("Can't write to file: " + f.getFullPathName());
return false;


+ 28
- 28
extras/Jucer (experimental)/Source/model/Project/jucer_ProjectWizard.cpp View File

@@ -79,30 +79,30 @@ public:
for (int i = project.getNumConfigurations(); --i >= 0;)
project.getConfiguration(i).getTargetBinaryName() = File::createLegalFileName (appTitle);
String appHeaders (createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
String appHeaders (CodeFormatting::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
String initCode, shutdownCode, anotherInstanceStartedCode, privateMembers, memberInitialisers;
if (createWindow)
{
appHeaders << newLine << createIncludeStatement (mainWindowH, mainCppFile);
appHeaders << newLine << CodeFormatting::createIncludeStatement (mainWindowH, mainCppFile);
memberInitialisers = " : mainWindow (0)";
initCode = "mainWindow = new " + windowClassName + "();";
shutdownCode = "deleteAndZero (mainWindow);";
privateMembers = windowClassName + "* mainWindow;";
String windowH = project.getFileTemplate ("jucer_WindowTemplate_h")
.replace ("INCLUDES", createIncludeStatement (project.getAppIncludeFile(), mainWindowH), false)
.replace ("INCLUDES", CodeFormatting::createIncludeStatement (project.getAppIncludeFile(), mainWindowH), false)
.replace ("WINDOWCLASS", windowClassName, false)
.replace ("HEADERGUARD", makeHeaderGuardName (mainWindowH), false);
.replace ("HEADERGUARD", CodeFormatting::makeHeaderGuardName (mainWindowH), false);
String windowCpp = project.getFileTemplate ("jucer_WindowTemplate_cpp")
.replace ("INCLUDES", createIncludeStatement (mainWindowH, mainWindowCpp), false)
.replace ("INCLUDES", CodeFormatting::createIncludeStatement (mainWindowH, mainWindowCpp), false)
.replace ("WINDOWCLASS", windowClassName, false);
if (! overwriteFileWithNewDataIfDifferent (mainWindowH, windowH))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (mainWindowH, windowH))
failedFiles.add (mainWindowH.getFullPathName());
if (! overwriteFileWithNewDataIfDifferent (mainWindowCpp, windowCpp))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (mainWindowCpp, windowCpp))
failedFiles.add (mainWindowCpp.getFullPathName());
group.addFile (mainWindowCpp, -1);
@@ -113,17 +113,17 @@ public:
{
String mainCpp = project.getFileTemplate ("jucer_MainTemplate_cpp")
.replace ("APPHEADERS", appHeaders, false)
.replace ("APPCLASSNAME", makeValidCppIdentifier (appTitle + "Application", false, true, false), false)
.replace ("APPCLASSNAME", CodeFormatting::makeValidIdentifier (appTitle + "Application", false, true, false), false)
.replace ("MEMBERINITIALISERS", memberInitialisers, false)
.replace ("APPINITCODE", initCode, false)
.replace ("APPSHUTDOWNCODE", shutdownCode, false)
.replace ("APPNAME", replaceCEscapeChars (appTitle), false)
.replace ("APPNAME", CodeFormatting::addEscapeChars (appTitle), false)
.replace ("APPVERSION", "1.0", false)
.replace ("ALLOWMORETHANONEINSTANCE", "true", false)
.replace ("ANOTHERINSTANCECODE", anotherInstanceStartedCode, false)
.replace ("PRIVATEMEMBERS", privateMembers, false);
if (! overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
failedFiles.add (mainCppFile.getFullPathName());
group.addFile (mainCppFile, -1);
@@ -186,12 +186,12 @@ public:
if (createMainCpp)
{
String appHeaders (createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
String appHeaders (CodeFormatting::createIncludeStatement (project.getAppIncludeFile(), mainCppFile));
String mainCpp = project.getFileTemplate ("jucer_MainConsoleAppTemplate_cpp")
.replace ("APPHEADERS", appHeaders, false);
if (! overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
failedFiles.add (mainCppFile.getFullPathName());
group.addFile (mainCppFile, -1);
@@ -228,7 +228,7 @@ public:
if (! getSourceFilesFolder().createDirectory())
failedFiles.add (getSourceFilesFolder().getFullPathName());
String filterClassName = makeValidCppIdentifier (appTitle, true, true, false) + "AudioProcessor";
String filterClassName = CodeFormatting::makeValidIdentifier (appTitle, true, true, false) + "AudioProcessor";
filterClassName = filterClassName.substring (0, 1).toUpperCase() + filterClassName.substring (1);
String editorClassName = filterClassName + "Editor";
@@ -247,42 +247,42 @@ public:
for (int i = project.getNumConfigurations(); --i >= 0;)
project.getConfiguration(i).getTargetBinaryName() = File::createLegalFileName (appTitle);
String appHeaders (createIncludeStatement (project.getAppIncludeFile(), filterCppFile));
appHeaders << newLine << createIncludeStatement (project.getPluginCharacteristicsFile(), filterCppFile);
String appHeaders (CodeFormatting::createIncludeStatement (project.getAppIncludeFile(), filterCppFile));
appHeaders << newLine << CodeFormatting::createIncludeStatement (project.getPluginCharacteristicsFile(), filterCppFile);
String filterCpp = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_cpp")
.replace ("FILTERHEADERS", createIncludeStatement (filterHFile, filterCppFile)
+ newLine + createIncludeStatement (editorHFile, filterCppFile), false)
.replace ("FILTERHEADERS", CodeFormatting::createIncludeStatement (filterHFile, filterCppFile)
+ newLine + CodeFormatting::createIncludeStatement (editorHFile, filterCppFile), false)
.replace ("FILTERCLASSNAME", filterClassName, false)
.replace ("EDITORCLASSNAME", editorClassName, false);
String filterH = project.getFileTemplate ("jucer_AudioPluginFilterTemplate_h")
.replace ("APPHEADERS", appHeaders, false)
.replace ("FILTERCLASSNAME", filterClassName, false)
.replace ("HEADERGUARD", makeHeaderGuardName (filterHFile), false);
.replace ("HEADERGUARD", CodeFormatting::makeHeaderGuardName (filterHFile), false);
String editorCpp = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_cpp")
.replace ("EDITORCPPHEADERS", createIncludeStatement (filterHFile, filterCppFile)
+ newLine + createIncludeStatement (editorHFile, filterCppFile), false)
.replace ("EDITORCPPHEADERS", CodeFormatting::createIncludeStatement (filterHFile, filterCppFile)
+ newLine + CodeFormatting::createIncludeStatement (editorHFile, filterCppFile), false)
.replace ("FILTERCLASSNAME", filterClassName, false)
.replace ("EDITORCLASSNAME", editorClassName, false);
String editorH = project.getFileTemplate ("jucer_AudioPluginEditorTemplate_h")
.replace ("EDITORHEADERS", appHeaders + newLine + createIncludeStatement (filterHFile, filterCppFile), false)
.replace ("EDITORHEADERS", appHeaders + newLine + CodeFormatting::createIncludeStatement (filterHFile, filterCppFile), false)
.replace ("FILTERCLASSNAME", filterClassName, false)
.replace ("EDITORCLASSNAME", editorClassName, false)
.replace ("HEADERGUARD", makeHeaderGuardName (editorHFile), false);
.replace ("HEADERGUARD", CodeFormatting::makeHeaderGuardName (editorHFile), false);
if (! overwriteFileWithNewDataIfDifferent (filterCppFile, filterCpp))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (filterCppFile, filterCpp))
failedFiles.add (filterCppFile.getFullPathName());
if (! overwriteFileWithNewDataIfDifferent (filterHFile, filterH))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (filterHFile, filterH))
failedFiles.add (filterHFile.getFullPathName());
if (! overwriteFileWithNewDataIfDifferent (editorCppFile, editorCpp))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (editorCppFile, editorCpp))
failedFiles.add (editorCppFile.getFullPathName());
if (! overwriteFileWithNewDataIfDifferent (editorHFile, editorH))
if (! FileUtils::overwriteFileWithNewDataIfDifferent (editorHFile, editorH))
failedFiles.add (editorHFile.getFullPathName());
group.addFile (filterCppFile, -1);
@@ -381,7 +381,7 @@ Project* ProjectWizard::runWizard (Component* ownerWindow_)
failedFiles.add (newProjectFolder.getFullPathName());
}
if (containsAnyNonHiddenFiles (newProjectFolder))
if (FileUtils::containsAnyNonHiddenFiles (newProjectFolder))
{
if (! AlertWindow::showOkCancelBox (AlertWindow::InfoIcon, "New Juce Project",
"The folder you chose isn't empty - are you sure you want to create the project there?\n\nAny existing files with the same names may be overwritten by the new files."))
@@ -480,7 +480,7 @@ Project* ProjectWizard::runNewProjectWizard (Component* ownerWindow)
if (aw.runModalLoop() == 0)
return 0;
if (isJuceFolder (juceFolderSelector.getCurrentFile()))
if (FileUtils::isJuceFolder (juceFolderSelector.getCurrentFile()))
{
wizard = createWizard (aw.getComboBoxComponent ("type")->getSelectedItemIndex());
break;


+ 13
- 86
extras/Jucer (experimental)/Source/model/Project/jucer_ResourceFile.cpp View File

@@ -100,83 +100,6 @@ int64 ResourceFile::getTotalDataSize() const
return total;
}
static void writeCppData (InputStream& in, OutputStream& out)
{
const int maxCharsOnLine = 250;
MemoryBlock mb;
in.readIntoMemoryBlock (mb);
const unsigned char* data = (const unsigned char*) mb.getData();
int charsOnLine = 0;
bool canUseStringLiteral = mb.getSize() < 65535; // MS compilers can't handle strings bigger than 65536 chars..
if (canUseStringLiteral)
{
for (size_t i = 0; i < mb.getSize(); ++i)
{
const unsigned int num = (unsigned int) data[i];
if (! ((num >= 32 && num < 127) || num == '\t' || num == '\r' || num == '\n'))
{
canUseStringLiteral = false;
break;
}
}
}
if (! canUseStringLiteral)
{
out << "{ ";
for (size_t i = 0; i < mb.getSize(); ++i)
{
const int num = (int) (unsigned int) data[i];
out << num << ',';
charsOnLine += 2;
if (num >= 10)
++charsOnLine;
if (num >= 100)
++charsOnLine;
if (charsOnLine >= maxCharsOnLine)
{
charsOnLine = 0;
out << newLine;
}
}
out << "0,0 };";
}
else
{
out << "\"";
for (size_t i = 0; i < mb.getSize(); ++i)
{
const unsigned int num = (unsigned int) data[i];
switch (num)
{
case '\t': out << "\\t"; break;
case '\r': out << "\\r"; break;
case '\n': out << "\\n"; charsOnLine = maxCharsOnLine; break;
case '"': out << "\\\""; break;
case '\\': out << "\\\\"; break;
default: out << (char) num; break;
}
if (++charsOnLine >= maxCharsOnLine && i < mb.getSize() - 1)
{
charsOnLine = 0;
out << "\"" << newLine << "\"";
}
}
out << "\";";
}
}
static int calcResourceHashCode (const String& s)
{
const char* t = s.toUTF8();
@@ -202,7 +125,7 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream&
<< comment;
if (juceHeader.exists())
header << createIncludeStatement (juceHeader, cppFile) << newLine;
header << CodeFormatting::createIncludeStatement (juceHeader, cppFile) << newLine;
const String namespaceName (className);
StringArray variableNames;
@@ -210,10 +133,10 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream&
int i;
for (i = 0; i < files.size(); ++i)
{
String variableNameRoot (makeValidCppIdentifier (files.getUnchecked(i)->getFileName()
.replaceCharacters (" .", "__")
.retainCharacters ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"),
false, true, false));
String variableNameRoot (CodeFormatting::makeValidIdentifier (files.getUnchecked(i)->getFileName()
.replaceCharacters (" .", "__")
.retainCharacters ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"),
false, true, false));
String variableName (variableNameRoot);
int suffix = 2;
@@ -223,7 +146,7 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream&
variableNames.add (variableName);
}
cpp << createIncludeStatement (cppFile.withFileExtension (".h"), cppFile) << newLine
cpp << CodeFormatting::createIncludeStatement (cppFile.withFileExtension (".h"), cppFile) << newLine
<< newLine
<< newLine
<< "const char* " << namespaceName << "::getNamedResource (const char* resourceNameUTF8, int& numBytes) throw()" << newLine
@@ -273,7 +196,11 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream&
<< "static const unsigned char " << tempVariable
<< "[] =" << newLine;
writeCppData (*fileStream, cpp);
{
MemoryBlock data;
fileStream->readIntoMemoryBlock (data);
CodeFormatting::writeDataAsCppLiteral (data, cpp);
}
cpp << newLine << newLine
<< "const char* " << namespaceName << "::" << variableName << " = (const char*) "
@@ -304,8 +231,8 @@ bool ResourceFile::write (const File& cppFile)
cppOut = 0;
hppOut = 0;
return (areFilesIdentical (tempCpp.getFile(), tempCpp.getTargetFile()) || tempCpp.overwriteTargetFileWithTemporary())
&& (areFilesIdentical (tempH.getFile(), tempH.getTargetFile()) || tempH.overwriteTargetFileWithTemporary());
return (FileUtils::areFilesIdentical (tempCpp.getFile(), tempCpp.getTargetFile()) || tempCpp.overwriteTargetFileWithTemporary())
&& (FileUtils::areFilesIdentical (tempH.getFile(), tempH.getTargetFile()) || tempH.overwriteTargetFileWithTemporary());
}
}


+ 10
- 0
extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.cpp View File

@@ -24,9 +24,15 @@
//[MiscUserDefs] You can add your own user definitions and misc code here...
//[/MiscUserDefs]
extern const unsigned char %%className%%_ComponentStateData[];
//==============================================================================
%%className%%::%%className%% (%%constructorParams%%)
%%initialisers%%{
componentState = ValueTree::readFromData (%%className%%_ComponentStateData, %%statedatasize%%);
jassert (componentState.isValid());
const ValueTree componentStateList (componentState.getChildByName ("COMPONENTS"));
%%constructor%%
//[Constructor] You can add your own custom stuff here..
@@ -52,6 +58,10 @@
%%staticMemberDefinitions%%
//==============================================================================
/* This data contains the ValueTree that holds all the Jucer-generated settings for the components */
const unsigned char %%className%%_ComponentStateData[] = %%statedata%%;
//==============================================================================
//======================= Jucer Information Section ==========================
//==============================================================================


+ 2
- 0
extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.h View File

@@ -57,6 +57,8 @@ private:
%%privateMemberDeclarations%%
//==============================================================================
ValueTree componentState;
// (prevent copy constructor and operator= being generated..)
%%className%% (const %%className%%&);
%%className%%& operator= (const %%className%%&);


+ 36
- 5
extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h View File

@@ -59,7 +59,7 @@ public:
Component* createComponentHolder()
{
return new ComponentHolder();
return new ComponentHolder (getDocument().getBackgroundColour());
}
void updateComponents()
@@ -222,24 +222,55 @@ private:
//==============================================================================
ComponentEditor& editor;
class ComponentHolder : public Component
class ComponentHolder : public Component,
public Value::Listener
{
public:
ComponentHolder()
ComponentHolder (const Value& backgroundColour_)
: backgroundColour (backgroundColour_)
{
setOpaque (true);
updateColour();
backgroundColour.addListener (this);
}
~ComponentHolder()
{
}
void updateColour()
{
Colour newColour (Colours::white);
if (backgroundColour.toString().isNotEmpty())
newColour = Colour::fromString (backgroundColour.toString());
if (newColour != colour)
{
colour = newColour;
repaint();
}
}
void paint (Graphics& g)
{
g.fillAll (Colours::white);
if (colour.isOpaque())
g.fillAll (colour);
else
g.fillCheckerBoard (0, 0, getWidth(), getHeight(), 24, 24,
Colour (0xffeeeeee).overlaidWith (colour),
Colour (0xffffffff).overlaidWith (colour));
}
};
void valueChanged (Value&)
{
updateColour();
}
private:
Value backgroundColour;
Colour colour;
};
};


+ 30
- 5
extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorToolbar.h View File

@@ -26,6 +26,8 @@
#ifndef __JUCER_COMPONENTEDITORTOOLBAR_H_6B5CA931__
#define __JUCER_COMPONENTEDITORTOOLBAR_H_6B5CA931__
#include "../../utility/jucer_ColourEditorComponent.h"
//==============================================================================
class JucerToolbarButton : public ToolbarItemComponent
@@ -103,6 +105,25 @@ public:
}
};
//==============================================================================
class BackgroundColourToolbarButton : public JucerToolbarButton
{
public:
BackgroundColourToolbarButton (ComponentEditor& editor_, int itemId_)
: JucerToolbarButton (editor_, itemId_, "background")
{
setTriggeredOnMouseDown (true);
}
void clicked()
{
editor.getDocument().getUndoManager()->beginNewTransaction();
PopupColourSelector::showAt (this, editor.getDocument().getBackgroundColour(), Colours::white, true);
}
};
//==============================================================================
class ComponentEditorToolbarFactory : public ToolbarItemFactory
{
@@ -120,15 +141,17 @@ public:
enum DemoToolbarItemIds
{
createComponent = 1,
showInfo = 2,
showComponentTree = 3,
showOrHideMarkers = 4,
toggleSnapping = 5
changeBackground,
showInfo,
showComponentTree,
showOrHideMarkers,
toggleSnapping
};
void getAllToolbarItemIds (Array <int>& ids)
{
ids.add (createComponent);
ids.add (changeBackground);
ids.add (showInfo);
ids.add (showComponentTree);
ids.add (showOrHideMarkers);
@@ -143,6 +166,7 @@ public:
{
ids.add (spacerId);
ids.add (createComponent);
ids.add (changeBackground);
ids.add (flexibleSpacerId);
ids.add (showOrHideMarkers);
ids.add (toggleSnapping);
@@ -159,7 +183,8 @@ public:
switch (itemId)
{
case createComponent: name = "new"; return new NewComponentToolbarButton (editor, createComponent);
case createComponent: return new NewComponentToolbarButton (editor, itemId);
case changeBackground: return new BackgroundColourToolbarButton (editor, itemId);
case showInfo: name = "info"; commandId = CommandIDs::showOrHideProperties; break;
case showComponentTree: name = "tree"; commandId = CommandIDs::showOrHideTree; break;
case showOrHideMarkers: name = "markers"; commandId = CommandIDs::showOrHideMarkers; break;


+ 2
- 2
extras/Jucer (experimental)/Source/ui/Editor Base/jucer_EditorCanvas.cpp View File

@@ -655,8 +655,8 @@ public:
{
const Rectangle<int> content (getContentArea());
// g.setColour (Colour::greyLevel (0.7f).withAlpha (0.4f));
// g.drawRect (content.expanded (resizerThickness, resizerThickness), resizerThickness);
g.setColour (Colour::greyLevel (0.1f).withAlpha (0.3f));
g.drawRect (content.expanded (1, 1), 1);
const int bottomGap = getHeight() - content.getBottom();
g.setFont (bottomGap - 5.0f);


+ 3
- 2
extras/Jucer (experimental)/Source/ui/Editor Base/jucer_EditorPanel.h View File

@@ -43,7 +43,7 @@ public:
tree->setRootItemVisible (true);
tree->setMultiSelectEnabled (true);
tree->setDefaultOpenness (true);
tree->setColour (TreeView::backgroundColourId, Colours::white);
tree->setColour (TreeView::backgroundColourId, Colour::greyLevel (0.92f));
tree->setIndentSize (15);
}
@@ -175,7 +175,7 @@ private:
PropertyPanel* props;
};
//==============================================================================
class CanvasViewport : public Viewport
{
public:
@@ -202,6 +202,7 @@ private:
}
};
//==============================================================================
Toolbar* toolbar;
Viewport* viewport;
InfoPanel* infoPanel;


+ 111
- 86
extras/Jucer (experimental)/Source/utility/jucer_ColourEditorComponent.h View File

@@ -27,13 +27,121 @@
#define __JUCER_COLOUREDITORCOMPONENT_JUCEHEADER__
//==============================================================================
class PopupColourSelector : public Component,
public ChangeListener,
public Value::Listener,
public ButtonListener
{
public:
PopupColourSelector (const Value& colourValue_,
const Colour& defaultColour_,
const bool canResetToDefault)
: defaultButton ("Reset to Default"),
colourValue (colourValue_),
defaultColour (defaultColour_)
{
addAndMakeVisible (&selector);
selector.setName ("Colour");
selector.setCurrentColour (getColour());
selector.addChangeListener (this);
if (canResetToDefault)
{
addAndMakeVisible (&defaultButton);
defaultButton.addButtonListener (this);
}
colourValue.addListener (this);
}
~PopupColourSelector()
{
}
static void showAt (Component* comp, const Value& colourValue,
const Colour& defaultColour, const bool canResetToDefault)
{
PopupColourSelector colourSelector (colourValue, defaultColour, canResetToDefault);
PopupMenu m;
m.addCustomItem (1234, &colourSelector, 300, 400, false);
m.showAt (comp);
}
void resized()
{
if (defaultButton.isVisible())
{
selector.setBounds (0, 0, getWidth(), getHeight() - 30);
defaultButton.changeWidthToFitText (22);
defaultButton.setTopLeftPosition (10, getHeight() - 26);
}
else
{
selector.setBounds (0, 0, getWidth(), getHeight());
}
}
const Colour getColour() const
{
if (colourValue.toString().isEmpty())
return defaultColour;
return Colour::fromString (colourValue.toString());
}
void setColour (const Colour& newColour)
{
if (getColour() != newColour)
{
if (newColour == defaultColour && defaultButton.isVisible())
colourValue = var::null;
else
colourValue = newColour.toDisplayString (true);
}
}
void buttonClicked (Button*)
{
setColour (defaultColour);
selector.setCurrentColour (defaultColour);
}
void changeListenerCallback (void* source)
{
if (selector.getCurrentColour() != getColour())
setColour (selector.getCurrentColour());
}
void valueChanged (Value&)
{
selector.setCurrentColour (getColour());
}
private:
class ColourSelectorWithSwatches : public ColourSelector
{
public:
ColourSelectorWithSwatches() {}
int getNumSwatches() const { return StoredSettings::getInstance()->swatchColours.size(); }
const Colour getSwatchColour (int index) const { return StoredSettings::getInstance()->swatchColours [index]; }
void setSwatchColour (int index, const Colour& newColour) const { StoredSettings::getInstance()->swatchColours.set (index, newColour); }
};
ColourSelectorWithSwatches selector;
TextButton defaultButton;
Value colourValue;
Colour defaultColour;
};
//==============================================================================
/**
A component that shows a colour swatch with hex ARGB value, and which pops up
a colour selector when you click it.
*/
class ColourEditorComponent : public Component,
public ChangeListener,
public Value::Listener
{
public:
@@ -47,7 +155,6 @@ public:
~ColourEditorComponent()
{
colourValue.removeListener (this);
}
void paint (Graphics& g)
@@ -80,7 +187,7 @@ public:
if (getColour() != newColour)
{
if (newColour == defaultColour && canResetToDefault)
colourValue = var();
colourValue = var::null;
else
colourValue = newColour.toDisplayString (true);
}
@@ -105,19 +212,7 @@ public:
void mouseDown (const MouseEvent& e)
{
document.getUndoManager()->beginNewTransaction();
SafePointer<Component> deletionChecker (this);
{
ColourSelectorComp colourSelector (this, canResetToDefault);
PopupMenu m;
m.addCustomItem (1234, &colourSelector, 300, 400, false);
m.showAt (this);
if (deletionChecker == 0)
return;
}
PopupColourSelector::showAt (this, colourValue, defaultColour, canResetToDefault);
}
void valueChanged (Value&)
@@ -125,14 +220,6 @@ public:
refresh();
}
void changeListenerCallback (void* source)
{
ColourSelector* cs = static_cast <ColourSelector*> (source);
if (cs->getCurrentColour() != getColour())
setColour (cs->getCurrentColour());
}
juce_UseDebuggingNewOperator
private:
@@ -141,68 +228,6 @@ private:
Colour lastColour;
const Colour defaultColour;
const bool canResetToDefault;
class ColourSelectorComp : public Component,
public ButtonListener
{
public:
ColourSelectorComp (ColourEditorComponent* owner_,
const bool canResetToDefault)
: owner (owner_),
defaultButton ("Reset to Default")
{
addAndMakeVisible (&selector);
selector.setName ("Colour");
selector.setCurrentColour (owner->getColour());
selector.addChangeListener (owner);
if (canResetToDefault)
{
addAndMakeVisible (&defaultButton);
defaultButton.addButtonListener (this);
}
}
~ColourSelectorComp()
{
}
void resized()
{
if (defaultButton.isVisible())
{
selector.setBounds (0, 0, getWidth(), getHeight() - 30);
defaultButton.changeWidthToFitText (22);
defaultButton.setTopLeftPosition (10, getHeight() - 26);
}
else
{
selector.setBounds (0, 0, getWidth(), getHeight());
}
}
void buttonClicked (Button*)
{
owner->resetToDefault();
owner->refresh();
selector.setCurrentColour (owner->getColour());
}
private:
class ColourSelectorWithSwatches : public ColourSelector
{
public:
ColourSelectorWithSwatches() {}
int getNumSwatches() const { return StoredSettings::getInstance()->swatchColours.size(); }
const Colour getSwatchColour (int index) const { return StoredSettings::getInstance()->swatchColours [index]; }
void setSwatchColour (int index, const Colour& newColour) const { StoredSettings::getInstance()->swatchColours.set (index, newColour); }
};
ColourEditorComponent* owner;
ColourSelectorWithSwatches selector;
TextButton defaultButton;
};
};
//==============================================================================


+ 27
- 10
extras/Jucer (experimental)/Source/utility/jucer_Coordinate.cpp View File

@@ -338,13 +338,29 @@ void Coordinate::changeAnchor2 (const String& newMarkerName, const MarkerResolve
moveToAbsolute (oldValue, markerResolver);
}
void Coordinate::renameAnchorIfUsed (const String& oldName, const String& newName)
void Coordinate::renameAnchorIfUsed (const String& oldName, const String& newName, const MarkerResolver& markerResolver)
{
if (anchor1.upToFirstOccurrenceOf (".", false, false) == oldName)
anchor1 = newName + anchor1.fromFirstOccurrenceOf (".", true, false);
jassert (oldName.isNotEmpty());
if (anchor2.upToFirstOccurrenceOf (".", false, false) == oldName)
anchor2 = newName + anchor2.fromFirstOccurrenceOf (".", true, false);
if (newName.isEmpty())
{
if (anchor1.upToFirstOccurrenceOf (".", false, false) == oldName
|| anchor2.upToFirstOccurrenceOf (".", false, false) == oldName)
{
value = resolve (markerResolver);
isProportion = false;
anchor1 = String::empty;
anchor2 = String::empty;
}
}
else
{
if (anchor1.upToFirstOccurrenceOf (".", false, false) == oldName)
anchor1 = newName + anchor1.fromFirstOccurrenceOf (".", true, false);
if (anchor2.upToFirstOccurrenceOf (".", false, false) == oldName)
anchor2 = newName + anchor2.fromFirstOccurrenceOf (".", true, false);
}
}
//==============================================================================
@@ -396,10 +412,11 @@ const String RectangleCoordinates::toString() const
return left.toString() + ", " + top.toString() + ", " + right.toString() + ", " + bottom.toString();
}
void RectangleCoordinates::renameAnchorIfUsed (const String& oldName, const String& newName)
void RectangleCoordinates::renameAnchorIfUsed (const String& oldName, const String& newName,
const Coordinate::MarkerResolver& markerResolver)
{
left.renameAnchorIfUsed (oldName, newName);
right.renameAnchorIfUsed (oldName, newName);
top.renameAnchorIfUsed (oldName, newName);
bottom.renameAnchorIfUsed (oldName, newName);
left.renameAnchorIfUsed (oldName, newName, markerResolver);
right.renameAnchorIfUsed (oldName, newName, markerResolver);
top.renameAnchorIfUsed (oldName, newName, markerResolver);
bottom.renameAnchorIfUsed (oldName, newName, markerResolver);
}

+ 6
- 3
extras/Jucer (experimental)/Source/utility/jucer_Coordinate.h View File

@@ -97,8 +97,10 @@ public:
const String getAnchor2() const { return checkName (anchor2); }
void changeAnchor2 (const String& newMarkerName, const MarkerResolver& markerResolver);
// Tells the coord that an anchor is changing its name.
void renameAnchorIfUsed (const String& oldName, const String& newName);
/** Tells the coord that an anchor is changing its name.
If the new name is empty, it removes the anchor.
*/
void renameAnchorIfUsed (const String& oldName, const String& newName, const MarkerResolver& markerResolver);
//==============================================================================
/*
@@ -158,7 +160,8 @@ public:
const String toString() const;
// Tells the coord that an anchor is changing its name.
void renameAnchorIfUsed (const String& oldName, const String& newName);
void renameAnchorIfUsed (const String& oldName, const String& newName,
const Coordinate::MarkerResolver& markerResolver);
Coordinate left, right, top, bottom;
};


+ 6
- 2
extras/Jucer (experimental)/Source/utility/jucer_MarkerListBase.h View File

@@ -56,7 +56,7 @@ public:
{
ValueTree v (getMarker (i));
Coordinate coord (getCoordinate (v));
coord.renameAnchorIfUsed (oldName, newName);
coord.renameAnchorIfUsed (oldName, newName, *this);
setCoordinate (v, coord);
}
}
@@ -70,7 +70,11 @@ public:
group.addChild (marker, -1, getUndoManager());
}
void deleteMarker (ValueTree& markerState) { group.removeChild (markerState, getUndoManager()); }
void deleteMarker (ValueTree& markerState)
{
renameAnchor (getName (markerState), String::empty);
group.removeChild (markerState, getUndoManager());
}
//==============================================================================
virtual UndoManager* getUndoManager() const = 0;


+ 2
- 2
extras/Jucer (experimental)/Source/utility/jucer_RelativePath.h View File

@@ -59,8 +59,8 @@ public:
RootFolder getRoot() const { return root; }
const String toUnixStyle() const { return unixStylePath (path); }
const String toWindowsStyle() const { return windowsStylePath (path); }
const String toUnixStyle() const { return FileUtils::unixStylePath (path); }
const String toWindowsStyle() const { return FileUtils::windowsStylePath (path); }
const String getFileName() const { return getFakeFile().getFileName(); }
const String getFileNameWithoutExtension() const { return getFakeFile().getFileNameWithoutExtension(); }


+ 3
- 3
extras/Jucer (experimental)/Source/utility/jucer_StoredSettings.cpp View File

@@ -112,10 +112,10 @@ void StoredSettings::setLastProject (const File& file)
const File StoredSettings::getLastKnownJuceFolder() const
{
File defaultJuceFolder (findDefaultJuceFolder());
File defaultJuceFolder (FileUtils::findDefaultJuceFolder());
File f (props->getValue ("lastJuceFolder", defaultJuceFolder.getFullPathName()));
if ((! isJuceFolder (f)) && isJuceFolder (defaultJuceFolder))
if ((! FileUtils::isJuceFolder (f)) && FileUtils::isJuceFolder (defaultJuceFolder))
f = defaultJuceFolder;
return f;
@@ -123,7 +123,7 @@ const File StoredSettings::getLastKnownJuceFolder() const
void StoredSettings::setLastKnownJuceFolder (const File& file)
{
jassert (isJuceFolder (file));
jassert (FileUtils::isJuceFolder (file));
props->setValue ("lastJuceFolder", file.getFullPathName());
}


+ 417
- 455
extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp View File

@@ -26,78 +26,6 @@
#include "../jucer_Headers.h"
//==============================================================================
int64 calculateStreamHashCode (InputStream& in)
{
int64 t = 0;
const int bufferSize = 4096;
HeapBlock <uint8> buffer;
buffer.malloc (bufferSize);
for (;;)
{
const int num = in.read (buffer, bufferSize);
if (num <= 0)
break;
for (int i = 0; i < num; ++i)
t = t * 65599 + buffer[i];
}
return t;
}
int64 calculateFileHashCode (const File& file)
{
ScopedPointer <FileInputStream> stream (file.createInputStream());
return stream != 0 ? calculateStreamHashCode (*stream) : 0;
}
bool areFilesIdentical (const File& file1, const File& file2)
{
return file1.getSize() == file2.getSize()
&& calculateFileHashCode (file1) == calculateFileHashCode (file2);
}
bool overwriteFileWithNewDataIfDifferent (const File& file, const char* data, int numBytes)
{
if (file.getSize() == numBytes)
{
MemoryInputStream newStream (data, numBytes, false);
if (calculateStreamHashCode (newStream) == calculateFileHashCode (file))
return true;
}
TemporaryFile temp (file);
return temp.getFile().appendData (data, numBytes)
&& temp.overwriteTargetFileWithTemporary();
}
bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData)
{
return overwriteFileWithNewDataIfDifferent (file, newData.getData(), newData.getDataSize());
}
bool overwriteFileWithNewDataIfDifferent (const File& file, const String& newData)
{
return overwriteFileWithNewDataIfDifferent (file, newData.toUTF8(), strlen ((const char*) newData.toUTF8()));
}
bool containsAnyNonHiddenFiles (const File& folder)
{
DirectoryIterator di (folder, false);
while (di.next())
if (! di.getFile().isHidden())
return true;
return false;
}
//==============================================================================
const int64 hashCode64 (const String& s)
{
@@ -147,216 +75,177 @@ const String createGUID (const String& seed)
return guid;
}
const String unixStylePath (const String& path)
{
return path.replaceCharacter ('\\', '/');
}
const String windowsStylePath (const String& path)
//==============================================================================
namespace FileUtils
{
return path.replaceCharacter ('/', '\\');
}
int64 calculateStreamHashCode (InputStream& in)
{
int64 t = 0;
const String appendPath (const String& path, const String& subpath)
{
if (File::isAbsolutePath (subpath)
|| subpath.startsWithChar ('$')
|| subpath.startsWithChar ('~')
|| (CharacterFunctions::isLetter (subpath[0]) && subpath[1] == ':'))
return subpath.replaceCharacter ('\\', '/');
const int bufferSize = 4096;
HeapBlock <uint8> buffer;
buffer.malloc (bufferSize);
String path1 (path.replaceCharacter ('\\', '/'));
if (! path1.endsWithChar ('/'))
path1 << '/';
for (;;)
{
const int num = in.read (buffer, bufferSize);
return path1 + subpath.replaceCharacter ('\\', '/');
}
if (num <= 0)
break;
bool shouldPathsBeRelative (String path1, String path2)
{
path1 = unixStylePath (path1);
path2 = unixStylePath (path2);
for (int i = 0; i < num; ++i)
t = t * 65599 + buffer[i];
}
const int len = jmin (path1.length(), path2.length());
int commonBitLength = 0;
return t;
}
for (int i = 0; i < len; ++i)
int64 calculateFileHashCode (const File& file)
{
if (CharacterFunctions::toLowerCase (path1[i]) != CharacterFunctions::toLowerCase (path2[i]))
break;
ScopedPointer <FileInputStream> stream (file.createInputStream());
return stream != 0 ? calculateStreamHashCode (*stream) : 0;
}
++commonBitLength;
bool areFilesIdentical (const File& file1, const File& file2)
{
return file1.getSize() == file2.getSize()
&& calculateFileHashCode (file1) == calculateFileHashCode (file2);
}
return path1.substring (0, commonBitLength).removeCharacters ("/:").isNotEmpty();
}
bool overwriteFileWithNewDataIfDifferent (const File& file, const char* data, int numBytes)
{
if (file.getSize() == numBytes)
{
MemoryInputStream newStream (data, numBytes, false);
const String createIncludeStatement (const File& includeFile, const File& targetFile)
{
return "#include \"" + unixStylePath (includeFile.getRelativePathFrom (targetFile.getParentDirectory()))
+ "\"";
}
if (calculateStreamHashCode (newStream) == calculateFileHashCode (file))
return true;
}
const String makeHeaderGuardName (const File& file)
{
return "__" + file.getFileName().toUpperCase()
.replaceCharacters (" .", "__")
.retainCharacters ("_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
+ "_"
+ String::toHexString (file.hashCode()).toUpperCase()
+ "__";
}
TemporaryFile temp (file);
//==============================================================================
bool isJuceFolder (const File& folder)
{
return folder.getFileName().containsIgnoreCase ("juce")
&& folder.getChildFile ("juce.h").exists()
&& folder.getChildFile ("juce_Config.h").exists();
}
return temp.getFile().appendData (data, numBytes)
&& temp.overwriteTargetFileWithTemporary();
}
static const File lookInFolderForJuceFolder (const File& folder)
{
for (DirectoryIterator di (folder, false, "*juce*", File::findDirectories); di.next();)
bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData)
{
if (isJuceFolder (di.getFile()))
return di.getFile();
return overwriteFileWithNewDataIfDifferent (file, newData.getData(), newData.getDataSize());
}
return File::nonexistent;
}
const File findParentJuceFolder (const File& file)
{
File f (file);
bool overwriteFileWithNewDataIfDifferent (const File& file, const String& newData)
{
return overwriteFileWithNewDataIfDifferent (file, newData.toUTF8(), strlen ((const char*) newData.toUTF8()));
}
while (f.exists() && f.getParentDirectory() != f)
bool containsAnyNonHiddenFiles (const File& folder)
{
if (isJuceFolder (f))
return f;
DirectoryIterator di (folder, false);
File found = lookInFolderForJuceFolder (f);
if (found.exists())
return found;
while (di.next())
if (! di.getFile().isHidden())
return true;
f = f.getParentDirectory();
return false;
}
return File::nonexistent;
}
const File findDefaultJuceFolder()
{
File f = findParentJuceFolder (File::getSpecialLocation (File::currentApplicationFile));
if (! f.exists())
f = lookInFolderForJuceFolder (File::getSpecialLocation (File::userHomeDirectory));
const String unixStylePath (const String& path)
{
return path.replaceCharacter ('\\', '/');
}
if (! f.exists())
f = lookInFolderForJuceFolder (File::getSpecialLocation (File::userDocumentsDirectory));
const String windowsStylePath (const String& path)
{
return path.replaceCharacter ('/', '\\');
}
return f;
}
const String appendPath (const String& path, const String& subpath)
{
if (File::isAbsolutePath (subpath)
|| subpath.startsWithChar ('$')
|| subpath.startsWithChar ('~')
|| (CharacterFunctions::isLetter (subpath[0]) && subpath[1] == ':'))
return subpath.replaceCharacter ('\\', '/');
//==============================================================================
const String replaceCEscapeChars (const String& s)
{
const int len = s.length();
String path1 (path.replaceCharacter ('\\', '/'));
if (! path1.endsWithChar ('/'))
path1 << '/';
String r;
r.preallocateStorage (len + 2);
bool lastWasHexEscapeCode = false;
return path1 + subpath.replaceCharacter ('\\', '/');
}
for (int i = 0; i < len; ++i)
bool shouldPathsBeRelative (String path1, String path2)
{
const tchar c = s[i];
path1 = unixStylePath (path1);
path2 = unixStylePath (path2);
switch (c)
const int len = jmin (path1.length(), path2.length());
int commonBitLength = 0;
for (int i = 0; i < len; ++i)
{
case '\t': r << "\\t"; lastWasHexEscapeCode = false; break;
case '\r': r << "\\r"; lastWasHexEscapeCode = false; break;
case '\n': r << "\\n"; lastWasHexEscapeCode = false; break;
case '\\': r << "\\\\"; lastWasHexEscapeCode = false; break;
case '\'': r << "\\\'"; lastWasHexEscapeCode = false; break;
case '\"': r << "\\\""; lastWasHexEscapeCode = false; break;
default:
if (c < 128
&& ! (lastWasHexEscapeCode
&& String ("0123456789abcdefABCDEF").containsChar (c))) // (have to avoid following a hex escape sequence with a valid hex digit)
{
r << c;
lastWasHexEscapeCode = false;
}
else
{
r << "\\x" << String::toHexString ((int) c);
lastWasHexEscapeCode = true;
}
if (CharacterFunctions::toLowerCase (path1[i]) != CharacterFunctions::toLowerCase (path2[i]))
break;
break;
++commonBitLength;
}
}
return r;
}
return path1.substring (0, commonBitLength).removeCharacters ("/:").isNotEmpty();
}
//==============================================================================
const String makeValidCppIdentifier (String s,
const bool capitalise,
const bool removeColons,
const bool allowTemplates)
{
if (s.isEmpty())
return "unknown";
//==============================================================================
bool isJuceFolder (const File& folder)
{
return folder.getFileName().containsIgnoreCase ("juce")
&& folder.getChildFile ("juce.h").exists()
&& folder.getChildFile ("juce_Config.h").exists();
}
if (removeColons)
s = s.replaceCharacters (".,;:/@", "______");
else
s = s.replaceCharacters (".,;/@", "_____");
static const File lookInFolderForJuceFolder (const File& folder)
{
for (DirectoryIterator di (folder, false, "*juce*", File::findDirectories); di.next();)
{
if (isJuceFolder (di.getFile()))
return di.getFile();
}
int i;
for (i = s.length(); --i > 0;)
if (CharacterFunctions::isLetter (s[i])
&& CharacterFunctions::isLetter (s[i - 1])
&& CharacterFunctions::isUpperCase (s[i])
&& ! CharacterFunctions::isUpperCase (s[i - 1]))
s = s.substring (0, i) + " " + s.substring (i);
return File::nonexistent;
}
String allowedChars ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_ 0123456789");
if (allowTemplates)
allowedChars += "<>";
const File findParentJuceFolder (const File& file)
{
File f (file);
if (! removeColons)
allowedChars += ":";
while (f.exists() && f.getParentDirectory() != f)
{
if (isJuceFolder (f))
return f;
StringArray words;
words.addTokens (s.retainCharacters (allowedChars), false);
words.trim();
File found = lookInFolderForJuceFolder (f);
if (found.exists())
return found;
String n (words[0]);
f = f.getParentDirectory();
}
if (capitalise)
n = n.toLowerCase();
return File::nonexistent;
}
for (i = 1; i < words.size(); ++i)
const File findDefaultJuceFolder()
{
if (capitalise && words[i].length() > 1)
n << words[i].substring (0, 1).toUpperCase()
<< words[i].substring (1).toLowerCase();
else
n << words[i];
}
File f = findParentJuceFolder (File::getSpecialLocation (File::currentApplicationFile));
if (CharacterFunctions::isDigit (n[0]))
n = "_" + n;
if (! f.exists())
f = lookInFolderForJuceFolder (File::getSpecialLocation (File::userHomeDirectory));
if (CPlusPlusCodeTokeniser::isReservedKeyword (n))
n << '_';
if (! f.exists())
f = lookInFolderForJuceFolder (File::getSpecialLocation (File::userDocumentsDirectory));
return n;
return f;
}
}
//==============================================================================
void autoScrollForMouseEvent (const MouseEvent& e)
{
Viewport* const viewport = e.eventComponent->findParentComponentOfClass ((Viewport*) 0);
@@ -392,139 +281,343 @@ void drawRecessedShadows (Graphics& g, int w, int h, int shadowSize)
g.setGradientFill (cg);
g.fillRect (0, 0, w, shadowSize);
cg.y1 = (float) h;
cg.y2 = cg.y1 - shadowSize;
cg.point1.setXY (0.0f, (float) h);
cg.point2.setXY (0.0f, (float) h - shadowSize);
g.setGradientFill (cg);
g.fillRect (0, h - shadowSize, w, shadowSize);
cg.x1 = cg.y1 = cg.y2 = 0;
cg.x2 = (float) shadowSize;
cg.point1.setXY (0.0f, 0.0f);
cg.point2.setXY ((float) shadowSize, 0.0f);
g.setGradientFill (cg);
g.fillRect (0, 0, shadowSize, h);
cg.y1 = cg.y2 = 0;
cg.x1 = (float) w;
cg.x2 = cg.x1 - shadowSize;
cg.point1.setXY ((float) w, 0.0f);
cg.point2.setXY ((float) w - shadowSize, 0.0f);
g.setGradientFill (cg);
g.fillRect (w - shadowSize, 0, shadowSize, h);
}
//==============================================================================
const String floatToCode (const float v)
namespace CodeFormatting
{
String s ((double) (float) v, 4);
const String indent (const String& code, const int numSpaces, bool indentFirstLine)
{
if (numSpaces == 0)
return code;
if (s.containsChar ('.'))
s << 'f';
else
s << ".0f";
const String space (String::repeatedString (" ", numSpaces));
return s;
}
StringArray lines;
lines.addLines (code);
const String doubleToCode (const double v)
{
String s (v, 7);
for (int i = (indentFirstLine ? 0 : 1); i < lines.size(); ++i)
{
String s (lines[i].trimEnd());
if (s.isNotEmpty())
s = space + s;
if (! s.containsChar ('.'))
s << ".0";
lines.set (i, s);
}
return s;
}
return lines.joinIntoString (newLine);
}
const String boolToCode (const bool b)
{
return b ? "true" : "false";
}
const String makeValidIdentifier (String s, bool capitalise, bool removeColons, bool allowTemplates)
{
if (s.isEmpty())
return "unknown";
const String colourToCode (const Colour& col)
{
const Colour colours[] =
if (removeColons)
s = s.replaceCharacters (".,;:/@", "______");
else
s = s.replaceCharacters (".,;/@", "_____");
int i;
for (i = s.length(); --i > 0;)
if (CharacterFunctions::isLetter (s[i])
&& CharacterFunctions::isLetter (s[i - 1])
&& CharacterFunctions::isUpperCase (s[i])
&& ! CharacterFunctions::isUpperCase (s[i - 1]))
s = s.substring (0, i) + " " + s.substring (i);
String allowedChars ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_ 0123456789");
if (allowTemplates)
allowedChars += "<>";
if (! removeColons)
allowedChars += ":";
StringArray words;
words.addTokens (s.retainCharacters (allowedChars), false);
words.trim();
String n (words[0]);
if (capitalise)
n = n.toLowerCase();
for (i = 1; i < words.size(); ++i)
{
if (capitalise && words[i].length() > 1)
n << words[i].substring (0, 1).toUpperCase()
<< words[i].substring (1).toLowerCase();
else
n << words[i];
}
if (CharacterFunctions::isDigit (n[0]))
n = "_" + n;
if (CPlusPlusCodeTokeniser::isReservedKeyword (n))
n << '_';
return n;
}
const String addEscapeChars (const String& s)
{
const int len = s.length();
String r;
r.preallocateStorage (len + 2);
bool lastWasHexEscapeCode = false;
for (int i = 0; i < len; ++i)
{
const juce_wchar c = s[i];
switch (c)
{
case '\t': r << "\\t"; lastWasHexEscapeCode = false; break;
case '\r': r << "\\r"; lastWasHexEscapeCode = false; break;
case '\n': r << "\\n"; lastWasHexEscapeCode = false; break;
case '\\': r << "\\\\"; lastWasHexEscapeCode = false; break;
case '\'': r << "\\\'"; lastWasHexEscapeCode = false; break;
case '\"': r << "\\\""; lastWasHexEscapeCode = false; break;
default:
if (c < 128
&& ! (lastWasHexEscapeCode
&& String ("0123456789abcdefABCDEF").containsChar (c))) // (have to avoid following a hex escape sequence with a valid hex digit)
{
r << c;
lastWasHexEscapeCode = false;
}
else
{
r << "\\x" << String::toHexString ((int) c);
lastWasHexEscapeCode = true;
}
break;
}
}
return r;
}
const String createIncludeStatement (const File& includeFile, const File& targetFile)
{
#define COL(col) Colours::col,
#include "jucer_Colours.h"
#undef COL
Colours::transparentBlack
};
return "#include \"" + FileUtils::unixStylePath (includeFile.getRelativePathFrom (targetFile.getParentDirectory())) + "\"";
}
static const char* colourNames[] =
const String makeHeaderGuardName (const File& file)
{
#define COL(col) #col,
#include "jucer_Colours.h"
#undef COL
0
};
return "__" + file.getFileName().toUpperCase()
.replaceCharacters (" .", "__")
.retainCharacters ("_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
+ "_" + String::toHexString (file.hashCode()).toUpperCase() + "__";
}
for (int i = 0; i < numElementsInArray (colourNames) - 1; ++i)
if (col == colours[i])
return "Colours::" + String (colourNames[i]);
const String stringLiteral (const String& text)
{
if (text.isEmpty())
return "String::empty";
return "Colour (0x" + hexString8Digits ((int) col.getARGB()) + ')';
}
return CodeFormatting::addEscapeChars (text).quoted();
}
const String justificationToCode (const Justification& justification)
{
switch (justification.getFlags())
{
case Justification::centred: return "Justification::centred";
case Justification::centredLeft: return "Justification::centredLeft";
case Justification::centredRight: return "Justification::centredRight";
case Justification::centredTop: return "Justification::centredTop";
case Justification::centredBottom: return "Justification::centredBottom";
case Justification::topLeft: return "Justification::topLeft";
case Justification::topRight: return "Justification::topRight";
case Justification::bottomLeft: return "Justification::bottomLeft";
case Justification::bottomRight: return "Justification::bottomRight";
case Justification::left: return "Justification::left";
case Justification::right: return "Justification::right";
case Justification::horizontallyCentred: return "Justification::horizontallyCentred";
case Justification::top: return "Justification::top";
case Justification::bottom: return "Justification::bottom";
case Justification::verticallyCentred: return "Justification::verticallyCentred";
case Justification::horizontallyJustified: return "Justification::horizontallyJustified";
default: jassertfalse; break;
}
return "Justification (" + String (justification.getFlags()) + ")";
}
const String boolLiteral (bool b)
{
return b ? "true" : "false";
}
const String castToFloat (const String& expression)
{
if (expression.containsOnly ("0123456789.f"))
const String floatLiteral (float v)
{
String s (expression.getFloatValue());
String s ((double) v, 4);
if (s.containsChar (T('.')))
return s + "f";
if (s.containsChar ('.'))
s << 'f';
else
s << ".0f";
return s + ".0f";
return s;
}
return "(float) (" + expression + ")";
}
const String doubleLiteral (double v)
{
String s (v, 7);
const String indentCode (const String& code, const int numSpaces)
{
if (numSpaces == 0)
return code;
if (! s.containsChar ('.'))
s << ".0";
return s;
}
const String colourToCode (const Colour& col)
{
const Colour colours[] =
{
#define COL(col) Colours::col,
#include "jucer_Colours.h"
#undef COL
Colours::transparentBlack
};
const String space (String::repeatedString (" ", numSpaces));
static const char* colourNames[] =
{
#define COL(col) #col,
#include "jucer_Colours.h"
#undef COL
0
};
for (int i = 0; i < numElementsInArray (colourNames) - 1; ++i)
if (col == colours[i])
return "Colours::" + String (colourNames[i]);
StringArray lines;
lines.addLines (code);
return "Colour (0x" + hexString8Digits ((int) col.getARGB()) + ')';
}
for (int i = 1; i < lines.size(); ++i)
const String justificationToCode (const Justification& justification)
{
String s (lines[i].trimEnd());
if (s.isNotEmpty())
s = space + s;
switch (justification.getFlags())
{
case Justification::centred: return "Justification::centred";
case Justification::centredLeft: return "Justification::centredLeft";
case Justification::centredRight: return "Justification::centredRight";
case Justification::centredTop: return "Justification::centredTop";
case Justification::centredBottom: return "Justification::centredBottom";
case Justification::topLeft: return "Justification::topLeft";
case Justification::topRight: return "Justification::topRight";
case Justification::bottomLeft: return "Justification::bottomLeft";
case Justification::bottomRight: return "Justification::bottomRight";
case Justification::left: return "Justification::left";
case Justification::right: return "Justification::right";
case Justification::horizontallyCentred: return "Justification::horizontallyCentred";
case Justification::top: return "Justification::top";
case Justification::bottom: return "Justification::bottom";
case Justification::verticallyCentred: return "Justification::verticallyCentred";
case Justification::horizontallyJustified: return "Justification::horizontallyJustified";
default: jassertfalse; break;
}
lines.set (i, s);
return "Justification (" + String (justification.getFlags()) + ")";
}
return lines.joinIntoString (newLine);
const String castToFloat (const String& expression)
{
if (expression.containsOnly ("0123456789.f"))
{
String s (expression.getFloatValue());
if (s.containsChar (T('.')))
return s + "f";
return s + ".0f";
}
return "(float) (" + expression + ")";
}
void writeDataAsCppLiteral (const MemoryBlock& mb, OutputStream& out)
{
const int maxCharsOnLine = 250;
const unsigned char* data = (const unsigned char*) mb.getData();
int charsOnLine = 0;
bool canUseStringLiteral = mb.getSize() < 65535; // MS compilers can't handle strings bigger than 65536 chars..
if (canUseStringLiteral)
{
int numEscaped = 0;
for (size_t i = 0; i < mb.getSize(); ++i)
{
const unsigned int num = (unsigned int) data[i];
if (! ((num >= 32 && num < 127) || num == '\t' || num == '\r' || num == '\n'))
{
if (++numEscaped > mb.getSize() / 4)
{
canUseStringLiteral = false;
break;
}
}
}
}
if (! canUseStringLiteral)
{
out << "{ ";
for (size_t i = 0; i < mb.getSize(); ++i)
{
const int num = (int) (unsigned int) data[i];
out << num << ',';
charsOnLine += 2;
if (num >= 10)
++charsOnLine;
if (num >= 100)
++charsOnLine;
if (charsOnLine >= maxCharsOnLine)
{
charsOnLine = 0;
out << newLine;
}
}
out << "0,0 };";
}
else
{
out << "\"";
for (size_t i = 0; i < mb.getSize(); ++i)
{
const unsigned int num = (unsigned int) data[i];
switch (num)
{
case '\t': out << "\\t"; break;
case '\r': out << "\\r"; break;
case '\n': out << "\\n"; charsOnLine = maxCharsOnLine; break;
case '"': out << "\\\""; break;
case '\\': out << "\\\\"; break;
default:
if (num >= 32 && num < 127)
out << (char) num;
else if (num <= 0x0f)
out << "\\x0" << String::toHexString ((int) num);
else
out << "\\x" << String::toHexString ((int) num);
break;
}
if (++charsOnLine >= maxCharsOnLine && i < mb.getSize() - 1)
{
charsOnLine = 0;
out << "\"" << newLine << "\"";
}
}
out << "\";";
}
}
}
//==============================================================================
int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex)
{
startIndex = jmax (0, startIndex);
@@ -663,134 +756,3 @@ void FloatingLabelComponent::paint (Graphics& g)
g.setColour (colour);
glyphs.draw (g, AffineTransform::translation (1.0f, 1.0f));
}
//==============================================================================
class FontNameValueSource : public Value::ValueSource,
public Value::Listener
{
public:
FontNameValueSource (const Value& source)
: sourceValue (source)
{
sourceValue.addListener (this);
}
~FontNameValueSource() {}
void valueChanged (Value&) { sendChangeMessage (true); }
const var getValue() const
{
const String fontName (sourceValue.toString());
const int index = StoredSettings::getInstance()->getFontNames().indexOf (fontName);
if (index >= 0) return 5 + index;
else if (fontName == getDefaultFontName()) return 1;
else if (fontName == getDefaultSansFontName()) return 2;
else if (fontName == getDefaultSerifFontName()) return 3;
else if (fontName == getDefaultMonospacedFontName()) return 4;
return 1;
}
void setValue (const var& newValue)
{
const int index = newValue;
if (index <= 1) sourceValue = getDefaultFontName();
else if (index == 2) sourceValue = getDefaultSansFontName();
else if (index == 3) sourceValue = getDefaultSerifFontName();
else if (index == 4) sourceValue = getDefaultMonospacedFontName();
else sourceValue = StoredSettings::getInstance()->getFontNames() [index - 5];
}
static ChoicePropertyComponent* createProperty (const String& title, const Value& value)
{
StringArray fontNames;
fontNames.add (getDefaultFontName());
fontNames.add (getDefaultSansFontName());
fontNames.add (getDefaultSerifFontName());
fontNames.add (getDefaultMonospacedFontName());
fontNames.add (String::empty);
fontNames.addArray (StoredSettings::getInstance()->getFontNames());
return new ChoicePropertyComponent (Value (new FontNameValueSource (value)), title, fontNames);
}
static void applyToFont (Font& font, const String& fontName)
{
if (fontName.isEmpty() || fontName == getDefaultFontName() || fontName == getDefaultSansFontName())
return;
font.setTypefaceName (fontName == getDefaultSerifFontName() ? Font::getDefaultSerifFontName()
: (fontName == getDefaultMonospacedFontName() ? Font::getDefaultMonospacedFontName()
: fontName));
}
static const char* getDefaultFontName() throw() { return "Default Font"; }
static const char* getDefaultSansFontName() throw() { return "Default Sans-Serif Font"; }
static const char* getDefaultSerifFontName() throw() { return "Default Serif Font"; }
static const char* getDefaultMonospacedFontName() throw() { return "Default Monospaced Font"; }
private:
Value sourceValue;
FontNameValueSource (const FontNameValueSource&);
const FontNameValueSource& operator= (const FontNameValueSource&);
};
static const char* const fontStyles[] = { "Normal", "Bold", "Italic", "Bold + Italic", 0 };
const Font getFontFromState (const ValueTree& state, const var::identifier& fontName, const var::identifier& fontSize, const var::identifier& fontStyle)
{
const String styleString (state.getProperty (fontStyle).toString());
const int fontFlags = styleString == fontStyles[1] ? Font::bold
: (styleString == fontStyles[2] ? Font::italic
: (styleString == fontStyles[3] ? (Font::italic | Font::bold)
: 0));
Font f (state.getProperty (fontSize, 14), fontFlags);
FontNameValueSource::applyToFont (f, state.getProperty (fontName));
return f;
}
void createFontProperties (Array <PropertyComponent*>& props, const ValueTree& state,
const var::identifier& fontName, const var::identifier& fontSize, const var::identifier& fontStyle,
UndoManager* undoManager)
{
props.add (FontNameValueSource::createProperty ("Font", state.getPropertyAsValue (fontName, undoManager)));
props.add (new SliderPropertyComponent (state.getPropertyAsValue (fontSize, undoManager), "Font Size", 1.0, 150.0, 0.1, 0.5));
props.add (StringListValueSource::create ("Font Style", state.getPropertyAsValue (fontStyle, undoManager), StringArray (fontStyles)));
}
PropertyComponent* createJustificationProperty (const String& name, const Value& value, bool onlyHorizontal)
{
ValueRemapperSource* remapper = new ValueRemapperSource (value);
StringArray strings;
if (onlyHorizontal)
{
const char* const layouts[] = { "Left", "Centred", "Right", 0 };
const int justifications[] = { Justification::left, Justification::centred, Justification::right, 0 };
for (int i = 0; i < numElementsInArray (justifications) - 1; ++i)
remapper->addMapping (justifications[i], i + 1);
strings = StringArray (layouts);
}
else
{
const char* const layouts[] = { "Centred", "Centred-left", "Centred-right", "Centred-top", "Centred-bottom", "Top-left",
"Top-right", "Bottom-left", "Bottom-right", 0 };
const int justifications[] = { Justification::centred, Justification::centredLeft, Justification::centredRight,
Justification::centredTop, Justification::centredBottom, Justification::topLeft,
Justification::topRight, Justification::bottomLeft, Justification::bottomRight, 0 };
for (int i = 0; i < numElementsInArray (justifications) - 1; ++i)
remapper->addMapping (justifications[i], i + 1);
strings = StringArray (layouts);
}
return new ChoicePropertyComponent (Value (remapper), name, strings);
}

+ 43
- 54
extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.h View File

@@ -25,15 +25,28 @@
//==============================================================================
int64 calculateStreamHashCode (InputStream& stream);
int64 calculateFileHashCode (const File& file);
bool areFilesIdentical (const File& file1, const File& file2);
namespace FileUtils
{
int64 calculateStreamHashCode (InputStream& stream);
int64 calculateFileHashCode (const File& file);
bool areFilesIdentical (const File& file1, const File& file2);
bool overwriteFileWithNewDataIfDifferent (const File& file, const char* data, int numBytes);
bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData);
bool overwriteFileWithNewDataIfDifferent (const File& file, const String& newData);
bool containsAnyNonHiddenFiles (const File& folder);
bool overwriteFileWithNewDataIfDifferent (const File& file, const char* data, int numBytes);
bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData);
bool overwriteFileWithNewDataIfDifferent (const File& file, const String& newData);
const String unixStylePath (const String& path);
const String windowsStylePath (const String& path);
bool containsAnyNonHiddenFiles (const File& folder);
bool shouldPathsBeRelative (String path1, String path2);
//==============================================================================
bool isJuceFolder (const File& folder);
const File findParentJuceFolder (const File& file);
const File findDefaultJuceFolder();
}
//==============================================================================
// String::hashCode64 actually hit some dupes, so this is a more powerful version.
@@ -44,38 +57,7 @@ const String hexString8Digits (int value);
const String createAlphaNumericUID();
const String createGUID (const String& seed); // Turns a seed into a windows GUID
const String unixStylePath (const String& path);
const String windowsStylePath (const String& path);
bool shouldPathsBeRelative (String path1, String path2);
//==============================================================================
bool isJuceFolder (const File& folder);
const File findParentJuceFolder (const File& file);
const File findDefaultJuceFolder();
//==============================================================================
const String createIncludeStatement (const File& includeFile, const File& targetFile);
const String makeHeaderGuardName (const File& file);
const String replaceCEscapeChars (const String& s);
const String makeValidCppIdentifier (String s,
const bool capitalise,
const bool removeColons,
const bool allowTemplates);
//==============================================================================
const String boolToCode (const bool b);
const String floatToCode (const float v);
const String doubleToCode (const double v);
const String colourToCode (const Colour& col);
const String justificationToCode (const Justification& justification);
const String castToFloat (const String& expression);
//==============================================================================
const String indentCode (const String& code, const int numSpaces);
int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex);
void autoScrollForMouseEvent (const MouseEvent& e);
@@ -83,20 +65,6 @@ void autoScrollForMouseEvent (const MouseEvent& e);
void drawComponentPlaceholder (Graphics& g, int w, int h, const String& text);
void drawRecessedShadows (Graphics& g, int w, int h, int shadowSize);
//==============================================================================
const Font getFontFromState (const ValueTree& state,
const var::identifier& fontName,
const var::identifier& fontSize,
const var::identifier& fontStyle);
void createFontProperties (Array <PropertyComponent*>& props, const ValueTree& state,
const var::identifier& fontName,
const var::identifier& fontSize,
const var::identifier& fontStyle,
UndoManager* undoManager);
PropertyComponent* createJustificationProperty (const String& name, const Value& value, bool onlyHorizontal);
//==============================================================================
class FileModificationDetector
{
@@ -113,14 +81,14 @@ public:
{
return fileModificationTime != file.getLastModificationTime()
&& (fileSize != file.getSize()
|| calculateFileHashCode (file) != fileHashCode);
|| FileUtils::calculateFileHashCode (file) != fileHashCode);
}
void updateHash()
{
fileModificationTime = file.getLastModificationTime();
fileSize = file.getSize();
fileHashCode = calculateFileHashCode (file);
fileHashCode = FileUtils::calculateFileHashCode (file);
}
private:
@@ -129,6 +97,27 @@ private:
int64 fileHashCode, fileSize;
};
//==============================================================================
namespace CodeFormatting
{
const String indent (const String& code, const int numSpaces, bool indentFirstLine);
const String makeValidIdentifier (String s, bool capitalise, bool removeColons, bool allowTemplates);
const String addEscapeChars (const String& text);
const String createIncludeStatement (const File& includeFile, const File& targetFile);
const String makeHeaderGuardName (const File& file);
const String stringLiteral (const String& text);
const String boolLiteral (bool b);
const String floatLiteral (float v);
const String doubleLiteral (double v);
const String colourToCode (const Colour& col);
const String justificationToCode (const Justification& justification);
const String castToFloat (const String& expression);
void writeDataAsCppLiteral (const MemoryBlock& data, OutputStream& out);
}
//==============================================================================
class PropertyPanelWithTooltips : public Component,
public Timer


+ 255
- 286
juce_amalgamated.cpp
File diff suppressed because it is too large
View File


+ 51
- 34
juce_amalgamated.h View File

@@ -587,7 +587,7 @@

@see jassertfalse
*/
#define jassert(expression) { if (! (expression)) jassertfalse }
#define jassert(expression) { if (! (expression)) jassertfalse; }

#else

@@ -598,7 +598,7 @@
#define jassertfalse { juce_LogCurrentAssertion }

#if JUCE_LOG_ASSERTIONS
#define jassert(expression) { if (! (expression)) jassertfalse }
#define jassert(expression) { if (! (expression)) jassertfalse; }
#else
#define jassert(a) { }
#endif
@@ -634,7 +634,7 @@
}

#define JUCE_CATCH_ALL catch (...) {}
#define JUCE_CATCH_ALL_ASSERT catch (...) { jassertfalse }
#define JUCE_CATCH_ALL_ASSERT catch (...) { jassertfalse; }

#else

@@ -3957,7 +3957,7 @@ public:

if (startIndex < 0)
{
jassertfalse
jassertfalse;
startIndex = 0;
}

@@ -6713,7 +6713,7 @@ public:

if (startIndex < 0)
{
jassertfalse
jassertfalse;
startIndex = 0;
}

@@ -9050,10 +9050,10 @@ public:
explicit XmlElement (const String& tagName) throw();

/** Creates a (deep) copy of another element. */
XmlElement (const XmlElement& other) throw();
XmlElement (const XmlElement& other);

/** Creates a (deep) copy of another element. */
XmlElement& operator= (const XmlElement& other) throw();
XmlElement& operator= (const XmlElement& other);

/** Deleting an XmlElement will also delete all its child elements. */
~XmlElement() throw();
@@ -9148,7 +9148,7 @@ public:

@see hasTagName
*/
inline const String& getTagName() const throw() { return tagName; }
inline const String& getTagName() const throw() { return tagName; }

/** Tests whether this element has a particular tag name.

@@ -9489,7 +9489,7 @@ public:
*/
template <class ElementComparator>
void sortChildElements (ElementComparator& comparator,
const bool retainOrderOfEquivalentItems = false) throw()
bool retainOrderOfEquivalentItems = false)
{
const int num = getNumChildElements();

@@ -9524,14 +9524,14 @@ public:

@see isTextElement, getAllSubText, getChildElementAllSubText
*/
const String getText() const throw();
const String& getText() const throw();

/** Sets the text in a text element.

Note that this is only a valid call if this element is a text element. If it's
not, then no action will be performed.
*/
void setText (const String& newText) throw();
void setText (const String& newText);

/** Returns all the text from this element's child nodes.

@@ -9543,7 +9543,7 @@ public:

@see isTextElement, getChildElementAllSubText, getText, addTextElement
*/
const String getAllSubText() const throw();
const String getAllSubText() const;

/** Returns all the sub-text of a named child element.

@@ -9554,13 +9554,13 @@ public:
@see getAllSubText
*/
const String getChildElementAllSubText (const String& childTagName,
const String& defaultReturnValue) const throw();
const String& defaultReturnValue) const;

/** Appends a section of text to this element.

@see isTextElement, getText, getAllSubText
*/
void addTextElement (const String& text) throw();
void addTextElement (const String& text);

/** Removes all the text elements from this element.

@@ -9570,7 +9570,7 @@ public:

/** Creates a text element that can be added to a parent element.
*/
static XmlElement* createTextElement (const String& text) throw();
static XmlElement* createTextElement (const String& text);

juce_UseDebuggingNewOperator

@@ -9596,7 +9596,7 @@ private:
XmlAttributeNode* attributes;

XmlElement (int) throw();
void copyChildrenAndAttributesFrom (const XmlElement& other) throw();
void copyChildrenAndAttributesFrom (const XmlElement& other);
void writeElementAsText (OutputStream& out, int indentationLevel, int lineWrapLength) const;
void getChildElementsAsArray (XmlElement**) const throw();
void reorderChildElements (XmlElement** const, const int) throw();
@@ -10363,7 +10363,7 @@ public:

if (startIndex < 0)
{
jassertfalse
jassertfalse;
startIndex = 0;
}

@@ -11071,7 +11071,7 @@ public:
{
if (startIndex < 0)
{
jassertfalse
jassertfalse;
startIndex = 0;
}

@@ -13719,7 +13719,7 @@ public:

This is needed to avoid unicode problems with the argc type params.
*/
static const String JUCE_CALLTYPE getCurrentCommandLineParams() throw();
static const String JUCE_CALLTYPE getCurrentCommandLineParams();
#endif

/** Clears the floating point unit's flags.
@@ -16549,14 +16549,14 @@ public:
SubregionStream (InputStream* sourceStream,
int64 startPositionInSourceStream,
int64 lengthOfSourceStream,
bool deleteSourceWhenDestroyed) throw();
bool deleteSourceWhenDestroyed);

/** Destructor.

This may also delete the source stream, if that option was chosen when the
buffered stream was created.
*/
~SubregionStream() throw();
~SubregionStream();

int64 getTotalLength();
int64 getPosition();
@@ -18830,17 +18830,20 @@ public:
/** Copies this point from another one. */
Point& operator= (const Point& other) throw() { x = other.x; y = other.y; return *this; }

/** Returns true if the point is (0, 0). */
bool isOrigin() const throw() { return x == ValueType() && y == ValueType(); }

/** Returns the point's x co-ordinate. */
inline ValueType getX() const throw() { return x; }

/** Returns the point's y co-ordinate. */
inline ValueType getY() const throw() { return y; }

inline bool operator== (const Point& other) const throw() { return x == other.x && y == other.y; }
inline bool operator!= (const Point& other) const throw() { return x != other.x || y != other.y; }
/** Sets the point's x co-ordinate. */
inline void setX (const ValueType newX) throw() { x = newX; }

/** Returns true if the point is (0, 0). */
bool isOrigin() const throw() { return x == ValueType() && y == ValueType(); }
/** Sets the point's y co-ordinate. */
inline void setY (const ValueType newY) throw() { y = newY; }

/** Returns a point which has the same Y position as this one, but a new X. */
const Point withX (const ValueType newX) const throw() { return Point (newX, y); }
@@ -18854,6 +18857,9 @@ public:
/** Adds a pair of co-ordinates to this value. */
void addXY (const ValueType xToAdd, const ValueType yToAdd) throw() { x += xToAdd; y += yToAdd; }

inline bool operator== (const Point& other) const throw() { return x == other.x && y == other.y; }
inline bool operator!= (const Point& other) const throw() { return x != other.x || y != other.y; }

/** Adds two points together. */
const Point operator+ (const Point& other) const throw() { return Point (x + other.x, y + other.y); }

@@ -18900,6 +18906,9 @@ public:
*/
void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); }

/** Returns the position of this point, if it is transformed by a given AffineTransform. */
const Point transformedBy (const AffineTransform& transform) const throw() { ValueType x2 (x), y2 (y); transform.transformPoint (x2, y2); return Point (x2, y2); }

/** Returns the point as a string in the form "x, y". */
const String toString() const { return String (x) + ", " + String (y); }

@@ -23022,14 +23031,10 @@ public:
/** Returns true if all colours are completely transparent. */
bool isInvisible() const throw();

float x1;
float y1;

float x2;
float y2;
Point<float> point1, point2;

/** If true, the gradient should be filled circularly, centred around
(x1, y1), with (x2, y2) defining a point on the circumference.
point1, with point2 defining a point on the circumference.

If false, the gradient is linear between the two points.
*/
@@ -23038,7 +23043,19 @@ public:
juce_UseDebuggingNewOperator

private:
Array <uint32> colours;
struct ColourPoint
{
ColourPoint() throw() {}

ColourPoint (uint32 position_, const Colour& colour_) throw()
: position (position_), colour (colour_)
{}

uint32 position;
Colour colour;
};

Array <ColourPoint> colours;
};

#endif // __JUCE_COLOURGRADIENT_JUCEHEADER__
@@ -27252,7 +27269,7 @@ public:

@see isScreenSaverEnabled
*/
static void setScreenSaverEnabled (bool isEnabled) throw();
static void setScreenSaverEnabled (bool isEnabled);

/** Returns true if the screensaver has not been turned off.

@@ -27262,7 +27279,7 @@ public:

@see setScreenSaverEnabled
*/
static bool isScreenSaverEnabled() throw();
static bool isScreenSaverEnabled();

/** Registers a MouseListener that will receive all mouse events that occur on
any component.


+ 2
- 2
src/application/juce_Application.cpp View File

@@ -113,7 +113,7 @@ void JUCEApplication::unhandledException (const std::exception*,
const String&,
const int)
{
jassertfalse
jassertfalse;
}
void JUCEApplication::sendUnhandledException (const std::exception* const e,
@@ -342,7 +342,7 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_GUI()
// Ended up here? If so, TURN ON RTTI in your compiler settings!! And if you
// got as far as this catch statement, then why haven't you got exception catching
// turned on in the debugger???
jassertfalse
jassertfalse;
}
#endif
}


+ 1
- 1
src/audio/audio_file_formats/juce_AiffAudioFormat.cpp View File

@@ -557,7 +557,7 @@ class AiffAudioFormatWriter : public AudioFormatWriter
if (sampleRate >= mask)
{
jassertfalse
jassertfalse;
sampleRateBytes[1] = 0x1d;
}
else


+ 1
- 1
src/audio/audio_file_formats/juce_AudioFormatManager.cpp View File

@@ -64,7 +64,7 @@ void AudioFormatManager::registerFormat (AudioFormat* newFormat,
{
if (getKnownFormat (i)->getFormatName() == newFormat->getFormatName())
{
jassertfalse // trying to add the same format twice!
jassertfalse; // trying to add the same format twice!
}
}
#endif


+ 1
- 1
src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp View File

@@ -384,7 +384,7 @@ AudioFormatWriter* QuickTimeAudioFormat::createWriterFor (OutputStream* /*stream
const StringPairArray& /*metadataValues*/,
int /*qualityOptionIndex*/)
{
jassertfalse // not yet implemented!
jassertfalse; // not yet implemented!
return 0;
}


+ 1
- 1
src/audio/devices/juce_AudioDeviceManager.cpp View File

@@ -539,7 +539,7 @@ void AudioDeviceManager::restartLastAudioDevice()
// This method will only reload the last device that was running
// before closeAudioDevice() was called - you need to actually open
// one first, with setAudioDevice().
jassertfalse
jassertfalse;
return;
}


+ 2
- 2
src/audio/devices/juce_AudioIODevice.cpp View File

@@ -48,8 +48,8 @@ bool AudioIODevice::hasControlPanel() const
bool AudioIODevice::showControlPanel()
{
jassertfalse // this should only be called for devices which return true from
// their hasControlPanel() method.
jassertfalse; // this should only be called for devices which return true from
// their hasControlPanel() method.
return false;
}


+ 2
- 2
src/audio/dsp/juce_AudioDataConverters.cpp View File

@@ -444,7 +444,7 @@ void AudioDataConverters::convertFloatToFormat (const DataFormat destFormat,
break;
default:
jassertfalse
jassertfalse;
break;
}
}
@@ -489,7 +489,7 @@ void AudioDataConverters::convertFormatToFloat (const DataFormat sourceFormat,
break;
default:
jassertfalse
jassertfalse;
break;
}
}


+ 1
- 1
src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm View File

@@ -1308,7 +1308,7 @@ const String AudioUnitPluginInstance::getProgramName (int index)
void AudioUnitPluginInstance::changeProgramName (int index, const String& newName)
{
jassertfalse // xxx not implemented!
jassertfalse; // xxx not implemented!
}
//==============================================================================


+ 1
- 1
src/audio/plugins/formats/juce_VSTPluginFormat.cpp View File

@@ -2676,7 +2676,7 @@ void VSTPluginInstance::changeProgramName (int index, const String& newName)
}
else
{
jassertfalse // xxx not implemented!
jassertfalse; // xxx not implemented!
}
}


+ 1
- 1
src/audio/processors/juce_AudioProcessorGraph.cpp View File

@@ -118,7 +118,7 @@ AudioProcessorGraph::Node* AudioProcessorGraph::addNode (AudioProcessor* const n
{
if (newProcessor == 0)
{
jassertfalse
jassertfalse;
return 0;
}


+ 1
- 1
src/containers/juce_Array.h View File

@@ -569,7 +569,7 @@ public:
if (startIndex < 0)
{
jassertfalse
jassertfalse;
startIndex = 0;
}


+ 3
- 3
src/containers/juce_BitArray.cpp View File

@@ -160,7 +160,7 @@ int BigInteger::getBitRangeAsInt (const int startBit, int numBits) const throw()
{
if (numBits > 32)
{
jassertfalse // use getBitRange() if you need more than 32 bits..
jassertfalse; // use getBitRange() if you need more than 32 bits..
numBits = 32;
}
@@ -185,7 +185,7 @@ void BigInteger::setBitRangeAsInt (const int startBit, int numBits, unsigned int
{
if (numBits > 32)
{
jassertfalse
jassertfalse;
numBits = 32;
}
@@ -908,7 +908,7 @@ const String BigInteger::toString (const int base, const int minimumNumCharacter
}
else
{
jassertfalse // can't do the specified base!
jassertfalse; // can't do the specified base!
return String::empty;
}


+ 1
- 1
src/containers/juce_OwnedArray.h View File

@@ -343,7 +343,7 @@ public:
if (startIndex < 0)
{
jassertfalse
jassertfalse;
startIndex = 0;
}


+ 1
- 1
src/containers/juce_ReferenceCountedArray.h View File

@@ -344,7 +344,7 @@ public:
if (startIndex < 0)
{
jassertfalse
jassertfalse;
startIndex = 0;
}


+ 1
- 1
src/containers/juce_SortedSet.h View File

@@ -383,7 +383,7 @@ public:
{
if (startIndex < 0)
{
jassertfalse
jassertfalse;
startIndex = 0;
}


+ 2
- 2
src/containers/juce_ValueTree.cpp View File

@@ -446,7 +446,7 @@ void ValueTree::SharedObject::addChild (SharedObject* child, int index, UndoMana
{
// You're attempting to create a recursive loop! A node
// can't be a child of one of its own children!
jassertfalse
jassertfalse;
}
}
}
@@ -840,7 +840,7 @@ ValueTree ValueTree::readFromStream (InputStream& input)
if (numProps < 0)
{
jassertfalse // trying to read corrupted data!
jassertfalse; // trying to read corrupted data!
return v;
}


+ 3
- 3
src/core/juce_PlatformDefs.h View File

@@ -123,7 +123,7 @@
@see jassertfalse
*/
#define jassert(expression) { if (! (expression)) jassertfalse }
#define jassert(expression) { if (! (expression)) jassertfalse; }
#else
//==============================================================================
@@ -134,7 +134,7 @@
#define jassertfalse { juce_LogCurrentAssertion }
#if JUCE_LOG_ASSERTIONS
#define jassert(expression) { if (! (expression)) jassertfalse }
#define jassert(expression) { if (! (expression)) jassertfalse; }
#else
#define jassert(a) { }
#endif
@@ -173,7 +173,7 @@
}
#define JUCE_CATCH_ALL catch (...) {}
#define JUCE_CATCH_ALL_ASSERT catch (...) { jassertfalse }
#define JUCE_CATCH_ALL_ASSERT catch (...) { jassertfalse; }
#else


+ 1
- 1
src/core/juce_PlatformUtilities.h View File

@@ -156,7 +156,7 @@ public:
This is needed to avoid unicode problems with the argc type params.
*/
static const String JUCE_CALLTYPE getCurrentCommandLineParams() throw();
static const String JUCE_CALLTYPE getCurrentCommandLineParams();
#endif
/** Clears the floating point unit's flags.


+ 1
- 1
src/cryptography/juce_Primes.cpp View File

@@ -218,7 +218,7 @@ const BigInteger Primes::createProbablePrime (const int bitLength,
return candidate;
}
jassertfalse
jassertfalse;
return BigInteger();
}


+ 1
- 1
src/cryptography/juce_RSAKey.cpp View File

@@ -64,7 +64,7 @@ bool RSAKey::applyToValue (BigInteger& value) const
{
if (part1.isZero() || part2.isZero() || value <= 0)
{
jassertfalse // using an uninitialised key
jassertfalse; // using an uninitialised key
value.clear();
return false;
}


+ 1
- 1
src/gui/components/controls/juce_ListBox.cpp View File

@@ -945,7 +945,7 @@ void ListBox::startDragAndDrop (const MouseEvent& e, const String& dragDescripti
{
// to be able to do a drag-and-drop operation, the listbox needs to
// be inside a component which is also a DragAndDropContainer.
jassertfalse
jassertfalse;
}
}


+ 1
- 1
src/gui/components/controls/juce_Slider.cpp View File

@@ -812,7 +812,7 @@ float Slider::getPositionOfValue (const double value)
}
else
{
jassertfalse // not a valid call on a slider that doesn't work linearly!
jassertfalse; // not a valid call on a slider that doesn't work linearly!
return 0.0f;
}
}


+ 1
- 1
src/gui/components/controls/juce_TextEditor.cpp View File

@@ -2190,7 +2190,7 @@ void TextEditor::handleCommandMessage (const int commandId)
break;
default:
jassertfalse
jassertfalse;
break;
}
}


+ 2
- 2
src/gui/components/controls/juce_TreeView.cpp View File

@@ -149,7 +149,7 @@ public:
{
// to be able to do a drag-and-drop operation, the treeview needs to
// be inside a component which is also a DragAndDropContainer.
jassertfalse
jassertfalse;
}
}
}
@@ -1801,7 +1801,7 @@ XmlElement* TreeViewItem::getOpennessState() const throw()
{
// trying to save the openness for an element that has no name - this won't
// work because it needs the names to identify what to open.
jassertfalse
jassertfalse;
}
return 0;


+ 2
- 2
src/gui/components/juce_Component.cpp View File

@@ -472,7 +472,7 @@ void Component::userTriedToCloseWindow()
If you want to ignore the event and don't want to trigger this assertion, just override
this method and do nothing.
*/
jassertfalse
jassertfalse;
}
void Component::minimisationStateChanged (bool)
@@ -625,7 +625,7 @@ void Component::toBack()
if (isOnDesktop())
{
jassertfalse //xxx need to add this to native window
jassertfalse; //xxx need to add this to native window
}
else if (parentComponent_ != 0 && childList.getFirst() != this)
{


+ 2
- 2
src/gui/components/juce_Desktop.h View File

@@ -138,7 +138,7 @@ public:
@see isScreenSaverEnabled
*/
static void setScreenSaverEnabled (bool isEnabled) throw();
static void setScreenSaverEnabled (bool isEnabled);
/** Returns true if the screensaver has not been turned off.
@@ -148,7 +148,7 @@ public:
@see setScreenSaverEnabled
*/
static bool isScreenSaverEnabled() throw();
static bool isScreenSaverEnabled();
//==============================================================================
/** Registers a MouseListener that will receive all mouse events that occur on


+ 1
- 1
src/gui/components/layout/juce_MultiDocumentPanel.cpp View File

@@ -322,7 +322,7 @@ bool MultiDocumentPanel::closeDocument (Component* component,
}
else
{
jassertfalse
jassertfalse;
}
return true;


+ 2
- 2
src/gui/components/layout/juce_ResizableBorderComponent.cpp View File

@@ -164,7 +164,7 @@ void ResizableBorderComponent::mouseDown (const MouseEvent& e)
{
if (component == 0)
{
jassertfalse // You've deleted the component that this resizer was supposed to be using!
jassertfalse; // You've deleted the component that this resizer was supposed to be using!
return;
}
@@ -180,7 +180,7 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e)
{
if (component == 0)
{
jassertfalse // You've deleted the component that this resizer was supposed to be using!
jassertfalse; // You've deleted the component that this resizer was supposed to be using!
return;
}


+ 4
- 4
src/gui/components/lookandfeel/juce_LookAndFeel.cpp View File

@@ -247,7 +247,7 @@ const Colour LookAndFeel::findColour (const int colourId) const throw()
if (index >= 0)
return colours [index];
jassertfalse
jassertfalse;
return Colours::black;
}
@@ -1923,7 +1923,7 @@ Button* LookAndFeel::createDocumentWindowButton (int buttonType)
return new GlassWindowButton ("maximise", Colour (0xff119911), shape, fullscreenShape);
}
jassertfalse
jassertfalse;
return 0;
}
@@ -3050,8 +3050,8 @@ void LookAndFeel::drawGlassLozenge (Graphics& g,
if (! (flatOnRight || flatOnTop || flatOnBottom))
{
cg.x1 = x + width - edgeBlurRadius;
cg.x2 = x + width;
cg.point1.setX (x + width - edgeBlurRadius);
cg.point2.setX (x + width);
g.saveState();
g.setGradientFill (cg);


+ 1
- 1
src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp View File

@@ -573,7 +573,7 @@ Button* OldSchoolLookAndFeel::createDocumentWindowButton (int buttonType)
return b;
}
jassertfalse
jassertfalse;
return 0;
}


+ 2
- 2
src/gui/components/menus/juce_PopupMenu.cpp View File

@@ -1734,14 +1734,14 @@ void PopupMenuCustomComponent::triggerMenuItem()
else
{
// something must have gone wrong with the component hierarchy if this happens..
jassertfalse
jassertfalse;
}
}
else
{
// why isn't this component inside a menu? Not much point triggering the item if
// there's no menu.
jassertfalse
jassertfalse;
}
}


+ 1
- 1
src/gui/components/mouse/juce_MouseEvent.cpp View File

@@ -64,7 +64,7 @@ const MouseEvent MouseEvent::getEventRelativeTo (Component* const otherComponent
{
if (otherComponent == 0)
{
jassertfalse
jassertfalse;
return *this;
}


+ 2
- 2
src/gui/components/special/juce_ColourSelector.cpp View File

@@ -616,13 +616,13 @@ int ColourSelector::getNumSwatches() const
const Colour ColourSelector::getSwatchColour (const int) const
{
jassertfalse // if you've overridden getNumSwatches(), you also need to implement this method
jassertfalse; // if you've overridden getNumSwatches(), you also need to implement this method
return Colours::black;
}
void ColourSelector::setSwatchColour (const int, const Colour&) const
{
jassertfalse // if you've overridden getNumSwatches(), you also need to implement this method
jassertfalse; // if you've overridden getNumSwatches(), you also need to implement this method
}


+ 1
- 1
src/gui/components/windows/juce_DocumentWindow.cpp View File

@@ -176,7 +176,7 @@ void DocumentWindow::closeButtonPressed()
still get cleaned-up if the app is quit by some other means (e.g. a cmd-Q on the mac
or closing it via the taskbar icon on Windows).
*/
jassertfalse
jassertfalse;
}
void DocumentWindow::minimiseButtonPressed()


+ 4
- 4
src/gui/components/windows/juce_ResizableWindow.cpp View File

@@ -392,7 +392,7 @@ void ResizableWindow::setFullScreen (const bool shouldBeFullScreen)
}
else
{
jassertfalse
jassertfalse;
}
}
else
@@ -427,7 +427,7 @@ void ResizableWindow::setMinimised (const bool shouldMinimise)
}
else
{
jassertfalse
jassertfalse;
}
}
}
@@ -533,7 +533,7 @@ void ResizableWindow::addChildComponent (Component* const child, int zOrder)
If you really know what you're doing and want to avoid this assertion, just call
Component::addChildComponent directly.
*/
jassertfalse
jassertfalse;
Component::addChildComponent (child, zOrder);
}
@@ -550,7 +550,7 @@ void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder)
If you really know what you're doing and want to avoid this assertion, just call
Component::addAndMakeVisible directly.
*/
jassertfalse
jassertfalse;
Component::addAndMakeVisible (child, zOrder);
}


+ 46
- 55
src/gui/graphics/colour/juce_ColourGradient.cpp View File

@@ -34,7 +34,7 @@ BEGIN_JUCE_NAMESPACE
ColourGradient::ColourGradient() throw()
{
#if JUCE_DEBUG
x1 = 987654.0f;
point1.setX (987654.0f);
#endif
}
@@ -45,17 +45,12 @@ ColourGradient::ColourGradient (const Colour& colour1,
const float x2_,
const float y2_,
const bool isRadial_)
: x1 (x1_),
y1 (y1_),
x2 (x2_),
y2 (y2_),
: point1 (x1_, y1_),
point2 (x2_, y2_),
isRadial (isRadial_)
{
colours.add (0);
colours.add (colour1.getARGB());
colours.add (1 << 16);
colours.add (colour2.getARGB());
colours.add (ColourPoint (0, colour1));
colours.add (ColourPoint (1 << 16, colour2));
}
ColourGradient::~ColourGradient()
@@ -77,62 +72,64 @@ void ColourGradient::addColour (const double proportionAlongGradient,
const uint32 pos = jlimit (0, 65535, roundToInt (proportionAlongGradient * 65536.0));
int i;
for (i = 0; i < colours.size(); i += 2)
if (colours.getUnchecked(i) > pos)
for (i = 0; i < colours.size(); ++i)
if (colours.getReference(i).position > pos)
break;
colours.insert (i, pos);
colours.insert (i + 1, colour.getARGB());
colours.insert (i, ColourPoint (pos, colour));
}
void ColourGradient::multiplyOpacity (const float multiplier) throw()
{
for (int i = 1; i < colours.size(); i += 2)
for (int i = 0; i < colours.size(); ++i)
{
const Colour c (colours.getUnchecked(i));
colours.set (i, c.withMultipliedAlpha (multiplier).getARGB());
Colour& c = colours.getReference(i).colour;
c = c.withMultipliedAlpha (multiplier);
}
}
//==============================================================================
int ColourGradient::getNumColours() const throw()
{
return colours.size() >> 1;
return colours.size();
}
double ColourGradient::getColourPosition (const int index) const throw()
{
return jlimit (0.0, 1.0, colours [index << 1] / 65535.0);
if (((unsigned int) index) < (unsigned int) colours.size())
return jlimit (0.0, 1.0, colours.getReference (index).position / 65535.0);
return 0;
}
const Colour ColourGradient::getColour (const int index) const throw()
{
return Colour (colours [(index << 1) + 1]);
if (((unsigned int) index) < (unsigned int) colours.size())
return colours.getReference (index).colour;
return Colour();
}
const Colour ColourGradient::getColourAtPosition (const float position) const throw()
{
jassert (colours.getUnchecked (0) == 0); // the first colour specified has to go at position 0
jassert (colours.getReference(0).position == 0); // the first colour specified has to go at position 0
const int integerPos = jlimit (0, 65535, roundToInt (position * 65536.0f));
if (integerPos <= 0 || colours.size() <= 2)
if (integerPos <= 0 || colours.size() <= 1)
return getColour (0);
int i = colours.size() - 2;
while (integerPos < (int) colours.getUnchecked(i))
i -= 2;
int i = colours.size() - 1;
while (integerPos < (int) colours.getReference(i).position)
--i;
if (i >= colours.size() - 2)
return Colour (colours.getUnchecked(i));
if (i >= colours.size() - 1)
return colours.getReference(i).colour;
const int pos1 = colours.getUnchecked (i);
const Colour col1 (colours.getUnchecked (i + 1));
const ColourPoint& p1 = colours.getReference (i);
const ColourPoint& p2 = colours.getReference (i + 1);
const int pos2 = colours.getUnchecked (i + 2);
const Colour col2 (colours.getUnchecked (i + 3));
return col1.interpolatedWith (col2, (integerPos - pos1) / (float) (pos2 - pos1));
return p1.colour.interpolatedWith (p2.colour, (integerPos - p1.position) / (float) (p2.position - p1.position));
}
//==============================================================================
@@ -141,32 +138,26 @@ int ColourGradient::createLookupTable (const AffineTransform& transform, HeapBlo
#if JUCE_DEBUG
// trying to use the object without setting its co-ordinates? Have a careful read of
// the comments for the constructors.
jassert (x1 != 987654.0f);
jassert (point1.getX() != 987654.0f);
#endif
const int numColours = colours.size() >> 1;
float tx1 = x1, ty1 = y1, tx2 = x2, ty2 = y2;
transform.transformPoint (tx1, ty1);
transform.transformPoint (tx2, ty2);
const double distance = juce_hypot (tx1 - tx2, ty1 - ty2);
const int numEntries = jlimit (1, (numColours - 1) << 8, 3 * (int) distance);
const int numEntries = jlimit (1, (colours.size() - 1) << 8,
3 * (int) point1.transformedBy (transform)
.getDistanceFrom (point2.transformedBy (transform)));
lookupTable.malloc (numEntries);
if (numColours >= 2)
if (colours.size() >= 2)
{
jassert (colours.getUnchecked (0) == 0); // the first colour specified has to go at position 0
jassert (colours.getReference(0).position == 0); // the first colour specified has to go at position 0
PixelARGB pix1 (colours.getUnchecked (1));
pix1.premultiply();
PixelARGB pix1 (colours.getReference (0).colour.getPixelARGB());
int index = 0;
for (int j = 2; j < colours.size(); j += 2)
for (int j = 1; j < colours.size(); ++j)
{
const int numToDo = ((colours.getUnchecked (j) * (numEntries - 1)) >> 16) - index;
PixelARGB pix2 (colours.getUnchecked (j + 1));
pix2.premultiply();
const ColourPoint& p = colours.getReference (j);
const int numToDo = ((p.position * (numEntries - 1)) >> 16) - index;
const PixelARGB pix2 (p.colour.getPixelARGB());
for (int i = 0; i < numToDo; ++i)
{
@@ -185,7 +176,7 @@ int ColourGradient::createLookupTable (const AffineTransform& transform, HeapBlo
}
else
{
jassertfalse // no colours specified!
jassertfalse; // no colours specified!
}
return numEntries;
@@ -193,8 +184,8 @@ int ColourGradient::createLookupTable (const AffineTransform& transform, HeapBlo
bool ColourGradient::isOpaque() const throw()
{
for (int i = 1; i < colours.size(); i += 2)
if (PixelARGB (colours.getUnchecked(i)).getAlpha() < 0xff)
for (int i = 0; i < colours.size(); ++i)
if (! colours.getReference(i).colour.isOpaque())
return false;
return true;
@@ -202,8 +193,8 @@ bool ColourGradient::isOpaque() const throw()
bool ColourGradient::isInvisible() const throw()
{
for (int i = 1; i < colours.size(); i += 2)
if (PixelARGB (colours.getUnchecked(i)).getAlpha() > 0)
for (int i = 0; i < colours.size(); ++i)
if (! colours.getReference(i).colour.isTransparent())
return false;
return true;


+ 16
- 8
src/gui/graphics/colour/juce_ColourGradient.h View File

@@ -27,7 +27,7 @@
#define __JUCE_COLOURGRADIENT_JUCEHEADER__
#include "juce_Colour.h"
#include "../geometry/juce_AffineTransform.h"
#include "../geometry/juce_Point.h"
#include "../../../containers/juce_Array.h"
#include "../../../containers/juce_HeapBlock.h"
@@ -132,14 +132,10 @@ public:
bool isInvisible() const throw();
//==============================================================================
float x1;
float y1;
float x2;
float y2;
Point<float> point1, point2;
/** If true, the gradient should be filled circularly, centred around
(x1, y1), with (x2, y2) defining a point on the circumference.
point1, with point2 defining a point on the circumference.
If false, the gradient is linear between the two points.
*/
@@ -149,7 +145,19 @@ public:
juce_UseDebuggingNewOperator
private:
Array <uint32> colours;
struct ColourPoint
{
ColourPoint() throw() {}
ColourPoint (uint32 position_, const Colour& colour_) throw()
: position (position_), colour (colour_)
{}
uint32 position;
Colour colour;
};
Array <ColourPoint> colours;
};


+ 2
- 2
src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp View File

@@ -143,7 +143,7 @@ void LowLevelGraphicsPostScriptRenderer::clipToPath (const Path& path, const Aff
void LowLevelGraphicsPostScriptRenderer::clipToImageAlpha (const Image& /*sourceImage*/, const Rectangle<int>& /*srcClip*/, const AffineTransform& /*transform*/)
{
needToClip = true;
jassertfalse // xxx
jassertfalse; // xxx
}
bool LowLevelGraphicsPostScriptRenderer::clipRegionIntersects (const Rectangle<int>& r)
@@ -299,7 +299,7 @@ void LowLevelGraphicsPostScriptRenderer::writePath (const Path& path) const
break;
default:
jassertfalse
jassertfalse;
break;
}
}


+ 11
- 12
src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp View File

@@ -198,8 +198,8 @@ public:
: lookupTable (lookupTable_), numEntries (numEntries_)
{
jassert (numEntries_ >= 0);
Point<float> p1 (gradient.x1, gradient.y1);
Point<float> p2 (gradient.x2, gradient.y2);
Point<float> p1 (gradient.point1);
Point<float> p2 (gradient.point2);
if (! transform.isIdentity())
{
@@ -271,13 +271,12 @@ public:
const PixelARGB* const lookupTable_, const int numEntries_)
: lookupTable (lookupTable_),
numEntries (numEntries_),
gx1 (gradient.x1),
gy1 (gradient.y1)
gx1 (gradient.point1.getX()),
gy1 (gradient.point1.getY())
{
jassert (numEntries_ >= 0);
const float gdx = gradient.x1 - gradient.x2;
const float gdy = gradient.y1 - gradient.y2;
maxDist = gdx * gdx + gdy * gdy;
const Point<float> diff (gradient.point1 - gradient.point2);
maxDist = diff.getX() * diff.getX() + diff.getY() * diff.getY();
invScale = numEntries / std::sqrt (maxDist);
jassert (roundToInt (std::sqrt (maxDist) * invScale) <= numEntries);
}
@@ -1908,16 +1907,16 @@ public:
ColourGradient g2 (*(fillType.gradient));
g2.multiplyOpacity (fillType.getOpacity());
g2.x1 -= 0.5f; g2.y1 -= 0.5f;
g2.x2 -= 0.5f; g2.y2 -= 0.5f;
g2.point1.addXY (-0.5f, -0.5f);
g2.point2.addXY (-0.5f, -0.5f);
AffineTransform transform (fillType.transform.translated ((float) xOffset, (float) yOffset));
const bool isIdentity = transform.isOnlyTranslation();
if (isIdentity)
{
// If our translation doesn't involve any distortion, we can speed it up..
transform.transformPoint (g2.x1, g2.y1);
transform.transformPoint (g2.x2, g2.y2);
g2.point1.applyTransform (transform);
g2.point2.applyTransform (transform);
transform = AffineTransform::identity;
}
@@ -2096,7 +2095,7 @@ void LowLevelGraphicsSoftwareRenderer::restoreState()
}
else
{
jassertfalse // trying to pop with an empty stack!
jassertfalse; // trying to pop with an empty stack!
}
}


+ 1
- 1
src/gui/graphics/drawables/juce_DrawableComposite.cpp View File

@@ -61,7 +61,7 @@ void DrawableComposite::insertDrawable (Drawable* drawable,
}
else
{
jassertfalse // trying to add a drawable that's already in here!
jassertfalse; // trying to add a drawable that's already in here!
}
}
}


+ 8
- 10
src/gui/graphics/drawables/juce_DrawablePath.cpp View File

@@ -142,10 +142,8 @@ static const FillType readFillTypeFromTree (const ValueTree& v)
else if (type.equalsIgnoreCase ("gradient"))
{
ColourGradient g;
g.x1 = v["x1"];
g.y1 = v["y1"];
g.x2 = v["x2"];
g.y2 = v["y2"];
g.point1.setXY (v["x1"], v["y1"]);
g.point2.setXY (v["x2"], v["y2"]);
g.isRadial = v["radial"];
StringArray colours;
@@ -158,7 +156,7 @@ static const FillType readFillTypeFromTree (const ValueTree& v)
return g;
}
jassertfalse
jassertfalse;
return FillType();
}
@@ -174,10 +172,10 @@ static ValueTree createTreeForFillType (const String& tagName, const FillType& f
else if (fillType.isGradient())
{
v.setProperty ("type", "gradient", 0);
v.setProperty ("x1", fillType.gradient->x1, 0);
v.setProperty ("y1", fillType.gradient->y1, 0);
v.setProperty ("x2", fillType.gradient->x2, 0);
v.setProperty ("y2", fillType.gradient->y2, 0);
v.setProperty ("x1", fillType.gradient->point1.getX(), 0);
v.setProperty ("y1", fillType.gradient->point1.getY(), 0);
v.setProperty ("x2", fillType.gradient->point2.getX(), 0);
v.setProperty ("y2", fillType.gradient->point2.getY(), 0);
v.setProperty ("radial", fillType.gradient->isRadial, 0);
String s;
@@ -189,7 +187,7 @@ static ValueTree createTreeForFillType (const String& tagName, const FillType& f
}
else
{
jassertfalse //xxx
jassertfalse; //xxx
}
return v;


+ 2
- 2
src/gui/graphics/drawables/juce_DrawableText.cpp View File

@@ -92,7 +92,7 @@ ValueTree DrawableText::createValueTree() const
if (getName().isNotEmpty())
v.setProperty ("id", getName(), 0);
jassertfalse // xxx not finished!
jassertfalse; // xxx not finished!
return v;
}
@@ -105,7 +105,7 @@ DrawableText* DrawableText::createFromValueTree (const ValueTree& tree)
dt->setName (tree ["id"]);
jassertfalse // xxx not finished!
jassertfalse; // xxx not finished!
return dt;
}


+ 8
- 10
src/gui/graphics/drawables/juce_SVGParser.cpp View File

@@ -752,25 +752,23 @@ private:
if (gradient.isRadial)
{
gradient.x1 = dx + getCoordLength (fillXml->getStringAttribute ("cx", "50%"), gradientWidth);
gradient.y1 = dy + getCoordLength (fillXml->getStringAttribute ("cy", "50%"), gradientHeight);
gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("cx", "50%"), gradientWidth),
dy + getCoordLength (fillXml->getStringAttribute ("cy", "50%"), gradientHeight));
const float radius = getCoordLength (fillXml->getStringAttribute ("r", "50%"), gradientWidth);
gradient.x2 = gradient.x1 + radius;
gradient.y2 = gradient.y1;
gradient.point2 = gradient.point1 + Point<float> (radius, 0.0f);
//xxx (the fx, fy focal point isn't handled properly here..)
}
else
{
gradient.x1 = dx + getCoordLength (fillXml->getStringAttribute ("x1", "0%"), gradientWidth);
gradient.y1 = dy + getCoordLength (fillXml->getStringAttribute ("y1", "0%"), gradientHeight);
gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x1", "0%"), gradientWidth),
dy + getCoordLength (fillXml->getStringAttribute ("y1", "0%"), gradientHeight));
gradient.x2 = dx + getCoordLength (fillXml->getStringAttribute ("x2", "100%"), gradientWidth);
gradient.y2 = dy + getCoordLength (fillXml->getStringAttribute ("y2", "0%"), gradientHeight);
gradient.point2.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x2", "100%"), gradientWidth),
dy + getCoordLength (fillXml->getStringAttribute ("y2", "0%"), gradientHeight));
if (gradient.x1 == gradient.x2 && gradient.y1 == gradient.y2)
if (gradient.point1 == gradient.point2)
return Colour (gradient.getColour (gradient.getNumColours() - 1));
}


+ 4
- 4
src/gui/graphics/geometry/juce_Path.cpp View File

@@ -827,7 +827,7 @@ void Path::addPath (const Path& other)
else
{
// something's gone wrong with the element list!
jassertfalse
jassertfalse;
}
}
}
@@ -881,7 +881,7 @@ void Path::addPath (const Path& other,
else
{
// something's gone wrong with the element list!
jassertfalse
jassertfalse;
}
}
}
@@ -1323,7 +1323,7 @@ void Path::loadPathFromStream (InputStream& source)
return; // end of path marker
default:
jassertfalse // illegal char in the stream
jassertfalse; // illegal char in the stream
break;
}
}
@@ -1529,7 +1529,7 @@ void Path::restoreFromString (const String& stringVersion)
break;
default:
jassertfalse // illegal string format?
jassertfalse; // illegal string format?
break;
}
}


+ 13
- 4
src/gui/graphics/geometry/juce_Point.h View File

@@ -59,17 +59,20 @@ public:
/** Copies this point from another one. */
Point& operator= (const Point& other) throw() { x = other.x; y = other.y; return *this; }
/** Returns true if the point is (0, 0). */
bool isOrigin() const throw() { return x == ValueType() && y == ValueType(); }
/** Returns the point's x co-ordinate. */
inline ValueType getX() const throw() { return x; }
/** Returns the point's y co-ordinate. */
inline ValueType getY() const throw() { return y; }
inline bool operator== (const Point& other) const throw() { return x == other.x && y == other.y; }
inline bool operator!= (const Point& other) const throw() { return x != other.x || y != other.y; }
/** Sets the point's x co-ordinate. */
inline void setX (const ValueType newX) throw() { x = newX; }
/** Returns true if the point is (0, 0). */
bool isOrigin() const throw() { return x == ValueType() && y == ValueType(); }
/** Sets the point's y co-ordinate. */
inline void setY (const ValueType newY) throw() { y = newY; }
/** Returns a point which has the same Y position as this one, but a new X. */
const Point withX (const ValueType newX) const throw() { return Point (newX, y); }
@@ -83,6 +86,9 @@ public:
/** Adds a pair of co-ordinates to this value. */
void addXY (const ValueType xToAdd, const ValueType yToAdd) throw() { x += xToAdd; y += yToAdd; }
inline bool operator== (const Point& other) const throw() { return x == other.x && y == other.y; }
inline bool operator!= (const Point& other) const throw() { return x != other.x || y != other.y; }
/** Adds two points together. */
const Point operator+ (const Point& other) const throw() { return Point (x + other.x, y + other.y); }
@@ -129,6 +135,9 @@ public:
*/
void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); }
/** Returns the position of this point, if it is transformed by a given AffineTransform. */
const Point transformedBy (const AffineTransform& transform) const throw() { ValueType x2 (x), y2 (y); transform.transformPoint (x2, y2); return Point (x2, y2); }
/** Returns the point as a string in the form "x, y". */
const String toString() const { return String (x) + ", " + String (y); }


+ 1
- 1
src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp View File

@@ -354,7 +354,7 @@ bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out)
if (image.hasAlphaChannel())
{
// this method could fill the background in white and still save the image..
jassertfalse
jassertfalse;
return true;
}


+ 1
- 1
src/gui/graphics/imaging/juce_Image.cpp View File

@@ -333,7 +333,7 @@ void Image::multiplyAllAlphas (const float amountToMultiplyBy)
}
else
{
jassertfalse // can't do this without an alpha-channel!
jassertfalse; // can't do this without an alpha-channel!
}
}


+ 1
- 1
src/gui/graphics/imaging/juce_ImageCache.cpp View File

@@ -161,7 +161,7 @@ void ImageCache::incReferenceCount (Image* const image)
}
}
jassertfalse // (trying to inc the ref count of an image that's not in the cache)
jassertfalse; // (trying to inc the ref count of an image that's not in the cache)
}
void ImageCache::timerCallback()


+ 3
- 3
src/io/files/juce_File.cpp View File

@@ -98,7 +98,7 @@ const String File::parseAbsolutePath (const String& p)
"File::getCurrentWorkingDirectory().getChildFile (myUnknownPath)" would return an absolute
path if that's what was supplied, or would evaluate a partial path relative to the CWD.
*/
jassertfalse
jassertfalse;
path = File::getCurrentWorkingDirectory().getFullPathName().substring (0, 2) + path;
}
@@ -112,7 +112,7 @@ const String File::parseAbsolutePath (const String& p)
"File::getCurrentWorkingDirectory().getChildFile (myUnknownPath)" would return an absolute
path if that's what was supplied, or would evaluate a partial path relative to the CWD.
*/
jassertfalse
jassertfalse;
return File::getCurrentWorkingDirectory().getChildFile (path).getFullPathName();
}
@@ -601,7 +601,7 @@ int File::getNumberOfChildFiles (const int whatToLookFor,
else
{
// trying to search for files inside a non-directory?
jassertfalse
jassertfalse;
}
return count;


+ 1
- 1
src/io/files/juce_FileOutputStream.cpp View File

@@ -50,7 +50,7 @@ FileOutputStream::FileOutputStream (const File& f,
if (currentPosition < 0)
{
jassertfalse
jassertfalse;
juce_fileClose (fileHandle);
fileHandle = 0;
}


+ 1
- 1
src/io/files/juce_TemporaryFile.cpp View File

@@ -100,7 +100,7 @@ bool TemporaryFile::overwriteTargetFileWithTemporary() const
{
// There's no temporary file to use. If your write failed, you should
// probably check, and not bother calling this method.
jassertfalse
jassertfalse;
}
return false;


+ 1
- 1
src/io/network/juce_Socket.cpp View File

@@ -379,7 +379,7 @@ bool StreamingSocket::connect (const String& remoteHostName,
{
if (isListener)
{
jassertfalse // a listener socket can't connect to another one!
jassertfalse; // a listener socket can't connect to another one!
return false;
}


+ 1
- 1
src/io/streams/juce_GZIPCompressorOutputStream.cpp View File

@@ -198,7 +198,7 @@ int64 GZIPCompressorOutputStream::getPosition()
bool GZIPCompressorOutputStream::setPosition (int64 /*newPosition*/)
{
jassertfalse // can't do it!
jassertfalse; // can't do it!
return false;
}


+ 2
- 2
src/io/streams/juce_InputStream.cpp View File

@@ -93,8 +93,8 @@ int InputStream::readCompressedInt()
const int numBytes = (sizeByte & 0x7f);
if (numBytes > 4)
{
jassertfalse // trying to read corrupt data - this method must only be used
// to read data that was written by OutputStream::writeCompressedInt()
jassertfalse; // trying to read corrupt data - this method must only be used
// to read data that was written by OutputStream::writeCompressedInt()
return 0;
}


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save