mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Minor clean-ups.
This commit is contained in:
parent
12c28fd882
commit
910b834f72
19 changed files with 95 additions and 57 deletions
|
|
@ -47,12 +47,7 @@ void DocumentEditorComponent::documentAboutToClose (OpenDocumentManager::Documen
|
|||
jassert (document != nullptr);
|
||||
|
||||
if (ProjectContentComponent* pcc = findParentComponentOfClass<ProjectContentComponent>())
|
||||
{
|
||||
pcc->hideDocument (document);
|
||||
return;
|
||||
}
|
||||
|
||||
jassertfalse
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,23 +77,21 @@ public:
|
|||
|
||||
Component* refreshComponentForRow (int rowNumber, bool /*isRowSelected*/, Component* existingComponentToUpdate)
|
||||
{
|
||||
ScopedPointer<Component> existing (existingComponentToUpdate);
|
||||
|
||||
if (rowNumber < getNumRows())
|
||||
{
|
||||
Project::Item child (item.getChild (rowNumber));
|
||||
|
||||
if (existingComponentToUpdate == nullptr
|
||||
|| dynamic_cast <FileOptionComponent*> (existingComponentToUpdate)->item != child)
|
||||
|| dynamic_cast <FileOptionComponent*> (existing.get())->item != child)
|
||||
{
|
||||
delete existingComponentToUpdate;
|
||||
existingComponentToUpdate = new FileOptionComponent (child);
|
||||
existing = nullptr;
|
||||
existing = new FileOptionComponent (child);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
deleteAndZero (existingComponentToUpdate);
|
||||
}
|
||||
|
||||
return existingComponentToUpdate;
|
||||
return existing.release();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -267,6 +267,23 @@ namespace CodeHelpers
|
|||
return result + currentLine.trimEnd() + ")";
|
||||
}
|
||||
|
||||
String floatLiteral (float value, int numDecPlaces)
|
||||
{
|
||||
String s ((double) value, numDecPlaces);
|
||||
|
||||
if (s.containsChar ('.'))
|
||||
s << 'f';
|
||||
else
|
||||
s << ".0f";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
String boolLiteral (bool value)
|
||||
{
|
||||
return value ? "true" : "false";
|
||||
}
|
||||
|
||||
String colourToCode (const Colour& col)
|
||||
{
|
||||
const Colour colours[] =
|
||||
|
|
@ -292,6 +309,33 @@ namespace CodeHelpers
|
|||
return "Colour (0x" + hexString8Digits ((int) col.getARGB()) + ')';
|
||||
}
|
||||
|
||||
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: break;
|
||||
}
|
||||
|
||||
jassertfalse;
|
||||
return "Justification (" + String (justification.getFlags()) + ")";
|
||||
}
|
||||
|
||||
void writeDataAsCppLiteral (const MemoryBlock& mb, OutputStream& out,
|
||||
bool breakAtNewLines, bool allowStringBreaks)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,8 +39,12 @@ namespace CodeHelpers
|
|||
String makeBinaryDataIdentifierName (const File& file);
|
||||
|
||||
String stringLiteral (const String& text, int maxLineLength = -1);
|
||||
String floatLiteral (float value, int numDecPlaces);
|
||||
String boolLiteral (bool value);
|
||||
|
||||
String colourToCode (const Colour& col);
|
||||
String justificationToCode (const Justification&);
|
||||
|
||||
String alignFunctionCallParams (const String& call, const StringArray& parameters, int maxLineLength);
|
||||
|
||||
void writeDataAsCppLiteral (const MemoryBlock& data, OutputStream& out,
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
selector.setBounds (0, 0, getWidth(), getHeight());
|
||||
selector.setBounds (getLocalBounds());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@ void DrawablePath::applyRelativePath (const RelativePointPath& newRelativePath,
|
|||
class DrawablePath::RelativePositioner : public RelativeCoordinatePositionerBase
|
||||
{
|
||||
public:
|
||||
RelativePositioner (DrawablePath& component_)
|
||||
: RelativeCoordinatePositionerBase (component_),
|
||||
owner (component_)
|
||||
RelativePositioner (DrawablePath& comp)
|
||||
: RelativeCoordinatePositionerBase (comp),
|
||||
owner (comp)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ DrawableShape::~DrawableShape()
|
|||
class DrawableShape::RelativePositioner : public RelativeCoordinatePositionerBase
|
||||
{
|
||||
public:
|
||||
RelativePositioner (DrawableShape& component_, const DrawableShape::RelativeFillType& fill_, bool isMainFill_)
|
||||
: RelativeCoordinatePositionerBase (component_),
|
||||
owner (component_),
|
||||
fill (fill_),
|
||||
isMainFill (isMainFill_)
|
||||
RelativePositioner (DrawableShape& comp, const DrawableShape::RelativeFillType& f, bool isMain)
|
||||
: RelativeCoordinatePositionerBase (comp),
|
||||
owner (comp),
|
||||
fill (f),
|
||||
isMainFill (isMain)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ class FileChooserDialogBox::ContentComponent : public Component
|
|||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
ContentComponent (const String& name, const String& instructions_, FileBrowserComponent& chooserComponent_)
|
||||
ContentComponent (const String& name, const String& desc, FileBrowserComponent& chooser)
|
||||
: Component (name),
|
||||
chooserComponent (chooserComponent_),
|
||||
okButton (chooserComponent_.getActionVerb()),
|
||||
chooserComponent (chooser),
|
||||
okButton (chooser.getActionVerb()),
|
||||
cancelButton (TRANS ("Cancel")),
|
||||
newFolderButton (TRANS ("New Folder")),
|
||||
instructions (instructions_)
|
||||
instructions (desc)
|
||||
{
|
||||
addAndMakeVisible (&chooserComponent);
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ void FilenameComponent::paintOverChildren (Graphics& g)
|
|||
if (isFileDragOver)
|
||||
{
|
||||
g.setColour (Colours::red.withAlpha (0.2f));
|
||||
g.drawRect (0, 0, getWidth(), getHeight(), 3);
|
||||
g.drawRect (getLocalBounds(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,13 +62,11 @@ void ImagePreviewComponent::timerCallback()
|
|||
currentDetails = String::empty;
|
||||
repaint();
|
||||
|
||||
ScopedPointer <FileInputStream> in (fileToLoad.createInputStream());
|
||||
ScopedPointer<FileInputStream> in (fileToLoad.createInputStream());
|
||||
|
||||
if (in != nullptr)
|
||||
{
|
||||
ImageFileFormat* const format = ImageFileFormat::findImageFormatForStream (*in);
|
||||
|
||||
if (format != nullptr)
|
||||
if (ImageFileFormat* const format = ImageFileFormat::findImageFormatForStream (*in))
|
||||
{
|
||||
currentThumbnail = format->decodeImage (*in);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
ComponentMovementWatcher::ComponentMovementWatcher (Component* const component_)
|
||||
: component (component_),
|
||||
ComponentMovementWatcher::ComponentMovementWatcher (Component* const comp)
|
||||
: component (comp),
|
||||
lastPeerID (0),
|
||||
reentrant (false),
|
||||
wasShowing (component_->isShowing())
|
||||
wasShowing (comp->isShowing())
|
||||
{
|
||||
jassert (component != nullptr); // can't use this with a null pointer..
|
||||
|
||||
|
|
|
|||
|
|
@ -435,10 +435,10 @@ bool DragAndDropContainer::shouldDropFilesWhenDraggedExternally (const DragAndDr
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
DragAndDropTarget::SourceDetails::SourceDetails (const var& description_, Component* sourceComponent_, const Point<int>& localPosition_) noexcept
|
||||
: description (description_),
|
||||
sourceComponent (sourceComponent_),
|
||||
localPosition (localPosition_)
|
||||
DragAndDropTarget::SourceDetails::SourceDetails (const var& desc, Component* comp, const Point<int>& pos) noexcept
|
||||
: description (desc),
|
||||
sourceComponent (comp),
|
||||
localPosition (pos)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
class MarkerListScope : public Expression::Scope
|
||||
{
|
||||
public:
|
||||
MarkerListScope (Component& component_) : component (component_) {}
|
||||
MarkerListScope (Component& comp) : component (comp) {}
|
||||
|
||||
Expression getSymbolValue (const String& symbol) const
|
||||
{
|
||||
|
|
@ -90,8 +90,8 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
RelativeCoordinatePositionerBase::ComponentScope::ComponentScope (Component& component_)
|
||||
: component (component_)
|
||||
RelativeCoordinatePositionerBase::ComponentScope::ComponentScope (Component& comp)
|
||||
: component (comp)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -151,8 +151,8 @@ Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponen
|
|||
class RelativeCoordinatePositionerBase::DependencyFinderScope : public ComponentScope
|
||||
{
|
||||
public:
|
||||
DependencyFinderScope (Component& component_, RelativeCoordinatePositionerBase& positioner_, bool& ok_)
|
||||
: ComponentScope (component_), positioner (positioner_), ok (ok_)
|
||||
DependencyFinderScope (Component& comp, RelativeCoordinatePositionerBase& positioner_, bool& ok_)
|
||||
: ComponentScope (comp), positioner (positioner_), ok (ok_)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -221,8 +221,8 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
RelativeCoordinatePositionerBase::RelativeCoordinatePositionerBase (Component& component_)
|
||||
: Component::Positioner (component_), registeredOk (false)
|
||||
RelativeCoordinatePositionerBase::RelativeCoordinatePositionerBase (Component& comp)
|
||||
: Component::Positioner (comp), registeredOk (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -187,9 +187,9 @@ void RelativeRectangle::renameSymbol (const Expression::Symbol& oldSymbol, const
|
|||
class RelativeRectangleComponentPositioner : public RelativeCoordinatePositionerBase
|
||||
{
|
||||
public:
|
||||
RelativeRectangleComponentPositioner (Component& component_, const RelativeRectangle& rectangle_)
|
||||
: RelativeCoordinatePositionerBase (component_),
|
||||
rectangle (rectangle_)
|
||||
RelativeRectangleComponentPositioner (Component& comp, const RelativeRectangle& r)
|
||||
: RelativeCoordinatePositionerBase (comp),
|
||||
rectangle (r)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ void ListBox::paintOverChildren (Graphics& g)
|
|||
if (outlineThickness > 0)
|
||||
{
|
||||
g.setColour (findColour (outlineColourId));
|
||||
g.drawRect (0, 0, getWidth(), getHeight(), outlineThickness);
|
||||
g.drawRect (getLocalBounds(), outlineThickness);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ public:
|
|||
&& tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar)
|
||||
{
|
||||
g.setColour (findColour (Toolbar::editingModeOutlineColourId, true));
|
||||
g.drawRect (0, 0, getWidth(), getHeight(),
|
||||
jmin (2, (getWidth() - 1) / 2, (getHeight() - 1) / 2));
|
||||
g.drawRect (getLocalBounds(), jmin (2, (getWidth() - 1) / 2,
|
||||
(getHeight() - 1) / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -610,7 +610,6 @@ public:
|
|||
TreeViewItem* getRootItem() const noexcept { return rootItem; }
|
||||
|
||||
/** This will remove and delete the current root item.
|
||||
|
||||
It's a convenient way of deleting the item and calling setRootItem (nullptr).
|
||||
*/
|
||||
void deleteRootItem();
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ static Array <ComponentPeer*> heavyweightPeers;
|
|||
static uint32 lastUniqueID = 1;
|
||||
|
||||
//==============================================================================
|
||||
ComponentPeer::ComponentPeer (Component& component_, const int styleFlags_)
|
||||
: component (component_),
|
||||
styleFlags (styleFlags_),
|
||||
ComponentPeer::ComponentPeer (Component& comp, const int flags)
|
||||
: component (comp),
|
||||
styleFlags (flags),
|
||||
constrainer (nullptr),
|
||||
lastDragAndDropCompUnderMouse (nullptr),
|
||||
uniqueID (lastUniqueID += 2), // increment by 2 so that this can never hit 0
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ public:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
CodeDocument::Iterator::Iterator (const CodeDocument& document_) noexcept
|
||||
: document (&document_),
|
||||
CodeDocument::Iterator::Iterator (const CodeDocument& doc) noexcept
|
||||
: document (&doc),
|
||||
charPointer (nullptr),
|
||||
line (0),
|
||||
position (0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue