Cockatrice
2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
percent_bar_widget.h
Go to the documentation of this file.
1
7
8
#ifndef PERCENT_BAR_WIDGET_H
9
#define PERCENT_BAR_WIDGET_H
10
11
#include <QPainter>
12
#include <QWidget>
13
14
class
PercentBarWidget
:
public
QWidget
15
{
16
Q_OBJECT
17
18
public
:
19
explicit
PercentBarWidget
(QWidget *parent,
double
initialValue);
20
21
void
setValue
(
double
newValue)
22
{
23
valueToDisplay
= qBound(-100.0, newValue, 100.0);
// Clamp to [-100, 100]
24
update();
// Trigger repaint
25
}
26
27
double
value
()
const
28
{
29
return
valueToDisplay
;
30
}
31
32
protected
:
33
void
paintEvent
(QPaintEvent *event)
override
;
34
35
private
:
36
double
valueToDisplay
;
// Ranges from -100 to 100
37
};
38
39
#endif
// PERCENT_BAR_WIDGET_H
PercentBarWidget::PercentBarWidget
PercentBarWidget(QWidget *parent, double initialValue)
Definition
percent_bar_widget.cpp:3
PercentBarWidget::value
double value() const
Definition
percent_bar_widget.h:27
PercentBarWidget::valueToDisplay
double valueToDisplay
Definition
percent_bar_widget.h:36
PercentBarWidget::setValue
void setValue(double newValue)
Definition
percent_bar_widget.h:21
PercentBarWidget::paintEvent
void paintEvent(QPaintEvent *event) override
Definition
percent_bar_widget.cpp:8
cockatrice
src
interface
widgets
general
display
percent_bar_widget.h
Generated by
1.14.0