Gin
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
SVGButton Class Reference

Button that displays an SVG graphic instead of or alongside text. More...

#include <gin_svgbutton.h>

Inheritance diagram for SVGButton:

Public Member Functions

 SVGButton (const juce::String &name, const juce::String &rawSVG_, int inset_=0)
 

Public Attributes

juce::String rawSVG
 
int inset = 0
 

Detailed Description

Button that displays an SVG graphic instead of or alongside text.

SVGButton extends TextButton to support rendering SVG graphics. The SVG is stored as raw XML text and can be drawn by a custom LookAndFeel. The button provides an inset parameter to control padding around the SVG.

Note: The actual SVG rendering must be implemented in your LookAndFeel's drawButtonBackground() or drawButtonText() methods. This class only stores the SVG data and inset value.

Usage:

String svgXml = "<svg>...</svg>";
SVGButton button("IconButton", svgXml, 4); // 4 pixel inset
// In your LookAndFeel:
void drawButtonBackground(Graphics& g, Button& btn, ...) override
{
if (auto* svg = dynamic_cast<SVGButton*>(&btn))
{
auto drawable = Drawable::createFromSVG(*XmlDocument::parse(svg->rawSVG));
drawable->drawWithin(g, btn.getLocalBounds().reduced(svg->inset).toFloat(), ...);
}
}
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
Point()=default
Creates a point at the origin (0, 0).
Button that displays an SVG graphic instead of or alongside text.
Definition gin_svgbutton.h:45
See also
juce::TextButton, juce::Drawable

Constructor & Destructor Documentation

◆ SVGButton()

SVGButton::SVGButton ( const juce::String &  name,
const juce::String &  rawSVG_,
int  inset_ = 0 
)

Member Data Documentation

◆ rawSVG

juce::String SVGButton::rawSVG

◆ inset

int SVGButton::inset = 0

The documentation for this class was generated from the following file: