API Documentation
Loading...
Searching...
No Matches
QCustomDial.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: QCustomDial
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/String.h>
35#include <NDEVR/RGBColor.h>
36#include <QDial>
37namespace NDEVR
38{
39 struct DialIcon
40 {
42 QPixmap pixmap;
43 QPixmap scaled_pixmap;//used to cache the last scaled pixmap to avoid calling scale again when the size is still at the same
44 bool fullsize = false;
45 bool rotate = false;
46 bool make_shadow = false;
48 fltp08 size = 1.0;
49 void setImageID(const String& id)
50 {
51 image_id = id;
52 pixmap = QPixmap();
53 scaled_pixmap = QPixmap();
54 }
55 };
56 class QCustomLineEdit;
57 class NDEVR_WIDGETS_API QCustomDial : public QDial
58 {
59 Q_OBJECT
60 public:
61 QCustomDial(QWidget* parent = nullptr);
63
64 //based on the implementation of QLabel::paintEvent
65 void paintEvent(QPaintEvent *event) override;
66 int heightForWidth(int w) const override { return w; }
67 void mouseMoveEvent(QMouseEvent *event) override;
68 void mouseReleaseEvent(QMouseEvent *event) override;
69 void mousePressEvent(QMouseEvent *event) override;
70 void keyPressEvent(QKeyEvent* event) override;
71 void wheelEvent(QWheelEvent* e) override;
72 void resizeEvent(QResizeEvent *event) override;
73 void setIcon(const QPixmap& map, bool show_full_icon, bool rotate_icon);
74 void addIcon(const String& icon, bool show_full_icon, bool rotate_icon);
75 void addIcon(const DialIcon& icon);
76 const Buffer<DialIcon>& icons() const { return m_icons; };
77 void setIcons(const Buffer<DialIcon>& icons);
78 void clearIcons();
79 void setColor(const RGBColor& color);
80 bool event(QEvent* event) override;
81 QSize sizeHint() const override;
82 QSize minimumSizeHint() const override;
83 void setGrip(fltp04 grip_size)
84 {
85 m_grip_size = grip_size;
86 }
87 void setMaxValue(fltp08 max);
88 void setMinValue(fltp08 min);
89 void showLineEdit(bool show);
90 void tieToLineEdit(QCustomLineEdit* edit, bool is_offset = false);
91 QCustomLineEdit* centerLineEdit();
92 fltp08 getValue();
93 protected slots:
94 void onValueChanged();
95 public slots:
96 void setValue(fltp08 value);
97 signals:
98 void edited();
99 protected:
100 void _setValue(fltp08 value, bool emit_edit = false);
101 void updateCenterLineEditLocation();
102 fltp08 pixSize(const DialIcon& icon) const;
103 void cacheScaledPixmap(DialIcon& icon);
104 private:
105 Buffer<DialIcon> m_icons;
106 fltp08 m_grip_size;
107 QCustomLineEdit* m_center_edit;
108
109 fltp08 m_max_value;
110 fltp08 m_min_value;
111 //key for the currently cached QImage and QPixmap
112 //used to make sure the label was not set to another QPixmap
113 qint64 cacheKey{ 0 };
114 RGBColor m_color;
115 bool m_is_editing;
116 bool m_has_user_focus;
117 void modifyValue(QMouseEvent* event);
118 };
119}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:81
Stores an angle in an optimized format.
Definition StringStream.h:352
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition QCustomDial.h:58
const Buffer< DialIcon > & icons() const
Definition QCustomDial.h:76
int heightForWidth(int w) const override
Definition QCustomDial.h:66
void setGrip(fltp04 grip_size)
Definition QCustomDial.h:83
Definition QCustomLineEdit.h:118
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
Definition String.h:40
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition QCustomDial.h:40
QPixmap scaled_pixmap
Definition QCustomDial.h:43
bool rotate
Definition QCustomDial.h:45
fltp08 size
Definition QCustomDial.h:48
String image_id
Definition QCustomDial.h:41
QPixmap pixmap
Definition QCustomDial.h:42
bool make_shadow
Definition QCustomDial.h:46
void setImageID(const String &id)
Definition QCustomDial.h:49
Angle< fltp08 > rotation_offset
Definition QCustomDial.h:47
bool fullsize
Definition QCustomDial.h:44