Browse Source

Minor clean-ups.

tags/2021-05-28
jules 12 years ago
parent
commit
910b834f72
19 changed files with 95 additions and 57 deletions
  1. +0
    -5
      extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp
  2. +6
    -8
      extras/Introjucer/Source/Project/jucer_GroupInformationComponent.h
  3. +44
    -0
      extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp
  4. +4
    -0
      extras/Introjucer/Source/Utility/jucer_CodeHelpers.h
  5. +1
    -1
      extras/Introjucer/Source/Utility/jucer_MiscUtilities.h
  6. +3
    -3
      modules/juce_gui_basics/drawables/juce_DrawablePath.cpp
  7. +5
    -5
      modules/juce_gui_basics/drawables/juce_DrawableShape.cpp
  8. +4
    -4
      modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp
  9. +1
    -1
      modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp
  10. +2
    -4
      modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp
  11. +3
    -3
      modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp
  12. +4
    -4
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp
  13. +7
    -7
      modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp
  14. +3
    -3
      modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp
  15. +1
    -1
      modules/juce_gui_basics/widgets/juce_ListBox.cpp
  16. +2
    -2
      modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp
  17. +0
    -1
      modules/juce_gui_basics/widgets/juce_TreeView.h
  18. +3
    -3
      modules/juce_gui_basics/windows/juce_ComponentPeer.cpp
  19. +2
    -2
      modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp

+ 0
- 5
extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp View File

@@ -47,12 +47,7 @@ void DocumentEditorComponent::documentAboutToClose (OpenDocumentManager::Documen
jassert (document != nullptr);
if (ProjectContentComponent* pcc = findParentComponentOfClass<ProjectContentComponent>())
{
pcc->hideDocument (document);
return;
}
jassertfalse
}
}


+ 6
- 8
extras/Introjucer/Source/Project/jucer_GroupInformationComponent.h View File

@@ -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();
}
//==============================================================================


+ 44
- 0
extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp View File

@@ -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)
{


+ 4
- 0
extras/Introjucer/Source/Utility/jucer_CodeHelpers.h View File

@@ -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,


+ 1
- 1
extras/Introjucer/Source/Utility/jucer_MiscUtilities.h View File

@@ -267,7 +267,7 @@ public:
}
else
{
selector.setBounds (0, 0, getWidth(), getHeight());
selector.setBounds (getLocalBounds());
}
}


+ 3
- 3
modules/juce_gui_basics/drawables/juce_DrawablePath.cpp View File

@@ -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)
{
}


+ 5
- 5
modules/juce_gui_basics/drawables/juce_DrawableShape.cpp View File

@@ -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)
{
}


+ 4
- 4
modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp View File

@@ -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);


+ 1
- 1
modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp View File

@@ -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);
}
}


+ 2
- 4
modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp View File

@@ -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);


+ 3
- 3
modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp View File

@@ -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..


+ 4
- 4
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp View File

@@ -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)
{
}


+ 7
- 7
modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp View File

@@ -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)
{
}


+ 3
- 3
modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp View File

@@ -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)
{
}


+ 1
- 1
modules/juce_gui_basics/widgets/juce_ListBox.cpp View File

@@ -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);
}
}


+ 2
- 2
modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp View File

@@ -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));
}
}
}


+ 0
- 1
modules/juce_gui_basics/widgets/juce_TreeView.h View File

@@ -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();


+ 3
- 3
modules/juce_gui_basics/windows/juce_ComponentPeer.cpp View File

@@ -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


+ 2
- 2
modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp View File

@@ -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…
Cancel
Save