DrawableImage::DrawableImage() : opacity (1.0f), overlayColour (0x00000000) { bounds.topRight = RelativePoint (Point<float> (1.0f, 0.0f)); bounds.bottomLeft = RelativePoint (Point<float> (0.0f, 1.0f)); }
void DrawableComposite::ValueTreeWrapper::resetBoundingBoxToContentArea (UndoManager* undoManager) { const RelativeRectangle content (getContentArea()); setBoundingBox (RelativeParallelogram (RelativePoint (content.left, content.top), RelativePoint (content.right, content.top), RelativePoint (content.left, content.bottom)), undoManager); }
void DrawableComposite::resetBoundingBoxToContentArea() { const RelativeRectangle content (getContentArea()); setBoundingBox (RelativeParallelogram (RelativePoint (content.left, content.top), RelativePoint (content.right, content.top), RelativePoint (content.left, content.bottom))); }
DrawableText::DrawableText() : colour (Colours::black), justification (Justification::centredLeft) { setBoundingBox (RelativeParallelogram (RelativePoint (0.0f, 0.0f), RelativePoint (50.0f, 0.0f), RelativePoint (0.0f, 20.0f))); setFont (Font (15.0f), true); }
//============================================================================== void DrawableImage::setImage (const Image& imageToUse) { image = imageToUse; setBounds (imageToUse.getBounds()); bounds.topLeft = RelativePoint (Point<float> (0.0f, 0.0f)); bounds.topRight = RelativePoint (Point<float> ((float) image.getWidth(), 0.0f)); bounds.bottomLeft = RelativePoint (Point<float> (0.0f, (float) image.getHeight())); recalculateCoordinates (nullptr); repaint(); }
//============================================================================== void DrawableImage::setImage (const Image& imageToUse) { image = imageToUse; setBounds (imageToUse.getBounds()); if (image.isValid()) { bounds.topLeft = RelativePoint (Point<float> (0.0f, 0.0f)); bounds.topRight = RelativePoint (Point<float> ((float) image.getWidth(), 0.0f)); bounds.bottomLeft = RelativePoint (Point<float> (0.0f, (float) image.getHeight())); } refreshTransformFromBounds(); }
BEGIN_JUCE_NAMESPACE #include "juce_DrawableText.h" #include "juce_DrawableComposite.h" //============================================================================== DrawableText::DrawableText() : colour (Colours::black), justification (Justification::centredLeft) { setBoundingBox (RelativeParallelogram (RelativePoint (0.0f, 0.0f), RelativePoint (50.0f, 0.0f), RelativePoint (0.0f, 20.0f))); setFont (Font (15.0f), true); }
BEGIN_JUCE_NAMESPACE #include "juce_DrawableImage.h" #include "juce_DrawableComposite.h" #include "../imaging/juce_ImageCache.h" //============================================================================== DrawableImage::DrawableImage() : image (0), opacity (1.0f), overlayColour (0x00000000) { bounds.topRight = RelativePoint (Point<float> (1.0f, 0.0f)); bounds.bottomLeft = RelativePoint (Point<float> (0.0f, 1.0f)); }
RelativePointPath::RelativePointPath (const Path& path) : usesNonZeroWinding (path.isUsingNonZeroWinding()), containsDynamicPoints (false) { for (Path::Iterator i (path); i.next();) { switch (i.elementType) { case Path::Iterator::startNewSubPath: elements.add (new StartSubPath (RelativePoint (i.x1, i.y1))); break; case Path::Iterator::lineTo: elements.add (new LineTo (RelativePoint (i.x1, i.y1))); break; case Path::Iterator::quadraticTo: elements.add (new QuadraticTo (RelativePoint (i.x1, i.y1), RelativePoint (i.x2, i.y2))); break; case Path::Iterator::cubicTo: elements.add (new CubicTo (RelativePoint (i.x1, i.y1), RelativePoint (i.x2, i.y2), RelativePoint (i.x3, i.y3))); break; case Path::Iterator::closePath: elements.add (new CloseSubPath()); break; default: jassertfalse; break; } } }
bool DrawableShape::RelativeFillType::readFrom (const ValueTree& v, ComponentBuilder::ImageProvider* imageProvider) { const String newType (v [FillAndStrokeState::type].toString()); if (newType == "solid") { const String colourString (v [FillAndStrokeState::colour].toString()); fill.setColour (Colour (colourString.isEmpty() ? (uint32) 0xff000000 : (uint32) colourString.getHexValue32())); return true; } else if (newType == "gradient") { ColourGradient g; g.isRadial = v [FillAndStrokeState::radial]; StringArray colourSteps; colourSteps.addTokens (v [FillAndStrokeState::colours].toString(), false); for (int i = 0; i < colourSteps.size() / 2; ++i) g.addColour (colourSteps[i * 2].getDoubleValue(), Colour ((uint32) colourSteps[i * 2 + 1].getHexValue32())); fill.setGradient (g); gradientPoint1 = RelativePoint (v [FillAndStrokeState::gradientPoint1]); gradientPoint2 = RelativePoint (v [FillAndStrokeState::gradientPoint2]); gradientPoint3 = RelativePoint (v [FillAndStrokeState::gradientPoint3]); return true; } else if (newType == "image") { Image im; if (imageProvider != nullptr) im = imageProvider->getImageForIdentifier (v [FillAndStrokeState::imageId]); fill.setTiledImage (im, AffineTransform::identity); fill.setOpacity ((float) v.getProperty (FillAndStrokeState::imageOpacity, 1.0f)); return true; } jassertfalse; return false; }
void DrawableText::setFont (const Font& newFont, bool applySizeAndScale) { if (font != newFont) { font = newFont; if (applySizeAndScale) { setFontSizeControlPoint (RelativePoint (RelativeParallelogram::getPointForInternalCoord (resolvedPoints, Point<float> (font.getHorizontalScale() * font.getHeight(), font.getHeight())))); } refreshBounds(); } }
RelativePoint DrawableRectangle::ValueTreeWrapper::getCornerSize() const { return RelativePoint (state [cornerSize]); }
NSPoint g(NSPoint refPoint) { float pointA, pointB; return RelativePoint (NSMakePoint (0, pointA), refPoint); }