//============================================================================== void DrawableRectangle::refreshFromValueTree (const ValueTree& tree, ComponentBuilder& builder) { ValueTreeWrapper v (tree); setComponentID (v.getID()); refreshFillTypes (v, builder.getImageProvider()); setStrokeType (v.getStrokeType()); setRectangle (v.getRectangle()); setCornerSize (v.getCornerSize()); }
//============================================================================== void DrawableText::refreshFromValueTree (const ValueTree& tree, ComponentBuilder&) { ValueTreeWrapper v (tree); setComponentID (v.getID()); const RelativeParallelogram newBounds (v.getBoundingBox()); const RelativeCoordinate newFontHeight (v.getFontHeight()); const RelativeCoordinate newFontHScale (v.getFontHorizontalScale()); const Colour newColour (v.getColour()); const Justification newJustification (v.getJustification()); const String newText (v.getText()); const Font newFont (v.getFont()); if (text != newText || font != newFont || justification != newJustification || colour != newColour || bounds != newBounds || newFontHeight != fontHeight || newFontHScale != fontHScale) { setBoundingBox (newBounds); setFontHeight (newFontHeight); setFontHorizontalScale (newFontHScale); setColour (newColour); setFont (newFont, false); setJustification (newJustification); setText (newText); } }
ValueTree DrawableRectangle::createValueTree (ComponentBuilder::ImageProvider* imageProvider) const { ValueTree tree (valueTreeType); ValueTreeWrapper v (tree); v.setID (getComponentID()); writeTo (v, imageProvider, nullptr); v.setRectangle (bounds, nullptr); v.setCornerSize (cornerSize, nullptr); return tree; }
//============================================================================== void DrawablePath::refreshFromValueTree (const ValueTree& tree, ComponentBuilder& builder) { ValueTreeWrapper v (tree); setComponentID (v.getID()); refreshFillTypes (v, builder.getImageProvider()); setStrokeType (v.getStrokeType()); RelativePointPath newRelativePath; v.writeTo (newRelativePath); setPath (newRelativePath); }
ValueTree DrawablePath::createValueTree (ComponentBuilder::ImageProvider* imageProvider) const { ValueTree tree (valueTreeType); ValueTreeWrapper v (tree); v.setID (getComponentID()); writeTo (v, imageProvider, nullptr); if (relativePath != nullptr) v.readFrom (*relativePath, nullptr); else v.readFrom (RelativePointPath (path), nullptr); return tree; }
ValueTree DrawableText::createValueTree (ComponentBuilder::ImageProvider*) const { ValueTree tree (valueTreeType); ValueTreeWrapper v (tree); v.setID (getComponentID()); v.setText (text, nullptr); v.setFont (font, nullptr); v.setJustification (justification, nullptr); v.setColour (colour, nullptr); v.setBoundingBox (bounds, nullptr); v.setFontHeight (fontHeight, nullptr); v.setFontHorizontalScale (fontHScale, nullptr); return tree; }
const ValueTree DrawableImage::createValueTree (ImageProvider* imageProvider) const { ValueTree tree (valueTreeType); ValueTreeWrapper v (tree); v.setID (getName(), 0); v.setOpacity (opacity, 0); v.setOverlayColour (overlayColour, 0); v.setBoundingBox (bounds, 0); if (image.isValid()) { jassert (imageProvider != 0); // if you're using images, you need to provide something that can load and save them! if (imageProvider != 0) v.setImageIdentifier (imageProvider->getIdentifierForImage (image), 0); } return tree; }
ValueTree DrawableComposite::createValueTree (ComponentBuilder::ImageProvider* imageProvider) const { ValueTree tree (valueTreeType); ValueTreeWrapper v (tree); v.setID (getComponentID()); v.setBoundingBox (bounds, nullptr); ValueTree childList (v.getChildListCreating (nullptr)); for (int i = 0; i < getNumChildComponents(); ++i) { const Drawable* const d = dynamic_cast <const Drawable*> (getChildComponent(i)); jassert (d != nullptr); // You can't save a mix of Drawables and normal components! childList.addChild (d->createValueTree (imageProvider), -1, nullptr); } v.getMarkerListCreating (true, nullptr).readFrom (markersX, nullptr); v.getMarkerListCreating (false, nullptr).readFrom (markersY, nullptr); return tree; }