15 .type = ElementType::Text,
16 .group = ElementGroup::Other,
19 static_assert(
validate(constraints));
24 meta.pixmapPath = []{
return QStringLiteral(
":/Components/Misc/text.png"); };
25 meta.titleText = QT_TRANSLATE_NOOP(
"Text",
"TEXT");
26 meta.translatedName = QT_TRANSLATE_NOOP(
"Text",
"Text");
27 meta.trContext =
"Text";
32 meta.defaultAppearances = QStringList({
33 ":/Components/Misc/no_text.png",
34 ":/Components/Misc/text.png",
51 QFont hintFont = m_emptyHint->font();
52 hintFont.setItalic(
true);
53 m_emptyHint->setFont(hintFont);
57 m_emptyHint->setPos(0, 64);
58 m_emptyHint->setText(tr(
"Double-click to add text"));
76 hintColor.setAlpha(140);
77 m_emptyHint->setBrush(hintColor);
82 m_emptyHint->setVisible(
label().isEmpty());
Singleton factory for all circuit element types.
Self-registering element trait template and compile-time constraint validation.
ElementMetadata metadataFromConstraints(const ElementConstraints &c)
Converts ElementConstraints to an ElementMetadata with all constraint-derived fields set.
constexpr bool validate(const ElementConstraints &c)
Validates element constraints at compile time.
Enums::ElementType ElementType
Graphic element for a free-text annotation label (no simulation).
Theme management types and singleton ThemeManager.
static void registerCreator(ElementType type, std::function< GraphicElement *()> creator)
Registers a creator lambda for type, used by buildElement().
GraphicElement(ElementType type, QGraphicsItem *parent=nullptr)
Constructs a graphic element of the given type, fetching all properties from the metadata registry.
virtual void updateTheme()
Updates the element's visual theme according to the current dark/light palette.
QString label() const
Returns the user-visible label text for this element.
QRectF boundingRect() const override
Returns the bounding rectangle of this element in local coordinates.
Free-text annotation element used for labelling circuit diagrams.
Text(QGraphicsItem *parent=nullptr)
Constructs a Text element.
void updateTheme() override
Refreshes the empty-state hint's color alongside the base label/port theming.
void labelContentChanged() override
QRectF boundingRect() const override
Returns a bounding rect that includes the label text, not just the pixmap.
QColor m_graphicElementLabelColor
static const ThemeAttributes & attributes()
Returns the current ThemeAttributes color set.
Compile-time-validatable subset of ElementMetadata.
static ElementMetadata metadata()
static constexpr ElementConstraints constraints
static const bool registered
Self-registering element information trait.