ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvFontPropertyWidget.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "CV_db.h"
12 
13 // Qt
14 #include <QColor>
15 #include <QWidget>
16 
17 class QToolButton;
18 
19 namespace Ui {
21 }
22 
48 class CV_DB_LIB_API ecvFontPropertyWidget : public QWidget {
49  Q_OBJECT
50 
51 public:
53  struct FontProperties {
54  QString family = "Arial";
55  int size = 18;
56  QColor color = QColor(255, 255, 255); // Default white
57  double opacity = 1.0;
58  bool bold = false;
59  bool italic = false;
60  bool shadow = true;
61  QString horizontalJustification = "Left"; // Left, Center, Right
62  QString verticalJustification = "Bottom"; // Top, Center, Bottom
63 
65  int fontFamilyIndex() const;
66 
68  void setFontFamilyFromIndex(int index);
69  };
70 
71  explicit ecvFontPropertyWidget(QWidget* parent = nullptr);
73 
77  void setFontProperties(const FontProperties& props);
79 
82  QString fontFamily() const;
83  int fontFamilyIndex() const;
84  int fontSize() const;
85  QColor fontColor() const;
86  double fontOpacity() const;
87  bool isBold() const;
88  bool isItalic() const;
89  bool hasShadow() const;
90  QString horizontalJustification() const;
91  QString verticalJustification() const;
93 
96  void setFontFamily(const QString& family, bool blockSignal = false);
97  void setFontFamilyIndex(int index, bool blockSignal = false);
98  void setFontSize(int size, bool blockSignal = false);
99  void setFontColor(const QColor& color, bool blockSignal = false);
100  void setFontOpacity(double opacity, bool blockSignal = false);
101  void setBold(bool bold, bool blockSignal = false);
102  void setItalic(bool italic, bool blockSignal = false);
103  void setShadow(bool shadow, bool blockSignal = false);
104  void setHorizontalJustification(const QString& justification,
105  bool blockSignal = false);
106  void setVerticalJustification(const QString& justification,
107  bool blockSignal = false);
109 
111  void setColorPickerVisible(bool visible);
112 
114  void setControlsEnabled(bool enabled);
115 
116 Q_SIGNALS:
119 
121  void fontFamilyChanged(const QString& family);
122  void fontFamilyIndexChanged(int index);
124  void fontColorChanged(const QColor& color);
125  void fontOpacityChanged(double opacity);
126  void boldChanged(bool bold);
127  void italicChanged(bool italic);
128  void shadowChanged(bool shadow);
129  void horizontalJustificationChanged(const QString& justification);
130  void verticalJustificationChanged(const QString& justification);
131 
132 private Q_SLOTS:
133  void onFontFamilyChanged(int index);
134  void onFontSizeChanged(int size);
135  void onFontColorClicked();
136  void onFontOpacityChanged(double opacity);
137  void onBoldToggled(bool checked);
138  void onItalicToggled(bool checked);
139  void onShadowToggled(bool checked);
140  void onHorizontalJustificationTriggered(QAction* action);
141  void onVerticalJustificationTriggered(QAction* action);
142 
143 protected:
144  void resizeEvent(QResizeEvent* event) override;
145 
146 private:
147  void setupConnections();
148  void updateColorButtonAppearance();
149  void setupHorizontalJustificationButton();
150  void setupVerticalJustificationButton();
151  void updateJustificationButtonIcon(const QString& justification,
152  QToolButton* button);
153 
154  Ui::ecvFontPropertyWidget* ui;
155 
157  QColor m_fontColor;
158 
160  QString m_horizontalJustification = "Left";
161  QString m_verticalJustification = "Bottom";
162 
164  bool m_blockSignals = false;
165 };
MouseEvent event
#define CV_DB_LIB_API
Definition: CV_db.h:15
int size
math::float4 color
A reusable font property widget matching ParaView's font editor style.
void setColorPickerVisible(bool visible)
Show/hide the color picker button.
double fontOpacity() const
void resizeEvent(QResizeEvent *event) override
void horizontalJustificationChanged(const QString &justification)
bool hasShadow() const
void setFontProperties(const FontProperties &props)
int fontFamilyIndex() const
QString fontFamily() const
void setFontFamilyIndex(int index, bool blockSignal=false)
void setShadow(bool shadow, bool blockSignal=false)
QString horizontalJustification() const
void fontFamilyChanged(const QString &family)
Individual property change signals.
void italicChanged(bool italic)
void setControlsEnabled(bool enabled)
Enable/disable all controls.
bool isItalic() const
ecvFontPropertyWidget(QWidget *parent=nullptr)
QColor fontColor() const
void setHorizontalJustification(const QString &justification, bool blockSignal=false)
void setFontOpacity(double opacity, bool blockSignal=false)
void setFontFamily(const QString &family, bool blockSignal=false)
void fontFamilyIndexChanged(int index)
void setFontColor(const QColor &color, bool blockSignal=false)
void fontColorChanged(const QColor &color)
void setFontSize(int size, bool blockSignal=false)
void setItalic(bool italic, bool blockSignal=false)
QString verticalJustification() const
void verticalJustificationChanged(const QString &justification)
FontProperties fontProperties() const
~ecvFontPropertyWidget() override
void fontPropertiesChanged()
Emitted when any font property changes.
void fontSizeChanged(int size)
void setVerticalJustification(const QString &justification, bool blockSignal=false)
void boldChanged(bool bold)
void shadowChanged(bool shadow)
void setBold(bool bold, bool blockSignal=false)
void fontOpacityChanged(double opacity)
Font property structure for convenience.
int fontFamilyIndex() const
Returns VTK font family index (0=Arial, 1=Courier, 2=Times)
void setFontFamilyFromIndex(int index)
Sets family from VTK font family index.