mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Minor clean-ups and documentation fixes.
This commit is contained in:
parent
68b2e056e7
commit
5d35a31f2e
7 changed files with 155 additions and 155 deletions
|
|
@ -454,8 +454,10 @@ bool operator!= (const var& v1, const char* const v2) { return v1.toString
|
|||
//==============================================================================
|
||||
var var::operator[] (const Identifier& propertyName) const
|
||||
{
|
||||
DynamicObject* const o = getDynamicObject();
|
||||
return o != nullptr ? o->getProperty (propertyName) : var::null;
|
||||
if (DynamicObject* const o = getDynamicObject())
|
||||
return o->getProperty (propertyName);
|
||||
|
||||
return var::null;
|
||||
}
|
||||
|
||||
var var::operator[] (const char* const propertyName) const
|
||||
|
|
@ -465,14 +467,18 @@ var var::operator[] (const char* const propertyName) const
|
|||
|
||||
var var::getProperty (const Identifier& propertyName, const var& defaultReturnValue) const
|
||||
{
|
||||
DynamicObject* const o = getDynamicObject();
|
||||
return o != nullptr ? o->getProperties().getWithDefault (propertyName, defaultReturnValue) : defaultReturnValue;
|
||||
if (DynamicObject* const o = getDynamicObject())
|
||||
return o->getProperties().getWithDefault (propertyName, defaultReturnValue);
|
||||
|
||||
return defaultReturnValue;
|
||||
}
|
||||
|
||||
var var::invoke (const Identifier& method, const var* arguments, int numArguments) const
|
||||
{
|
||||
DynamicObject* const o = getDynamicObject();
|
||||
return o != nullptr ? o->invokeMethod (method, arguments, numArguments) : var::null;
|
||||
if (DynamicObject* const o = getDynamicObject())
|
||||
return o->invokeMethod (method, arguments, numArguments);
|
||||
|
||||
return var::null;
|
||||
}
|
||||
|
||||
var var::invokeMethod (DynamicObject* const target, const var* const arguments, const int numArguments) const
|
||||
|
|
@ -522,8 +528,10 @@ var var::call (const Identifier& method, const var& arg1, const var& arg2, const
|
|||
//==============================================================================
|
||||
int var::size() const
|
||||
{
|
||||
const Array<var>* const array = getArray();
|
||||
return array != nullptr ? array->size() : 0;
|
||||
if (const Array<var>* const array = getArray())
|
||||
return array->size();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const var& var::operator[] (int arrayIndex) const
|
||||
|
|
@ -574,9 +582,7 @@ void var::append (const var& n)
|
|||
|
||||
void var::remove (const int index)
|
||||
{
|
||||
Array<var>* const array = getArray();
|
||||
|
||||
if (array != nullptr)
|
||||
if (Array<var>* const array = getArray())
|
||||
array->remove (index);
|
||||
}
|
||||
|
||||
|
|
@ -592,8 +598,10 @@ void var::resize (const int numArrayElementsWanted)
|
|||
|
||||
int var::indexOf (const var& n) const
|
||||
{
|
||||
const Array<var>* const array = getArray();
|
||||
return array != nullptr ? array->indexOf (n) : -1;
|
||||
if (const Array<var>* const array = getArray())
|
||||
return array->indexOf (n);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -482,13 +482,10 @@ public:
|
|||
{
|
||||
if (! (isAddingNewProperty || isDeletingProperty))
|
||||
{
|
||||
SetPropertyAction* const next = dynamic_cast <SetPropertyAction*> (nextAction);
|
||||
|
||||
if (next != nullptr && next->target == target && next->name == name
|
||||
&& ! (next->isAddingNewProperty || next->isDeletingProperty))
|
||||
{
|
||||
return new SetPropertyAction (target, name, next->newValue, oldValue, false, false);
|
||||
}
|
||||
if (SetPropertyAction* const next = dynamic_cast <SetPropertyAction*> (nextAction))
|
||||
if (next->target == target && next->name == name
|
||||
&& ! (next->isAddingNewProperty || next->isDeletingProperty))
|
||||
return new SetPropertyAction (target, name, next->newValue, oldValue, false, false);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
|
|||
|
|
@ -521,8 +521,8 @@ namespace TextLayoutHelpers
|
|||
|
||||
if (attr.range.contains (i))
|
||||
{
|
||||
if (attr.getFont() != nullptr) newFontAndColour.font = attr.getFont();
|
||||
if (attr.getColour() != nullptr) newFontAndColour.colour = *attr.getColour();
|
||||
if (const Font* f = attr.getFont()) newFontAndColour.font = f;
|
||||
if (const Colour* c = attr.getColour()) newFontAndColour.colour = *c;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,9 +146,7 @@ private:
|
|||
|
||||
DrawableComposite* parseSwitch (const XmlElement& xml)
|
||||
{
|
||||
const XmlElement* const group = xml.getChildByName ("g");
|
||||
|
||||
if (group != nullptr)
|
||||
if (const XmlElement* const group = xml.getChildByName ("g"))
|
||||
return parseGroupElement (*group);
|
||||
|
||||
return nullptr;
|
||||
|
|
@ -572,26 +570,112 @@ private:
|
|||
|
||||
void addGradientStopsIn (ColourGradient& cg, const XmlElement* const fillXml) const
|
||||
{
|
||||
if (fillXml == 0)
|
||||
return;
|
||||
|
||||
forEachXmlChildElementWithTagName (*fillXml, e, "stop")
|
||||
if (fillXml != nullptr)
|
||||
{
|
||||
int index = 0;
|
||||
Colour col (parseColour (getStyleAttribute (e, "stop-color"), index, Colours::black));
|
||||
forEachXmlChildElementWithTagName (*fillXml, e, "stop")
|
||||
{
|
||||
int index = 0;
|
||||
Colour col (parseColour (getStyleAttribute (e, "stop-color"), index, Colours::black));
|
||||
|
||||
const String opacity (getStyleAttribute (e, "stop-opacity", "1"));
|
||||
col = col.withMultipliedAlpha (jlimit (0.0f, 1.0f, opacity.getFloatValue()));
|
||||
const String opacity (getStyleAttribute (e, "stop-opacity", "1"));
|
||||
col = col.withMultipliedAlpha (jlimit (0.0f, 1.0f, opacity.getFloatValue()));
|
||||
|
||||
double offset = e->getDoubleAttribute ("offset");
|
||||
double offset = e->getDoubleAttribute ("offset");
|
||||
|
||||
if (e->getStringAttribute ("offset").containsChar ('%'))
|
||||
offset *= 0.01;
|
||||
if (e->getStringAttribute ("offset").containsChar ('%'))
|
||||
offset *= 0.01;
|
||||
|
||||
cg.addColour (jlimit (0.0, 1.0, offset), col);
|
||||
cg.addColour (jlimit (0.0, 1.0, offset), col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FillType getGradientFillType (const XmlElement* fillXml,
|
||||
const Path& path,
|
||||
const float opacity) const
|
||||
{
|
||||
ColourGradient gradient;
|
||||
|
||||
addGradientStopsIn (gradient, findLinkedElement (fillXml));
|
||||
addGradientStopsIn (gradient, fillXml);
|
||||
|
||||
if (gradient.getNumColours() > 0)
|
||||
{
|
||||
gradient.addColour (0.0, gradient.getColour (0));
|
||||
gradient.addColour (1.0, gradient.getColour (gradient.getNumColours() - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
gradient.addColour (0.0, Colours::black);
|
||||
gradient.addColour (1.0, Colours::black);
|
||||
}
|
||||
|
||||
if (opacity < 1.0f)
|
||||
gradient.multiplyOpacity (opacity);
|
||||
|
||||
jassert (gradient.getNumColours() > 0);
|
||||
|
||||
gradient.isRadial = fillXml->hasTagName ("radialGradient");
|
||||
|
||||
float gradientWidth = viewBoxW;
|
||||
float gradientHeight = viewBoxH;
|
||||
float dx = 0.0f;
|
||||
float dy = 0.0f;
|
||||
|
||||
const bool userSpace = fillXml->getStringAttribute ("gradientUnits").equalsIgnoreCase ("userSpaceOnUse");
|
||||
|
||||
if (! userSpace)
|
||||
{
|
||||
const Rectangle<float> bounds (path.getBounds());
|
||||
dx = bounds.getX();
|
||||
dy = bounds.getY();
|
||||
gradientWidth = bounds.getWidth();
|
||||
gradientHeight = bounds.getHeight();
|
||||
}
|
||||
|
||||
if (gradient.isRadial)
|
||||
{
|
||||
if (userSpace)
|
||||
gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("cx", "50%"), gradientWidth),
|
||||
dy + getCoordLength (fillXml->getStringAttribute ("cy", "50%"), gradientHeight));
|
||||
else
|
||||
gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("cx", "50%"), 1.0f),
|
||||
dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("cy", "50%"), 1.0f));
|
||||
|
||||
const float radius = getCoordLength (fillXml->getStringAttribute ("r", "50%"), gradientWidth);
|
||||
gradient.point2 = gradient.point1 + Point<float> (radius, 0.0f);
|
||||
|
||||
//xxx (the fx, fy focal point isn't handled properly here..)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (userSpace)
|
||||
{
|
||||
gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x1", "0%"), gradientWidth),
|
||||
dy + getCoordLength (fillXml->getStringAttribute ("y1", "0%"), gradientHeight));
|
||||
|
||||
gradient.point2.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x2", "100%"), gradientWidth),
|
||||
dy + getCoordLength (fillXml->getStringAttribute ("y2", "0%"), gradientHeight));
|
||||
}
|
||||
else
|
||||
{
|
||||
gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x1", "0%"), 1.0f),
|
||||
dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y1", "0%"), 1.0f));
|
||||
|
||||
gradient.point2.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x2", "100%"), 1.0f),
|
||||
dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y2", "0%"), 1.0f));
|
||||
}
|
||||
|
||||
if (gradient.point1 == gradient.point2)
|
||||
return Colour (gradient.getColour (gradient.getNumColours() - 1));
|
||||
}
|
||||
|
||||
FillType type (gradient);
|
||||
type.transform = parseTransform (fillXml->getStringAttribute ("gradientTransform"))
|
||||
.followedBy (transform);
|
||||
return type;
|
||||
}
|
||||
|
||||
FillType getPathFillType (const Path& path,
|
||||
const String& fill,
|
||||
const String& fillOpacity,
|
||||
|
|
@ -611,103 +695,16 @@ private:
|
|||
const String id (fill.fromFirstOccurrenceOf ("#", false, false)
|
||||
.upToLastOccurrenceOf (")", false, false).trim());
|
||||
|
||||
const XmlElement* const fillXml = findElementForId (topLevelXml, id);
|
||||
|
||||
if (fillXml != nullptr
|
||||
&& (fillXml->hasTagName ("linearGradient")
|
||||
|| fillXml->hasTagName ("radialGradient")))
|
||||
{
|
||||
const XmlElement* inheritedFrom = findLinkedElement (fillXml);
|
||||
|
||||
ColourGradient gradient;
|
||||
|
||||
addGradientStopsIn (gradient, inheritedFrom);
|
||||
addGradientStopsIn (gradient, fillXml);
|
||||
|
||||
if (gradient.getNumColours() > 0)
|
||||
{
|
||||
gradient.addColour (0.0, gradient.getColour (0));
|
||||
gradient.addColour (1.0, gradient.getColour (gradient.getNumColours() - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
gradient.addColour (0.0, Colours::black);
|
||||
gradient.addColour (1.0, Colours::black);
|
||||
}
|
||||
|
||||
if (overallOpacity.isNotEmpty())
|
||||
gradient.multiplyOpacity (overallOpacity.getFloatValue());
|
||||
|
||||
jassert (gradient.getNumColours() > 0);
|
||||
|
||||
gradient.isRadial = fillXml->hasTagName ("radialGradient");
|
||||
|
||||
float gradientWidth = viewBoxW;
|
||||
float gradientHeight = viewBoxH;
|
||||
float dx = 0.0f;
|
||||
float dy = 0.0f;
|
||||
|
||||
const bool userSpace = fillXml->getStringAttribute ("gradientUnits").equalsIgnoreCase ("userSpaceOnUse");
|
||||
|
||||
if (! userSpace)
|
||||
{
|
||||
const Rectangle<float> bounds (path.getBounds());
|
||||
dx = bounds.getX();
|
||||
dy = bounds.getY();
|
||||
gradientWidth = bounds.getWidth();
|
||||
gradientHeight = bounds.getHeight();
|
||||
}
|
||||
|
||||
if (gradient.isRadial)
|
||||
{
|
||||
if (userSpace)
|
||||
gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("cx", "50%"), gradientWidth),
|
||||
dy + getCoordLength (fillXml->getStringAttribute ("cy", "50%"), gradientHeight));
|
||||
else
|
||||
gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("cx", "50%"), 1.0f),
|
||||
dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("cy", "50%"), 1.0f));
|
||||
|
||||
const float radius = getCoordLength (fillXml->getStringAttribute ("r", "50%"), gradientWidth);
|
||||
gradient.point2 = gradient.point1 + Point<float> (radius, 0.0f);
|
||||
|
||||
//xxx (the fx, fy focal point isn't handled properly here..)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (userSpace)
|
||||
{
|
||||
gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x1", "0%"), gradientWidth),
|
||||
dy + getCoordLength (fillXml->getStringAttribute ("y1", "0%"), gradientHeight));
|
||||
|
||||
gradient.point2.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x2", "100%"), gradientWidth),
|
||||
dy + getCoordLength (fillXml->getStringAttribute ("y2", "0%"), gradientHeight));
|
||||
}
|
||||
else
|
||||
{
|
||||
gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x1", "0%"), 1.0f),
|
||||
dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y1", "0%"), 1.0f));
|
||||
|
||||
gradient.point2.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x2", "100%"), 1.0f),
|
||||
dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y2", "0%"), 1.0f));
|
||||
}
|
||||
|
||||
if (gradient.point1 == gradient.point2)
|
||||
return Colour (gradient.getColour (gradient.getNumColours() - 1));
|
||||
}
|
||||
|
||||
FillType type (gradient);
|
||||
type.transform = parseTransform (fillXml->getStringAttribute ("gradientTransform"))
|
||||
.followedBy (transform);
|
||||
return type;
|
||||
}
|
||||
if (const XmlElement* const fillXml = findElementForId (topLevelXml, id))
|
||||
if (fillXml->hasTagName ("linearGradient") || fillXml->hasTagName ("radialGradient"))
|
||||
return getGradientFillType (fillXml, path, opacity);
|
||||
}
|
||||
|
||||
if (fill.equalsIgnoreCase ("none"))
|
||||
return Colours::transparentBlack;
|
||||
|
||||
int i = 0;
|
||||
const Colour colour (parseColour (fill, i, defaultColour));
|
||||
return colour.withMultipliedAlpha (opacity);
|
||||
return parseColour (fill, i, defaultColour).withMultipliedAlpha (opacity);
|
||||
}
|
||||
|
||||
PathStrokeType getStrokeFor (const XmlElement* const xml) const
|
||||
|
|
@ -1216,9 +1213,7 @@ private:
|
|||
if (e->compareAttribute ("id", id))
|
||||
return e;
|
||||
|
||||
const XmlElement* const found = findElementForId (e, id);
|
||||
|
||||
if (found != nullptr)
|
||||
if (const XmlElement* const found = findElementForId (e, id))
|
||||
return found;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,16 +153,14 @@ public:
|
|||
This sets both the position and size of the thumb - to just set the position without
|
||||
changing the size, you can use setCurrentRangeStart().
|
||||
|
||||
If this method call actually changes the scrollbar's position, it will trigger an
|
||||
asynchronous call to ScrollBar::Listener::scrollBarMoved() for all the listeners that
|
||||
are registered.
|
||||
|
||||
@param newStart the top (or left) of the thumb, in the range
|
||||
getMinimumRangeLimit() <= newStart <= getMaximumRangeLimit(). If the
|
||||
value is beyond these limits, it will be clipped.
|
||||
@param newSize the size of the thumb, such that
|
||||
getMinimumRangeLimit() <= newStart + newSize <= getMaximumRangeLimit(). If the
|
||||
size is beyond these limits, it will be clipped.
|
||||
@param notification specifies if and how a callback should be made to any listeners
|
||||
if the range actually changes
|
||||
@see setCurrentRangeStart, getCurrentRangeStart, getCurrentRangeSize
|
||||
*/
|
||||
void setCurrentRange (double newStart, double newSize,
|
||||
|
|
|
|||
|
|
@ -132,8 +132,9 @@ public:
|
|||
|
||||
const int columnId = owner.getHeader().getColumnIdAtX (e.x);
|
||||
|
||||
if (columnId != 0 && owner.getModel() != nullptr)
|
||||
owner.getModel()->cellClicked (row, columnId, e);
|
||||
if (columnId != 0)
|
||||
if (TableListBoxModel* model = owner.getModel())
|
||||
model->cellClicked (row, columnId, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -169,8 +170,9 @@ public:
|
|||
|
||||
const int columnId = owner.getHeader().getColumnIdAtX (e.x);
|
||||
|
||||
if (columnId != 0 && owner.getModel() != nullptr)
|
||||
owner.getModel()->cellClicked (row, columnId, e);
|
||||
if (columnId != 0)
|
||||
if (TableListBoxModel* model = owner.getModel())
|
||||
model->cellClicked (row, columnId, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,16 +180,18 @@ public:
|
|||
{
|
||||
const int columnId = owner.getHeader().getColumnIdAtX (e.x);
|
||||
|
||||
if (columnId != 0 && owner.getModel() != nullptr)
|
||||
owner.getModel()->cellDoubleClicked (row, columnId, e);
|
||||
if (columnId != 0)
|
||||
if (TableListBoxModel* model = owner.getModel())
|
||||
model->cellDoubleClicked (row, columnId, e);
|
||||
}
|
||||
|
||||
String getTooltip()
|
||||
{
|
||||
const int columnId = owner.getHeader().getColumnIdAtX (getMouseXYRelative().getX());
|
||||
|
||||
if (columnId != 0 && owner.getModel() != nullptr)
|
||||
return owner.getModel()->getCellTooltip (row, columnId);
|
||||
if (columnId != 0)
|
||||
if (TableListBoxModel* model = owner.getModel())
|
||||
return model->getCellTooltip (row, columnId);
|
||||
|
||||
return String::empty;
|
||||
}
|
||||
|
|
@ -334,15 +338,15 @@ Rectangle<int> TableListBox::getCellPosition (const int columnId, const int rowN
|
|||
|
||||
Component* TableListBox::getCellComponent (int columnId, int rowNumber) const
|
||||
{
|
||||
RowComp* const rowComp = dynamic_cast <RowComp*> (getComponentForRowNumber (rowNumber));
|
||||
return rowComp != nullptr ? rowComp->findChildComponentForColumn (columnId) : 0;
|
||||
if (RowComp* const rowComp = dynamic_cast <RowComp*> (getComponentForRowNumber (rowNumber)))
|
||||
return rowComp->findChildComponentForColumn (columnId);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TableListBox::scrollToEnsureColumnIsOnscreen (const int columnId)
|
||||
{
|
||||
ScrollBar* const scrollbar = getHorizontalScrollBar();
|
||||
|
||||
if (scrollbar != nullptr)
|
||||
if (ScrollBar* const scrollbar = getHorizontalScrollBar())
|
||||
{
|
||||
const Rectangle<int> pos (header->getColumnPosition (header->getIndexOfColumnId (columnId, true)));
|
||||
|
||||
|
|
@ -447,12 +451,8 @@ void TableListBox::updateColumnComponents() const
|
|||
const int firstRow = getRowContainingPosition (0, 0);
|
||||
|
||||
for (int i = firstRow + getNumRowsOnScreen() + 2; --i >= firstRow;)
|
||||
{
|
||||
RowComp* const rowComp = dynamic_cast <RowComp*> (getComponentForRowNumber (i));
|
||||
|
||||
if (rowComp != nullptr)
|
||||
if (RowComp* const rowComp = dynamic_cast <RowComp*> (getComponentForRowNumber (i)))
|
||||
rowComp->resized();
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -363,9 +363,11 @@ private:
|
|||
|
||||
static bool isMouseDraggingInChildCompOf (Component* const comp)
|
||||
{
|
||||
for (int i = Desktop::getInstance().getNumMouseSources(); --i >= 0;)
|
||||
Desktop& desktop = Desktop::getInstance();
|
||||
|
||||
for (int i = desktop.getNumMouseSources(); --i >= 0;)
|
||||
{
|
||||
MouseInputSource* const source = Desktop::getInstance().getMouseSource(i);
|
||||
MouseInputSource* const source = desktop.getMouseSource(i);
|
||||
|
||||
if (source->isDragging())
|
||||
if (Component* const underMouse = source->getComponentUnderMouse())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue