- use expectations

- improved gibbs sampling
- LayerArray is template class

git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@18 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-10-06 17:08:50 +00:00
parent f62f1283f8
commit fc758b853a
122 changed files with 1053 additions and 1149 deletions
@@ -53,24 +53,24 @@
MyJUCEApp() {}
~MyJUCEApp() {}
void initialise (const String& commandLine) override
void initialise (const String& commandLine)
{
myMainWindow = new MyApplicationWindow();
myMainWindow->setBounds (100, 100, 400, 500);
myMainWindow->setVisible (true);
}
void shutdown() override
void shutdown()
{
myMainWindow = nullptr;
}
const String getApplicationName() override
const String getApplicationName()
{
return "Super JUCE-o-matic";
}
const String getApplicationVersion() override
const String getApplicationVersion()
{
return "1.0";
}
@@ -252,7 +252,7 @@ bool KeyPressMappingSet::restoreFromXml (const XmlElement& xmlVersion)
XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefaultSet) const
{
ScopedPointer<KeyPressMappingSet> defaultSet;
ScopedPointer <KeyPressMappingSet> defaultSet;
if (saveDifferencesFromDefaultSet)
{
@@ -141,7 +141,7 @@ public:
}
private:
Array<MouseListener*> listeners;
Array <MouseListener*> listeners;
int numDeepMouseListeners;
class BailOutChecker2
@@ -256,7 +256,7 @@ struct Component::ComponentHelpers
#if JUCE_MODAL_LOOPS_PERMITTED
static void* runModalLoopCallback (void* userData)
{
return (void*) (pointer_sized_int) static_cast<Component*> (userData)->runModalLoop();
return (void*) (pointer_sized_int) static_cast <Component*> (userData)->runModalLoop();
}
#endif
@@ -399,6 +399,16 @@ struct Component::ComponentHelpers
return convertFromDistantParentSpace (topLevelComp, *target, p);
}
static Rectangle<int> getUnclippedArea (const Component& comp)
{
Rectangle<int> r (comp.getLocalBounds());
if (Component* const p = comp.getParentComponent())
r = r.getIntersection (convertFromParentSpace (comp, getUnclippedArea (*p)));
return r;
}
static bool clipObscuredRegions (const Component& comp, Graphics& g, const Rectangle<int>& clipRect, Point<int> delta)
{
bool nothingChanged = true;
@@ -431,6 +441,35 @@ struct Component::ComponentHelpers
return nothingChanged;
}
static void subtractObscuredRegions (const Component& comp, RectangleList<int>& result,
Point<int> delta, const Rectangle<int>& clipRect,
const Component* const compToAvoid)
{
for (int i = comp.childComponentList.size(); --i >= 0;)
{
const Component* const c = comp.childComponentList.getUnchecked(i);
if (c != compToAvoid && c->isVisible())
{
if (c->isOpaque() && c->componentTransparency == 0)
{
Rectangle<int> childBounds (c->bounds.getIntersection (clipRect));
childBounds.translate (delta.x, delta.y);
result.subtract (childBounds);
}
else
{
Rectangle<int> newClip (clipRect.getIntersection (c->bounds));
newClip.translate (-c->getX(), -c->getY());
subtractObscuredRegions (*c, result, c->getPosition() + delta,
newClip, compToAvoid);
}
}
}
}
static Rectangle<int> getParentOrMainMonitorBounds (const Component& comp)
{
if (Component* p = comp.getParentComponent())
@@ -441,7 +480,7 @@ struct Component::ComponentHelpers
};
//==============================================================================
Component::Component() noexcept
Component::Component()
: parentComponent (nullptr),
lookAndFeel (nullptr),
effect (nullptr),
@@ -450,7 +489,7 @@ Component::Component() noexcept
{
}
Component::Component (const String& name) noexcept
Component::Component (const String& name)
: componentName (name),
parentComponent (nullptr),
lookAndFeel (nullptr),
@@ -581,6 +620,7 @@ bool Component::isShowing() const
return false;
}
//==============================================================================
void* Component::getWindowHandle() const
{
@@ -840,7 +880,7 @@ void Component::setBufferedToImage (const bool shouldBeBuffered)
// so by calling setBufferedToImage, you'll be deleting the custom one - this is almost certainly
// not what you wanted to happen... If you really do know what you're doing here, and want to
// avoid this assertion, just call setCachedComponentImage (nullptr) before setBufferedToImage().
jassert (cachedImage == nullptr || dynamic_cast<StandardCachedComponentImage*> (cachedImage.get()) != nullptr);
jassert (cachedImage == nullptr || dynamic_cast <StandardCachedComponentImage*> (cachedImage.get()) != nullptr);
if (shouldBeBuffered)
{
@@ -1603,7 +1643,7 @@ Component* Component::getChildComponent (const int index) const noexcept
int Component::getIndexOfChildComponent (const Component* const child) const noexcept
{
return childComponentList.indexOf (const_cast<Component*> (child));
return childComponentList.indexOf (const_cast <Component*> (child));
}
Component* Component::findChildWithID (StringRef targetID) const noexcept
@@ -1625,7 +1665,7 @@ Component* Component::getTopLevelComponent() const noexcept
while (comp->parentComponent != nullptr)
comp = comp->parentComponent;
return const_cast<Component*> (comp);
return const_cast <Component*> (comp);
}
bool Component::isParentOf (const Component* possibleChild) const noexcept
@@ -2165,7 +2205,7 @@ void Component::sendLookAndFeelChange()
Colour Component::findColour (const int colourId, const bool inheritFromParent) const
{
if (const var* const v = properties.getVarPointer (ComponentHelpers::getColourPropertyId (colourId)))
return Colour ((uint32) static_cast<int> (*v));
return Colour ((uint32) static_cast <int> (*v));
if (inheritFromParent && parentComponent != nullptr
&& (lookAndFeel == nullptr || ! lookAndFeel->isColourSpecified (colourId)))
@@ -2244,6 +2284,28 @@ Rectangle<int> Component::getBoundsInParent() const noexcept
: bounds.transformedBy (*affineTransform);
}
void Component::getVisibleArea (RectangleList<int>& result, const bool includeSiblings) const
{
result.clear();
const Rectangle<int> unclipped (ComponentHelpers::getUnclippedArea (*this));
if (! unclipped.isEmpty())
{
result.add (unclipped);
if (includeSiblings)
{
const Component* const c = getTopLevelComponent();
ComponentHelpers::subtractObscuredRegions (*c, result, getLocalPoint (c, Point<int>()),
c->getLocalBounds(), this);
}
ComponentHelpers::subtractObscuredRegions (*this, result, Point<int>(), unclipped, nullptr);
result.consolidate();
}
}
//==============================================================================
void Component::mouseEnter (const MouseEvent&) {}
void Component::mouseExit (const MouseEvent&) {}
@@ -2794,7 +2856,7 @@ void Component::grabFocusInternal (const FocusChangeType cause, const bool canTr
else
{
// find the default child component..
ScopedPointer<KeyboardFocusTraverser> traverser (createFocusTraverser());
ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser());
if (traverser != nullptr)
{
@@ -2836,7 +2898,7 @@ void Component::moveKeyboardFocusToSibling (const bool moveToNext)
if (parentComponent != nullptr)
{
ScopedPointer<KeyboardFocusTraverser> traverser (createFocusTraverser());
ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser());
if (traverser != nullptr)
{
@@ -2990,7 +3052,7 @@ Point<int> Component::getMouseXYRelative() const
void Component::addKeyListener (KeyListener* const newListener)
{
if (keyListeners == nullptr)
keyListeners = new Array<KeyListener*>();
keyListeners = new Array <KeyListener*>();
keyListeners->addIfNotAlreadyThere (newListener);
}
@@ -46,7 +46,7 @@ public:
subclass of Component or use one of the other types of component from
the library.
*/
Component() noexcept;
Component();
/** Destructor.
@@ -66,7 +66,7 @@ public:
/** Creates a component, setting its name at the same time.
@see getName, setName
*/
explicit Component (const String& componentName) noexcept;
explicit Component (const String& componentName);
/** Returns the name of this component.
@see setName
@@ -315,6 +315,16 @@ public:
*/
Rectangle<int> getBoundsInParent() const noexcept;
/** Returns the region of this component that's not obscured by other, opaque components.
The RectangleList that is returned represents the area of this component
which isn't covered by opaque child components.
If includeSiblings is true, it will also take into account any siblings
that may be overlapping the component.
*/
void getVisibleArea (RectangleList<int>& result, bool includeSiblings) const;
//==============================================================================
/** Returns this component's x coordinate relative the screen's top-left origin.
@see getX, localPointToGlobal
@@ -797,7 +807,7 @@ public:
TargetClass* findParentComponentOfClass() const
{
for (Component* p = parentComponent; p != nullptr; p = p->parentComponent)
if (TargetClass* const target = dynamic_cast<TargetClass*> (p))
if (TargetClass* const target = dynamic_cast <TargetClass*> (p))
return target;
return nullptr;
@@ -1156,7 +1166,7 @@ public:
By default, components are considered transparent, unless this is used to
make it otherwise.
@see isOpaque
@see isOpaque, getVisibleArea
*/
void setOpaque (bool shouldBeOpaque);
@@ -1747,14 +1757,11 @@ public:
*/
virtual void focusLost (FocusChangeType cause);
/** Called to indicate a change in whether or not this component is the parent of the
currently-focused component.
/** Called to indicate that one of this component's children has been focused or unfocused.
Essentially this is called when the return value of a call to hasKeyboardFocus (true) has
Essentially this means that the return value of a call to hasKeyboardFocus (true) has
changed. It happens when focus moves from one of this component's children (at any depth)
to a component that isn't contained in this one, (or vice-versa).
Note that this method does NOT get called to when focus simply moves from one of its
child components to another.
@see focusGained, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus
*/
@@ -1789,7 +1796,9 @@ public:
bool isMouseButtonDown() const;
/** True if the mouse is over this component, or if it's being dragged in this component.
This is a handy equivalent to (isMouseOver() || isMouseButtonDown()).
@see isMouseOver, isMouseButtonDown, isMouseButtonDownAnywhere
*/
bool isMouseOverOrDragging() const;
@@ -2127,31 +2136,31 @@ public:
SafePointer() noexcept {}
/** Creates a SafePointer that points at the given component. */
SafePointer (ComponentType* component) : weakRef (component) {}
SafePointer (ComponentType* const component) : weakRef (component) {}
/** Creates a copy of another SafePointer. */
SafePointer (const SafePointer& other) noexcept : weakRef (other.weakRef) {}
SafePointer (const SafePointer& other) noexcept : weakRef (other.weakRef) {}
/** Copies another pointer to this one. */
SafePointer& operator= (const SafePointer& other) { weakRef = other.weakRef; return *this; }
SafePointer& operator= (const SafePointer& other) { weakRef = other.weakRef; return *this; }
/** Copies another pointer to this one. */
SafePointer& operator= (ComponentType* newComponent) { weakRef = newComponent; return *this; }
SafePointer& operator= (ComponentType* const newComponent) { weakRef = newComponent; return *this; }
/** Returns the component that this pointer refers to, or null if the component no longer exists. */
ComponentType* getComponent() const noexcept { return dynamic_cast<ComponentType*> (weakRef.get()); }
ComponentType* getComponent() const noexcept { return dynamic_cast <ComponentType*> (weakRef.get()); }
/** Returns the component that this pointer refers to, or null if the component no longer exists. */
operator ComponentType*() const noexcept { return getComponent(); }
operator ComponentType*() const noexcept { return getComponent(); }
/** Returns the component that this pointer refers to, or null if the component no longer exists. */
ComponentType* operator->() noexcept { return getComponent(); }
ComponentType* operator->() noexcept { return getComponent(); }
/** Returns the component that this pointer refers to, or null if the component no longer exists. */
const ComponentType* operator->() const noexcept { return getComponent(); }
const ComponentType* operator->() const noexcept { return getComponent(); }
/** If the component is valid, this deletes it and sets this pointer to null. */
void deleteAndZero() { delete getComponent(); }
void deleteAndZero() { delete getComponent(); }
bool operator== (ComponentType* component) const noexcept { return weakRef == component; }
bool operator!= (ComponentType* component) const noexcept { return weakRef != component; }
@@ -2259,20 +2268,20 @@ private:
String componentName, componentID;
Component* parentComponent;
Rectangle<int> bounds;
ScopedPointer<Positioner> positioner;
ScopedPointer<AffineTransform> affineTransform;
Array<Component*> childComponentList;
ScopedPointer <Positioner> positioner;
ScopedPointer <AffineTransform> affineTransform;
Array <Component*> childComponentList;
LookAndFeel* lookAndFeel;
MouseCursor cursor;
ImageEffectFilter* effect;
ScopedPointer<CachedComponentImage> cachedImage;
ScopedPointer <CachedComponentImage> cachedImage;
class MouseListenerList;
friend class MouseListenerList;
friend struct ContainerDeletePolicy<MouseListenerList>;
ScopedPointer<MouseListenerList> mouseListeners;
ScopedPointer<Array<KeyListener*> > keyListeners;
ListenerList<ComponentListener> componentListeners;
ScopedPointer <MouseListenerList> mouseListeners;
ScopedPointer <Array <KeyListener*> > keyListeners;
ListenerList <ComponentListener> componentListeners;
NamedValueSet properties;
friend class WeakReference<Component>;
@@ -2299,9 +2308,9 @@ private:
bool mouseDownWasBlocked : 1;
bool isMoveCallbackPending : 1;
bool isResizeCallbackPending : 1;
#if JUCE_DEBUG
#if JUCE_DEBUG
bool isInsidePaintCall : 1;
#endif
#endif
};
union
@@ -85,13 +85,31 @@ public:
newState.viewBoxW = vwh.x;
newState.viewBoxH = vwh.y;
const int placementFlags = parsePlacementFlags (xml->getStringAttribute ("preserveAspectRatio").trim());
int placementFlags = 0;
if (placementFlags != 0)
newState.transform = RectanglePlacement (placementFlags)
.getTransformToFit (Rectangle<float> (viewboxXY.x, viewboxXY.y, vwh.x, vwh.y),
Rectangle<float> (newState.width, newState.height))
.followedBy (newState.transform);
const String aspect (xml->getStringAttribute ("preserveAspectRatio"));
if (aspect.containsIgnoreCase ("none"))
{
placementFlags = RectanglePlacement::stretchToFit;
}
else
{
if (aspect.containsIgnoreCase ("slice")) placementFlags |= RectanglePlacement::fillDestination;
if (aspect.containsIgnoreCase ("xMin")) placementFlags |= RectanglePlacement::xLeft;
else if (aspect.containsIgnoreCase ("xMax")) placementFlags |= RectanglePlacement::xRight;
else placementFlags |= RectanglePlacement::xMid;
if (aspect.containsIgnoreCase ("yMin")) placementFlags |= RectanglePlacement::yTop;
else if (aspect.containsIgnoreCase ("yMax")) placementFlags |= RectanglePlacement::yBottom;
else placementFlags |= RectanglePlacement::yMid;
}
newState.transform = RectanglePlacement (placementFlags)
.getTransformToFit (Rectangle<float> (viewboxXY.x, viewboxXY.y, vwh.x, vwh.y),
Rectangle<float> (newState.width, newState.height))
.followedBy (newState.transform);
}
}
else
@@ -542,12 +560,24 @@ private:
path.applyTransform (transform);
dp->setPath (path);
Path::Iterator iter (path);
bool containsClosedSubPath = false;
while (iter.next())
{
if (iter.elementType == Path::Iterator::closePath)
{
containsClosedSubPath = true;
break;
}
}
dp->setFill (getPathFillType (path,
getStyleAttribute (xml, "fill"),
getStyleAttribute (xml, "fill-opacity"),
getStyleAttribute (xml, "opacity"),
pathContainsClosedSubPath (path) ? Colours::black
: Colours::transparentBlack));
containsClosedSubPath ? Colours::black
: Colours::transparentBlack));
const String strokeType (getStyleAttribute (xml, "stroke"));
@@ -564,15 +594,6 @@ private:
return dp;
}
static bool pathContainsClosedSubPath (const Path& path) noexcept
{
for (Path::Iterator iter (path); iter.next();)
if (iter.elementType == Path::Iterator::closePath)
return true;
return false;
}
struct SetGradientStopsOp
{
const SVGState* state;
@@ -775,41 +796,44 @@ private:
return parseColour (fill, i, defaultColour).withMultipliedAlpha (opacity);
}
static PathStrokeType::JointStyle getJointStyle (const String& join) noexcept
{
if (join.equalsIgnoreCase ("round")) return PathStrokeType::curved;
if (join.equalsIgnoreCase ("bevel")) return PathStrokeType::beveled;
return PathStrokeType::mitered;
}
static PathStrokeType::EndCapStyle getEndCapStyle (const String& cap) noexcept
{
if (cap.equalsIgnoreCase ("round")) return PathStrokeType::rounded;
if (cap.equalsIgnoreCase ("square")) return PathStrokeType::square;
return PathStrokeType::butt;
}
float getStrokeWidth (const String& strokeWidth) const noexcept
{
return transform.getScaleFactor() * getCoordLength (strokeWidth, viewBoxW);
}
PathStrokeType getStrokeFor (const XmlPath& xml) const
{
return PathStrokeType (getStrokeWidth (getStyleAttribute (xml, "stroke-width", "1")),
getJointStyle (getStyleAttribute (xml, "stroke-linejoin")),
getEndCapStyle (getStyleAttribute (xml, "stroke-linecap")));
const String strokeWidth (getStyleAttribute (xml, "stroke-width"));
const String cap (getStyleAttribute (xml, "stroke-linecap"));
const String join (getStyleAttribute (xml, "stroke-linejoin"));
//const String mitreLimit (getStyleAttribute (xml, "stroke-miterlimit"));
//const String dashArray (getStyleAttribute (xml, "stroke-dasharray"));
//const String dashOffset (getStyleAttribute (xml, "stroke-dashoffset"));
PathStrokeType::JointStyle joinStyle = PathStrokeType::mitered;
PathStrokeType::EndCapStyle capStyle = PathStrokeType::butt;
if (join.equalsIgnoreCase ("round"))
joinStyle = PathStrokeType::curved;
else if (join.equalsIgnoreCase ("bevel"))
joinStyle = PathStrokeType::beveled;
if (cap.equalsIgnoreCase ("round"))
capStyle = PathStrokeType::rounded;
else if (cap.equalsIgnoreCase ("square"))
capStyle = PathStrokeType::square;
float ox = 0.0f, oy = 0.0f;
float x = getCoordLength (strokeWidth, viewBoxW), y = 0.0f;
transform.transformPoints (ox, oy, x, y);
return PathStrokeType (strokeWidth.isNotEmpty() ? juce_hypot (x - ox, y - oy) : 1.0f,
joinStyle, capStyle);
}
//==============================================================================
Drawable* parseText (const XmlPath& xml)
{
Array<float> xCoords, yCoords, dxCoords, dyCoords;
Array <float> xCoords, yCoords, dxCoords, dyCoords;
getCoordList (xCoords, getInheritedAttribute (xml, "x"), true, true);
getCoordList (yCoords, getInheritedAttribute (xml, "y"), true, false);
getCoordList (xCoords, getInheritedAttribute (xml, "x"), true, true);
getCoordList (yCoords, getInheritedAttribute (xml, "y"), true, false);
getCoordList (dxCoords, getInheritedAttribute (xml, "dx"), true, true);
getCoordList (dyCoords, getInheritedAttribute (xml, "dy"), true, false);
@@ -874,7 +898,7 @@ private:
return false;
}
float getCoordLength (const String& s, const float sizeForProportions) const noexcept
float getCoordLength (const String& s, const float sizeForProportions) const
{
float n = s.getFloatValue();
const int len = s.length();
@@ -896,12 +920,13 @@ private:
return n;
}
float getCoordLength (const XmlPath& xml, const char* attName, const float sizeForProportions) const noexcept
float getCoordLength (const XmlPath& xml, const char* attName, const float sizeForProportions) const
{
return getCoordLength (xml->getStringAttribute (attName), sizeForProportions);
}
void getCoordList (Array<float>& coords, const String& list, bool allowUnits, const bool isX) const
void getCoordList (Array <float>& coords, const String& list,
const bool allowUnits, const bool isX) const
{
String::CharPointerType text (list.getCharPointer());
float value;
@@ -935,7 +960,7 @@ private:
return source;
}
String getStyleAttribute (const XmlPath& xml, StringRef attributeName,
String getStyleAttribute (const XmlPath& xml, const String& attributeName,
const String& defaultValue = String()) const
{
if (xml->hasAttribute (attributeName))
@@ -975,7 +1000,7 @@ private:
return defaultValue;
}
String getInheritedAttribute (const XmlPath& xml, StringRef attributeName) const
String getInheritedAttribute (const XmlPath& xml, const String& attributeName) const
{
if (xml->hasAttribute (attributeName))
return xml->getStringAttribute (attributeName);
@@ -986,30 +1011,13 @@ private:
return String();
}
static int parsePlacementFlags (const String& align) noexcept
{
if (align.isEmpty())
return 0;
if (align.containsIgnoreCase ("none"))
return RectanglePlacement::stretchToFit;
return (align.containsIgnoreCase ("slice") ? RectanglePlacement::fillDestination : 0)
| (align.containsIgnoreCase ("xMin") ? RectanglePlacement::xLeft
: (align.containsIgnoreCase ("xMax") ? RectanglePlacement::xRight
: RectanglePlacement::xMid))
| (align.containsIgnoreCase ("yMin") ? RectanglePlacement::yTop
: (align.containsIgnoreCase ("yMax") ? RectanglePlacement::yBottom
: RectanglePlacement::yMid));
}
//==============================================================================
static bool isIdentifierChar (const juce_wchar c)
{
return CharacterFunctions::isLetter (c) || c == '-';
}
static String getAttributeFromStyleList (const String& list, StringRef attributeName, const String& defaultValue)
static String getAttributeFromStyleList (const String& list, const String& attributeName, const String& defaultValue)
{
int i = 0;
@@ -1213,7 +1221,7 @@ private:
const bool largeArc, const bool sweep,
double& rx, double& ry,
double& centreX, double& centreY,
double& startAngle, double& deltaAngle) noexcept
double& startAngle, double& deltaAngle)
{
const double midX = (x1 - x2) * 0.5;
const double midY = (y1 - y2) * 0.5;
@@ -49,7 +49,7 @@
#import <WebKit/WebKit.h>
#import <IOKit/pwr_mgt/IOPMLib.h>
#if JUCE_SUPPORT_CARBON && ! (defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6)
#if JUCE_SUPPORT_CARBON
#define Point CarbonDummyPointName
#define Component CarbonDummyCompName
#import <Carbon/Carbon.h> // still needed for SetSystemUIMode()
@@ -25,7 +25,8 @@
class ComponentAnimator::AnimationTask
{
public:
AnimationTask (Component* const comp) noexcept : component (comp)
AnimationTask (Component* const comp)
: component (comp)
{
}
@@ -33,7 +34,7 @@ public:
float finalAlpha,
int millisecondsToSpendMoving,
bool useProxyComponent,
double startSpd, double endSpd)
double startSpeed_, double endSpeed_)
{
msElapsed = 0;
msTotal = jmax (1, millisecondsToSpendMoving);
@@ -50,10 +51,10 @@ public:
bottom = component->getBottom();
alpha = component->getAlpha();
const double invTotalDistance = 4.0 / (startSpd + endSpd + 2.0);
startSpeed = jmax (0.0, startSpd * invTotalDistance);
const double invTotalDistance = 4.0 / (startSpeed_ + endSpeed_ + 2.0);
startSpeed = jmax (0.0, startSpeed_ * invTotalDistance);
midSpeed = invTotalDistance;
endSpeed = jmax (0.0, endSpd * invTotalDistance);
endSpeed = jmax (0.0, endSpeed_ * invTotalDistance);
if (useProxyComponent)
proxy = new ProxyComponent (*component);
@@ -148,10 +148,10 @@ public:
private:
//==============================================================================
class AnimationTask;
OwnedArray<AnimationTask> tasks;
OwnedArray <AnimationTask> tasks;
uint32 lastTime;
AnimationTask* findTaskFor (Component*) const noexcept;
AnimationTask* findTaskFor (Component* component) const noexcept;
void timerCallback();
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentAnimator)
@@ -238,7 +238,7 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree
const int numExistingChildComps = parent.getNumChildComponents();
Array<Component*> componentsInOrder;
Array <Component*> componentsInOrder;
componentsInOrder.ensureStorageAllocated (numExistingChildComps);
{
@@ -226,7 +226,7 @@ public:
private:
//=============================================================================
OwnedArray<TypeHandler> types;
OwnedArray <TypeHandler> types;
ScopedPointer<Component> component;
ImageProvider* imageProvider;
#if JUCE_DEBUG
@@ -1001,16 +1001,6 @@ void LookAndFeel_V2::drawPopupMenuItem (Graphics& g, const Rectangle<int>& area,
}
}
void LookAndFeel_V2::drawPopupMenuSectionHeader (Graphics& g, const Rectangle<int>& area, const String& sectionName)
{
g.setFont (getPopupMenuFont().boldened());
g.setColour (findColour (PopupMenu::headerTextColourId));
g.drawFittedText (sectionName,
area.getX() + 12, area.getY(), area.getWidth() - 16, (int) (area.getHeight() * 0.8f),
Justification::bottomLeft, 1);
}
//==============================================================================
int LookAndFeel_V2::getMenuWindowFlags()
{
@@ -137,9 +137,6 @@ public:
const String& text, const String& shortcutKeyText,
const Drawable* icon, const Colour* textColour) override;
void drawPopupMenuSectionHeader (Graphics&, const Rectangle<int>& area,
const String& sectionName) override;
Font getPopupMenuFont() override;
void drawPopupMenuUpDownArrow (Graphics&, int width, int height, bool isScrollUpArrow) override;
@@ -22,7 +22,7 @@
==============================================================================
*/
MenuBarComponent::MenuBarComponent (MenuBarModel* m)
MenuBarComponent::MenuBarComponent (MenuBarModel* model_)
: model (nullptr),
itemUnderMouse (-1),
currentPopupIndex (-1),
@@ -32,7 +32,7 @@ MenuBarComponent::MenuBarComponent (MenuBarModel* m)
setWantsKeyboardFocus (false);
setMouseClickGrabsKeyboardFocus (false);
setModel (m);
setModel (model_);
}
MenuBarComponent::~MenuBarComponent()
@@ -284,26 +284,22 @@ void MenuBarComponent::mouseMove (const MouseEvent& e)
bool MenuBarComponent::keyPressed (const KeyPress& key)
{
bool used = false;
const int numMenus = menuNames.size();
const int currentIndex = jlimit (0, menuNames.size() - 1, currentPopupIndex);
if (numMenus > 0)
if (key.isKeyCode (KeyPress::leftKey))
{
const int currentIndex = jlimit (0, numMenus - 1, currentPopupIndex);
if (key.isKeyCode (KeyPress::leftKey))
{
showMenu ((currentIndex + numMenus - 1) % numMenus);
return true;
}
if (key.isKeyCode (KeyPress::rightKey))
{
showMenu ((currentIndex + 1) % numMenus);
return true;
}
showMenu ((currentIndex + numMenus - 1) % numMenus);
used = true;
}
else if (key.isKeyCode (KeyPress::rightKey))
{
showMenu ((currentIndex + 1) % numMenus);
used = true;
}
return false;
return used;
}
void MenuBarComponent::menuBarItemsChanged (MenuBarModel* /*menuBarModel*/)
@@ -40,9 +40,9 @@ public:
//==============================================================================
/** Creates a menu bar.
@param model the model object to use to control this bar. You can
pass nullptr into this if you like, and set the model
later using the setModel() method
@param model the model object to use to control this bar. You can
pass 0 into this if you like, and set the model later
using the setModel() method
*/
MenuBarComponent (MenuBarModel* model);
@@ -57,7 +57,8 @@ public:
*/
void setModel (MenuBarModel* newModel);
/** Returns the current menu bar model being used. */
/** Returns the current menu bar model being used.
*/
MenuBarModel* getModel() const noexcept;
//==============================================================================
@@ -80,7 +80,8 @@ public:
virtual ~Listener() {}
//==============================================================================
/** This callback is made when items are changed in the menu bar model. */
/** This callback is made when items are changed in the menu bar model.
*/
virtual void menuBarItemsChanged (MenuBarModel* menuBarModel) = 0;
/** This callback is made when an application command is invoked that
@@ -100,6 +101,7 @@ public:
void addListener (Listener* listenerToAdd) noexcept;
/** Removes a listener.
@see addListener
*/
void removeListener (Listener* listenerToRemove) noexcept;
@@ -128,7 +130,7 @@ public:
//==============================================================================
#if JUCE_MAC || DOXYGEN
/** OSX ONLY - Sets the model that is currently being shown as the main
/** MAC ONLY - Sets the model that is currently being shown as the main
menu bar at the top of the screen on the Mac.
You can pass 0 to stop the current model being displayed. Be careful
@@ -149,12 +151,12 @@ public:
const PopupMenu* extraAppleMenuItems = nullptr,
const String& recentItemsMenuName = String::empty);
/** OSX ONLY - Returns the menu model that is currently being shown as
/** MAC ONLY - Returns the menu model that is currently being shown as
the main menu bar.
*/
static MenuBarModel* getMacMainMenu();
/** OSX ONLY - Returns the menu that was last passed as the extraAppleMenuItems
/** MAC ONLY - Returns the menu that was last passed as the extraAppleMenuItems
argument to setMacMainMenu(), or nullptr if none was specified.
*/
static const PopupMenu* getMacExtraAppleItemsMenu();
@@ -162,7 +164,7 @@ public:
//==============================================================================
/** @internal */
void applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo&) override;
void applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo& info) override;
/** @internal */
void applicationCommandListChanged() override;
/** @internal */
@@ -170,7 +172,7 @@ public:
private:
ApplicationCommandManager* manager;
ListenerList<Listener> listeners;
ListenerList <Listener> listeners;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MenuBarModel)
};
@@ -1216,7 +1216,12 @@ public:
void paint (Graphics& g) override
{
getLookAndFeel().drawPopupMenuSectionHeader (g, getLocalBounds(), getName());
g.setFont (getLookAndFeel().getPopupMenuFont().boldened());
g.setColour (findColour (PopupMenu::headerTextColourId));
g.drawFittedText (getName(),
12, 0, getWidth() - 16, proportionOfHeight (0.8f),
Justification::bottomLeft, 1);
}
void getIdealSize (int& idealWidth, int& idealHeight)
@@ -562,9 +562,6 @@ public:
const Drawable* icon,
const Colour* textColour) = 0;
virtual void drawPopupMenuSectionHeader (Graphics&, const Rectangle<int>& area,
const String& sectionName) = 0;
/** Returns the size and style of font to use in popup menus. */
virtual Font getPopupMenuFont() = 0;
@@ -215,28 +215,13 @@ private:
return dynamic_cast<DragAndDropTarget*> (currentlyOverComp.get());
}
static Component* findDesktopComponentBelow (Point<int> screenPos)
{
Desktop& desktop = Desktop::getInstance();
for (int i = desktop.getNumComponents(); --i >= 0;)
{
Component* c = desktop.getComponent(i);
if (Component* hit = c->getComponentAt (c->getLocalPoint (nullptr, screenPos)))
return hit;
}
return nullptr;
}
DragAndDropTarget* findTarget (Point<int> screenPos, Point<int>& relativePos,
Component*& resultComponent) const
{
Component* hit = getParentComponent();
if (hit == nullptr)
hit = findDesktopComponentBelow (screenPos);
hit = Desktop::getInstance().findComponentAt (screenPos);
else
hit = hit->getComponentAt (hit->getLocalPoint (nullptr, screenPos));
@@ -128,7 +128,7 @@ private:
SpinLock MouseCursor::SharedCursorHandle::lock;
//==============================================================================
MouseCursor::MouseCursor() noexcept
MouseCursor::MouseCursor()
: cursorHandle (nullptr)
{
}
@@ -72,10 +72,10 @@ public:
//==============================================================================
/** Creates the standard arrow cursor. */
MouseCursor() noexcept;
MouseCursor();
/** Creates one of the standard mouse cursor */
MouseCursor (StandardCursorType);
MouseCursor (StandardCursorType type);
/** Creates a custom cursor from an image.
@@ -43,7 +43,7 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, launchApp, void, (JNIEnv* en
JUCEApplicationBase* app = JUCEApplicationBase::createInstance();
if (! app->initialiseApp())
exit (app->getApplicationReturnValue());
exit (0);
jassert (MessageManager::getInstance()->isThisTheMessageThread());
}
@@ -1087,7 +1087,9 @@ public:
{
for (int i = windowListSize; --i >= 0;)
{
if (LinuxComponentPeer* const peer = LinuxComponentPeer::getPeerFor (windowList[i]))
LinuxComponentPeer* const peer = LinuxComponentPeer::getPeerFor (windowList[i]);
if (peer != 0)
{
result = (peer == this);
break;
@@ -845,7 +845,7 @@ public:
void toBehind (ComponentPeer* other) override
{
if (HWNDComponentPeer* const otherPeer = dynamic_cast<HWNDComponentPeer*> (other))
if (HWNDComponentPeer* const otherPeer = dynamic_cast <HWNDComponentPeer*> (other))
{
setMinimised (false);
@@ -960,7 +960,7 @@ public:
static ModifierKeys modifiersAtLastCallback;
//==============================================================================
class JuceDropTarget : public ComBaseClassHelper<IDropTarget>
class JuceDropTarget : public ComBaseClassHelper <IDropTarget>
{
public:
JuceDropTarget (HWNDComponentPeer& p) : ownerInfo (new OwnerInfo (p)) {}
@@ -1099,13 +1099,13 @@ public:
if (SUCCEEDED (fileData.error))
{
const LPDROPFILES dropFiles = static_cast<const LPDROPFILES> (fileData.data);
const LPDROPFILES dropFiles = static_cast <const LPDROPFILES> (fileData.data);
const void* const names = addBytesToPointer (dropFiles, sizeof (DROPFILES));
if (dropFiles->fWide)
ownerInfo->parseFileList (static_cast<const WCHAR*> (names), fileData.dataSize);
ownerInfo->parseFileList (static_cast <const WCHAR*> (names), fileData.dataSize);
else
ownerInfo->parseFileList (static_cast<const char*> (names), fileData.dataSize);
ownerInfo->parseFileList (static_cast <const char*> (names), fileData.dataSize);
}
else
{
@@ -1300,7 +1300,7 @@ private:
//==============================================================================
static void* createWindowCallback (void* userData)
{
static_cast<HWNDComponentPeer*> (userData)->createWindow();
static_cast <HWNDComponentPeer*> (userData)->createWindow();
return nullptr;
}
@@ -1528,14 +1528,10 @@ private:
// if something in a paint handler calls, e.g. a message box, this can become reentrant and
// corrupt the image it's using to paint into, so do a check here.
static bool reentrant = false;
if (! reentrant)
if (! (reentrant || dontRepaint))
{
const ScopedValueSetter<bool> setter (reentrant, true, false);
if (dontRepaint)
component.handleCommandMessage (0); // (this triggers a repaint in the openGL context)
else
performPaint (dc, rgn, regionType, paintStruct);
performPaint (dc, rgn, regionType, paintStruct);
}
DeleteObject (rgn);
@@ -1643,7 +1639,7 @@ private:
handlePaint (*context);
}
static_cast<WindowsBitmapImage*> (offscreenImage.getPixelData())
static_cast <WindowsBitmapImage*> (offscreenImage.getPixelData())
->blitToWindow (hwnd, dc, transparent, x, y, updateLayeredWindowAlpha);
}
@@ -2261,24 +2257,6 @@ private:
}
}
void handlePowerBroadcast (WPARAM wParam)
{
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
{
switch (wParam)
{
case PBT_APMSUSPEND: app->suspended(); break;
case PBT_APMQUERYSUSPENDFAILED:
case PBT_APMRESUMECRITICAL:
case PBT_APMRESUMESUSPEND:
case PBT_APMRESUMEAUTOMATIC: app->resumed(); break;
default: break;
}
}
}
void handleLeftClickInNCArea (WPARAM wParam)
{
if (! sendInputAttemptWhenModalMessage())
@@ -2327,7 +2305,7 @@ private:
{
Desktop& desktop = Desktop::getInstance();
const_cast<Desktop::Displays&> (desktop.getDisplays()).refresh();
const_cast <Desktop::Displays&> (desktop.getDisplays()).refresh();
if (fullScreen && ! isMinimised())
{
@@ -2568,10 +2546,6 @@ private:
}
return TRUE;
case WM_POWERBROADCAST:
handlePowerBroadcast (wParam);
break;
case WM_SYNCPAINT:
return 0;
@@ -2901,7 +2875,7 @@ private:
void moveCandidateWindowToLeftAlignWithSelection (HIMC hImc, ComponentPeer& peer, TextInputTarget* target) const
{
if (Component* const targetComp = dynamic_cast<Component*> (target))
if (Component* const targetComp = dynamic_cast <Component*> (target))
{
const Rectangle<int> area (peer.getComponent().getLocalArea (targetComp, target->getCaretRectangle()));
@@ -2922,15 +2896,18 @@ private:
ModifierKeys HWNDComponentPeer::currentModifiers;
ModifierKeys HWNDComponentPeer::modifiersAtLastCallback;
ComponentPeer* Component::createNewPeer (int styleFlags, void* parentHWND)
ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo)
{
return new HWNDComponentPeer (*this, styleFlags, (HWND) parentHWND, false);
return new HWNDComponentPeer (*this, styleFlags,
(HWND) nativeWindowToAttachTo, false);
}
ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component& component, void* parentHWND)
ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component* component, void* parent)
{
return new HWNDComponentPeer (component, ComponentPeer::windowIgnoresMouseClicks,
(HWND) parentHWND, true);
jassert (component != nullptr);
return new HWNDComponentPeer (*component, ComponentPeer::windowIgnoresMouseClicks,
(HWND) parent, true);
}
@@ -3003,7 +2980,7 @@ bool JUCE_CALLTYPE Process::isForegroundProcess()
fg = GetAncestor (fg, GA_ROOT);
for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
if (HWNDComponentPeer* const wp = dynamic_cast<HWNDComponentPeer*> (ComponentPeer::getPeer (i)))
if (HWNDComponentPeer* const wp = dynamic_cast <HWNDComponentPeer*> (ComponentPeer::getPeer (i)))
if (wp->isInside (fg))
return true;
@@ -3029,7 +3006,7 @@ static BOOL CALLBACK enumAlwaysOnTopWindows (HWND hwnd, LPARAM lParam)
if (GetWindowInfo (hwnd, &info)
&& (info.dwExStyle & WS_EX_TOPMOST) != 0)
{
*reinterpret_cast<bool*> (lParam) = true;
*reinterpret_cast <bool*> (lParam) = true;
return FALSE;
}
}
@@ -3234,7 +3211,7 @@ void SystemClipboard::copyTextToClipboard (const String& text)
{
if (HGLOBAL bufH = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE | GMEM_ZEROINIT, bytesNeeded + sizeof (WCHAR)))
{
if (WCHAR* const data = static_cast<WCHAR*> (GlobalLock (bufH)))
if (WCHAR* const data = static_cast <WCHAR*> (GlobalLock (bufH)))
{
text.copyToUTF16 (data, bytesNeeded);
GlobalUnlock (bufH);
@@ -56,10 +56,6 @@ protected:
public:
/** Creates a button component.
Note that if you call this constructor then you must use the Value to interact with the
button state, and you can't override the class with your own setState or getState methods.
If you want to use getState and setState, call the other constructor instead.
@param valueToControl a Value object that this property should refer to.
@param propertyName the property name to be passed to the PropertyComponent
@param buttonText the text shown in the ToggleButton component
@@ -50,17 +50,15 @@ class JUCE_API ChoicePropertyComponent : public PropertyComponent,
{
protected:
/** Creates the component.
Your subclass's constructor must add a list of options to the choices member variable.
Your subclass's constructor must add a list of options to the choices
member variable.
*/
ChoicePropertyComponent (const String& propertyName);
public:
/** Creates the component.
Note that if you call this constructor then you must use the Value to interact with the
index, and you can't override the class with your own setIndex or getIndex methods.
If you want to use those methods, call the other constructor instead.
@param valueToControl the value that the combo box will read and control
@param propertyName the name of the property
@param choices the list of possible values that the drop-down list will contain
@@ -58,10 +58,6 @@ public:
If you need to customise the slider in other ways, your constructor can
access the slider member variable and change it directly.
Note that if you call this constructor then you must use the Value to interact with
the value, and you can't override the class with your own setValue or getValue methods.
If you want to use those methods, call the other constructor instead.
*/
SliderPropertyComponent (const Value& valueToControl,
const String& propertyName,
@@ -418,7 +418,7 @@ private:
bool isEnabled : 1, isHeading : 1;
};
OwnedArray<ItemInfo> items;
OwnedArray <ItemInfo> items;
Value currentId;
int lastCurrentId;
bool isButtonDown, separatorPending, menuActive, scrollWheelEnabled;
@@ -460,3 +460,5 @@ void Label::textEditorFocusLost (TextEditor& ed)
{
textEditorTextChanged (ed);
}
void Label::Listener::editorShown (Label*, TextEditor&) {}
@@ -184,7 +184,7 @@ public:
virtual void labelTextChanged (Label* labelThatHasChanged) = 0;
/** Called when a Label goes into editing mode and displays a TextEditor. */
virtual void editorShown (Label*, TextEditor&) {}
virtual void editorShown (Label*, TextEditor& textEditorShown);
};
/** Registers a listener that will be called when the label's text changes. */
@@ -45,10 +45,7 @@ public:
*/
virtual int getNumRows() = 0;
/** This method must be implemented to draw a row of the list.
Note that the rowNumber value may be greater than the number of rows in your
list, so be careful that you don't assume it's less than getNumRows().
*/
/** This method must be implemented to draw a row of the list. */
virtual void paintListBoxItem (int rowNumber,
Graphics& g,
int width, int height,
@@ -464,9 +464,9 @@ public:
const bool stopAtEnd)
{
// make sure the values are sensible..
jassert (startAngleRadians >= 0 && endAngleRadians >= 0);
jassert (startAngleRadians < float_Pi * 4.0f && endAngleRadians < float_Pi * 4.0f);
jassert (startAngleRadians < endAngleRadians);
jassert (rotaryStart >= 0 && rotaryEnd >= 0);
jassert (rotaryStart < float_Pi * 4.0f && rotaryEnd < float_Pi * 4.0f);
jassert (rotaryStart < rotaryEnd);
rotaryStart = startAngleRadians;
rotaryEnd = endAngleRadians;
@@ -566,7 +566,6 @@ public:
valueBox->setWantsKeyboardFocus (false);
valueBox->setText (previousTextBoxContent, dontSendNotification);
valueBox->setTooltip (owner.getTooltip());
if (valueBox->isEditable() != editableText) // (avoid overriding the single/double click flags unless we have to)
valueBox->setEditable (editableText && owner.isEnabled());
@@ -578,6 +577,10 @@ public:
valueBox->addMouseListener (&owner, false);
valueBox->setMouseCursor (MouseCursor::ParentCursor);
}
else
{
valueBox->setTooltip (owner.getTooltip());
}
}
else
{
@@ -1006,9 +1009,9 @@ public:
valueBox->hideEditor (false);
const double value = (double) currentValue.getValue();
const double delta = getMouseWheelDelta (value, (std::abs (wheel.deltaX) > std::abs (wheel.deltaY)
? -wheel.deltaX : wheel.deltaY)
* (wheel.isReversed ? -1.0f : 1.0f));
const double delta = getMouseWheelDelta (value, (wheel.deltaX != 0 ? -wheel.deltaX : wheel.deltaY)
* (wheel.isReversed ? -1.0f : 1.0f));
if (delta != 0)
{
const double newValue = value + jmax (interval, std::abs (delta)) * (delta < 0 ? -1.0 : 1.0);
@@ -26,7 +26,7 @@ class TableListBox::RowComp : public Component,
public TooltipClient
{
public:
RowComp (TableListBox& tlb) noexcept : owner (tlb), row (-1), isSelected (false)
RowComp (TableListBox& tlb) : owner (tlb), row (-1), isSelected (false)
{
}
@@ -192,7 +192,7 @@ public:
if (TableListBoxModel* m = owner.getModel())
return m->getCellTooltip (row, columnId);
return String();
return String::empty;
}
Component* findChildComponentForColumn (const int columnId) const
@@ -275,7 +275,7 @@ void TableListBox::setHeader (TableHeaderComponent* newHeader)
{
jassert (newHeader != nullptr); // you need to supply a real header for a table!
Rectangle<int> newBounds (100, 28);
Rectangle<int> newBounds (0, 0, 100, 28);
if (header != nullptr)
newBounds = header->getBounds();
@@ -287,7 +287,7 @@ void TableListBox::setHeader (TableHeaderComponent* newHeader)
header->addListener (this);
}
int TableListBox::getHeaderHeight() const noexcept
int TableListBox::getHeaderHeight() const
{
return header->getHeight();
}
@@ -312,11 +312,16 @@ void TableListBox::autoSizeAllColumns()
autoSizeColumn (header->getColumnIdOfIndex (i, true));
}
void TableListBox::setAutoSizeMenuOptionShown (const bool shouldBeShown) noexcept
void TableListBox::setAutoSizeMenuOptionShown (const bool shouldBeShown)
{
autoSizeOptionsShown = shouldBeShown;
}
bool TableListBox::isAutoSizeMenuOptionShown() const
{
return autoSizeOptionsShown;
}
Rectangle<int> TableListBox::getCellPosition (const int columnId, const int rowNumber,
const bool relativeToComponentTopLeft) const
{
@@ -332,7 +337,7 @@ Rectangle<int> TableListBox::getCellPosition (const int columnId, const int rowN
Component* TableListBox::getCellComponent (int columnId, int rowNumber) const
{
if (RowComp* const rowComp = dynamic_cast<RowComp*> (getComponentForRowNumber (rowNumber)))
if (RowComp* const rowComp = dynamic_cast <RowComp*> (getComponentForRowNumber (rowNumber)))
return rowComp->findChildComponentForColumn (columnId);
return nullptr;
@@ -365,12 +370,12 @@ void TableListBox::paintListBoxItem (int, Graphics&, int, int, bool)
{
}
Component* TableListBox::refreshComponentForRow (int rowNumber, bool rowSelected, Component* existingComponentToUpdate)
Component* TableListBox::refreshComponentForRow (int rowNumber, bool isRowSelected_, Component* existingComponentToUpdate)
{
if (existingComponentToUpdate == nullptr)
existingComponentToUpdate = new RowComp (*this);
static_cast<RowComp*> (existingComponentToUpdate)->update (rowNumber, rowSelected);
static_cast <RowComp*> (existingComponentToUpdate)->update (rowNumber, isRowSelected_);
return existingComponentToUpdate;
}
@@ -445,7 +450,7 @@ void TableListBox::updateColumnComponents() const
const int firstRow = getRowContainingPosition (0, 0);
for (int i = firstRow + getNumRowsOnScreen() + 2; --i >= firstRow;)
if (RowComp* const rowComp = dynamic_cast<RowComp*> (getComponentForRowNumber (i)))
if (RowComp* const rowComp = dynamic_cast <RowComp*> (getComponentForRowNumber (i)))
rowComp->resized();
}
@@ -460,7 +465,7 @@ void TableListBoxModel::deleteKeyPressed (int) {}
void TableListBoxModel::returnKeyPressed (int) {}
void TableListBoxModel::listWasScrolled() {}
String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String(); }
String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; }
var TableListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var(); }
Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component* existingComponentToUpdate)
@@ -57,7 +57,7 @@ public:
The graphics context has its origin at the row's top-left, and your method
should fill the area specified by the width and height parameters.
*/
virtual void paintRowBackground (Graphics&,
virtual void paintRowBackground (Graphics& g,
int rowNumber,
int width, int height,
bool rowIsSelected) = 0;
@@ -66,11 +66,8 @@ public:
The graphics context's origin will already be set to the top-left of the cell,
whose size is specified by (width, height).
Note that the rowNumber value may be greater than the number of rows in your
list, so be careful that you don't assume it's less than getNumRows().
*/
virtual void paintCell (Graphics&,
virtual void paintCell (Graphics& g,
int rowNumber,
int columnId,
int width, int height,
@@ -145,21 +142,25 @@ public:
*/
virtual int getColumnAutoSizeWidth (int columnId);
/** Returns a tooltip for a particular cell in the table. */
/** Returns a tooltip for a particular cell in the table.
*/
virtual String getCellTooltip (int rowNumber, int columnId);
//==============================================================================
/** Override this to be informed when rows are selected or deselected.
@see ListBox::selectedRowsChanged()
*/
virtual void selectedRowsChanged (int lastRowSelected);
/** Override this to be informed when the delete key is pressed.
@see ListBox::deleteKeyPressed()
*/
virtual void deleteKeyPressed (int lastRowSelected);
/** Override this to be informed when the return key is pressed.
@see ListBox::returnKeyPressed()
*/
virtual void returnKeyPressed (int lastRowSelected);
@@ -209,34 +210,29 @@ public:
/** Creates a TableListBox.
The model pointer passed-in can be null, in which case you can set it later
with setModel(). The TableListBox does not take ownership of the model - it's
the caller's responsibility to manage its lifetime and make sure it
doesn't get deleted while still being used.
with setModel().
*/
TableListBox (const String& componentName = String(),
TableListBoxModel* model = nullptr);
TableListBox (const String& componentName = String::empty,
TableListBoxModel* model = 0);
/** Destructor. */
~TableListBox();
//==============================================================================
/** Changes the TableListBoxModel that is being used for this table.
The TableListBox does not take ownership of the model - it's the caller's responsibility
to manage its lifetime and make sure it doesn't get deleted while still being used.
*/
void setModel (TableListBoxModel* newModel);
/** Returns the model currently in use. */
TableListBoxModel* getModel() const noexcept { return model; }
TableListBoxModel* getModel() const { return model; }
//==============================================================================
/** Returns the header component being used in this table. */
TableHeaderComponent& getHeader() const noexcept { return *header; }
TableHeaderComponent& getHeader() const { return *header; }
/** Sets the header component to use for the table.
The table will take ownership of the component that you pass in, and will delete it
when it's no longer needed.
The pointer passed in may not be null.
*/
void setHeader (TableHeaderComponent* newHeader);
@@ -248,7 +244,7 @@ public:
/** Returns the height of the table header.
@see setHeaderHeight
*/
int getHeaderHeight() const noexcept;
int getHeaderHeight() const;
//==============================================================================
/** Resizes a column to fit its contents.
@@ -264,14 +260,15 @@ public:
void autoSizeAllColumns();
/** Enables or disables the auto size options on the popup menu.
By default, these are enabled.
*/
void setAutoSizeMenuOptionShown (bool shouldBeShown) noexcept;
void setAutoSizeMenuOptionShown (bool shouldBeShown);
/** True if the auto-size options should be shown on the menu.
@see setAutoSizeMenuOptionShown
@see setAutoSizeMenuOptionsShown
*/
bool isAutoSizeMenuOptionShown() const noexcept { return autoSizeOptionsShown; }
bool isAutoSizeMenuOptionShown() const;
/** Returns the position of one of the cells in the table.
@@ -591,8 +591,8 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
{
const Rectangle<int> previousPos (animator.getComponentDestination (prev));
if (std::abs (dragObjectLeft - (vertical ? previousPos.getY() : previousPos.getX()))
< std::abs (dragObjectRight - (vertical ? current.getBottom() : current.getRight())))
if (abs (dragObjectLeft - (vertical ? previousPos.getY() : previousPos.getX())
< abs (dragObjectRight - (vertical ? current.getBottom() : current.getRight()))))
{
newIndex = getIndexOfChildComponent (prev);
}
@@ -602,8 +602,8 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
{
const Rectangle<int> nextPos (animator.getComponentDestination (next));
if (std::abs (dragObjectLeft - (vertical ? current.getY() : current.getX()))
> std::abs (dragObjectRight - (vertical ? nextPos.getBottom() : nextPos.getRight())))
if (abs (dragObjectLeft - (vertical ? current.getY() : current.getX())
> abs (dragObjectRight - (vertical ? nextPos.getBottom() : nextPos.getRight()))))
{
newIndex = getIndexOfChildComponent (next) + 1;
}
@@ -1773,11 +1773,6 @@ TreeViewItem* TreeViewItem::getNextVisibleItem (const bool recurse) const noexce
return nullptr;
}
static String escapeSlashesInTreeViewItemName (const String& s)
{
return s.replaceCharacter ('/', '\\');
}
String TreeViewItem::getItemIdentifierString() const
{
String s;
@@ -1785,12 +1780,12 @@ String TreeViewItem::getItemIdentifierString() const
if (parentItem != nullptr)
s = parentItem->getItemIdentifierString();
return s + "/" + escapeSlashesInTreeViewItemName (getUniqueName());
return s + "/" + getUniqueName().replaceCharacter ('/', '\\');
}
TreeViewItem* TreeViewItem::findItemFromIdentifierString (const String& identifierString)
{
const String thisId ("/" + escapeSlashesInTreeViewItemName (getUniqueName()));
const String thisId ("/" + getUniqueName());
if (thisId == identifierString)
return this;
@@ -404,7 +404,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
for (int i = textBlocks.size(); --i >= 0;)
{
const AlertTextComp* const ac = static_cast<const AlertTextComp*> (textBlocks.getUnchecked(i));
const AlertTextComp* const ac = static_cast <const AlertTextComp*> (textBlocks.getUnchecked(i));
w = jmax (w, ac->getPreferredWidth());
}
@@ -412,7 +412,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
for (int i = textBlocks.size(); --i >= 0;)
{
AlertTextComp* const ac = static_cast<AlertTextComp*> (textBlocks.getUnchecked(i));
AlertTextComp* const ac = static_cast <AlertTextComp*> (textBlocks.getUnchecked(i));
ac->updateLayout ((int) (w * 0.8f));
h += ac->getHeight() + 10;
}
@@ -470,11 +470,11 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
Component* const c = allComps.getUnchecked(i);
h = 22;
const int comboIndex = comboBoxes.indexOf (dynamic_cast<ComboBox*> (c));
const int comboIndex = comboBoxes.indexOf (dynamic_cast <ComboBox*> (c));
if (comboIndex >= 0 && comboBoxNames [comboIndex].isNotEmpty())
y += labelHeight;
const int tbIndex = textBoxes.indexOf (dynamic_cast<TextEditor*> (c));
const int tbIndex = textBoxes.indexOf (dynamic_cast <TextEditor*> (c));
if (tbIndex >= 0 && textboxNames[tbIndex].isNotEmpty())
y += labelHeight;
@@ -536,8 +536,7 @@ bool AlertWindow::keyPressed (const KeyPress& key)
exitModalState (0);
return true;
}
if (key.isKeyCode (KeyPress::returnKey) && buttons.size() == 1)
else if (key.isKeyCode (KeyPress::returnKey) && buttons.size() == 1)
{
buttons.getUnchecked(0)->triggerClick();
return true;
@@ -593,8 +592,8 @@ private:
LookAndFeel& lf = associatedComponent != nullptr ? associatedComponent->getLookAndFeel()
: LookAndFeel::getDefaultLookAndFeel();
ScopedPointer<Component> alertBox (lf.createAlertWindow (title, message, button1, button2, button3,
iconType, numButtons, associatedComponent));
ScopedPointer <Component> alertBox (lf.createAlertWindow (title, message, button1, button2, button3,
iconType, numButtons, associatedComponent));
jassert (alertBox != nullptr); // you have to return one of these!
@@ -615,7 +614,7 @@ private:
static void* showCallback (void* userData)
{
static_cast<AlertWindowInfo*> (userData)->show();
static_cast <AlertWindowInfo*> (userData)->show();
return nullptr;
}
};
@@ -78,7 +78,7 @@ public:
initialise its fields with the appropriate details, and then call its launchAsync()
method to launch the dialog.
*/
struct JUCE_API LaunchOptions
struct LaunchOptions
{
LaunchOptions() noexcept;
@@ -127,7 +127,7 @@ public:
//==============================================================================
/** @internal */
void addToDesktop (int windowStyleFlags, void* nativeWindowToAttachTo = nullptr) override;
virtual void addToDesktop (int windowStyleFlags, void* nativeWindowToAttachTo = nullptr) override;
protected:
//==============================================================================