bWidgets
Core widget toolkit designed for Blender
bwNumberSlider.h
Go to the documentation of this file.
1#pragma once
2
3#include "bwTextBox.h"
4
5namespace bWidgets {
6
7class bwPainter;
8class bwStyle;
9
10class bwNumberSlider : public bwTextBox {
11 public:
13
14 bwNumberSlider(std::optional<unsigned int> width_hint = std::nullopt,
15 std::optional<unsigned int> height_hint = std::nullopt);
16
17 auto getTypeIdentifier() const -> std::string_view override;
18
19 void draw(bwStyle& style) override;
20
21 auto createHandler() -> std::unique_ptr<bwScreenGraph::EventHandler> override;
22
23 auto setValue(float value) -> bwNumberSlider&;
24 auto getValue() const -> float;
25 auto setMinMax(float min, float max) -> bwNumberSlider&;
26
27 std::unique_ptr<bwFunctorInterface> apply_functor{nullptr};
28
29 private:
30 auto valueToString(unsigned int precision) const -> std::string;
31 void drawValueIndicator(bwPainter& painter, bwStyle& style) const;
32 auto calcValueIndicatorWidth(class bwStyle& style) const -> float;
33
38 union {
39 // float
40 struct {
41 float value;
42 float min, max;
43 unsigned int precision;
44 };
45 // struct { int value; ...}
46 // struct { char value; ...}
47 // ...
48 };
49};
50
51} // namespace bWidgets
Abstract function object class.
Definition: bwFunctorInterface.h:31
Definition: bwNumberSlider.cc:138
Definition: bwNumberSlider.h:10
bwNumberSlider(std::optional< unsigned int > width_hint=std::nullopt, std::optional< unsigned int > height_hint=std::nullopt)
Definition: bwNumberSlider.cc:16
auto getTypeIdentifier() const -> std::string_view override
Definition: bwNumberSlider.cc:22
auto setMinMax(float min, float max) -> bwNumberSlider &
Definition: bwNumberSlider.cc:113
float max
Definition: bwNumberSlider.h:42
float min
Definition: bwNumberSlider.h:42
std::unique_ptr< bwFunctorInterface > apply_functor
Definition: bwNumberSlider.h:27
auto createHandler() -> std::unique_ptr< bwScreenGraph::EventHandler > override
Definition: bwNumberSlider.cc:160
auto setValue(float value) -> bwNumberSlider &
Definition: bwNumberSlider.cc:99
unsigned int precision
Definition: bwNumberSlider.h:43
auto getValue() const -> float
Definition: bwNumberSlider.cc:108
float value
Definition: bwNumberSlider.h:41
void draw(bwStyle &style) override
Definition: bwNumberSlider.cc:27
Definition: bwPainter.h:40
Definition: bwStyle.h:10
Definition: bwTextBox.h:8
unsigned int height_hint
Definition: bwWidget.h:68
unsigned int width_hint
Definition: bwWidget.h:68
Definition: bwContext.h:3