GUI parts for DISCO-F746NG. GuiBase, Button, ButtonGroup, ResetButton, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup, NumericUpDown
Dependencies: Array_Matrix TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG
SeekBar.hpp@10:5a2068884fd9, 2016-04-27 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Wed Apr 27 00:24:18 2016 +0000
- Revision:
- 10:5a2068884fd9
- Parent:
- 9:c379410bda15
- Child:
- 11:7debdaa7b503
11
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:a2686ef737c2 | 1 | //----------------------------------------------------------- |
MikamiUitOpen | 0:a2686ef737c2 | 2 | // SeekBar class -- Header |
MikamiUitOpen | 0:a2686ef737c2 | 3 | // |
MikamiUitOpen | 10:5a2068884fd9 | 4 | // 2016/04/26, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 0:a2686ef737c2 | 5 | //----------------------------------------------------------- |
MikamiUitOpen | 0:a2686ef737c2 | 6 | |
MikamiUitOpen | 0:a2686ef737c2 | 7 | #ifndef F746_SEEKBAR_HPP |
MikamiUitOpen | 0:a2686ef737c2 | 8 | #define F746_SEEKBAR_HPP |
MikamiUitOpen | 0:a2686ef737c2 | 9 | |
MikamiUitOpen | 0:a2686ef737c2 | 10 | #include "GuiBase.hpp" |
MikamiUitOpen | 6:b8f197b0012c | 11 | #include "Label.hpp" |
MikamiUitOpen | 0:a2686ef737c2 | 12 | |
MikamiUitOpen | 0:a2686ef737c2 | 13 | namespace Mikami |
MikamiUitOpen | 0:a2686ef737c2 | 14 | { |
MikamiUitOpen | 0:a2686ef737c2 | 15 | class SeekBar : public GuiBase |
MikamiUitOpen | 0:a2686ef737c2 | 16 | { |
MikamiUitOpen | 0:a2686ef737c2 | 17 | public: |
MikamiUitOpen | 0:a2686ef737c2 | 18 | enum Orientation { Holizontal, Vertical }; |
MikamiUitOpen | 0:a2686ef737c2 | 19 | |
MikamiUitOpen | 9:c379410bda15 | 20 | struct Point |
MikamiUitOpen | 9:c379410bda15 | 21 | { |
MikamiUitOpen | 9:c379410bda15 | 22 | uint16_t x, y; |
MikamiUitOpen | 9:c379410bda15 | 23 | Point(uint16_t x0 = 0, uint16_t y0 = 0) : x(x0), y(y0) {} |
MikamiUitOpen | 9:c379410bda15 | 24 | }; |
MikamiUitOpen | 9:c379410bda15 | 25 | |
MikamiUitOpen | 0:a2686ef737c2 | 26 | // Constructor |
MikamiUitOpen | 0:a2686ef737c2 | 27 | SeekBar(uint16_t x, uint16_t y, uint16_t length, |
MikamiUitOpen | 6:b8f197b0012c | 28 | float min, float max, float initialValue, |
MikamiUitOpen | 0:a2686ef737c2 | 29 | Orientation hv = Holizontal, |
MikamiUitOpen | 0:a2686ef737c2 | 30 | uint32_t thumbColor = LCD_COLOR_WHITE, |
MikamiUitOpen | 0:a2686ef737c2 | 31 | uint16_t thumbSize = 30, uint16_t width = 4, |
MikamiUitOpen | 0:a2686ef737c2 | 32 | uint32_t colorL = LCD_COLOR_LIGHTGRAY, |
MikamiUitOpen | 0:a2686ef737c2 | 33 | uint32_t colorH = 0xFFB0B0B0, |
MikamiUitOpen | 0:a2686ef737c2 | 34 | uint32_t backColor = GuiBase::ENUM_BACK) |
MikamiUitOpen | 0:a2686ef737c2 | 35 | : GuiBase(x, y, Font12, 0, backColor, thumbColor), |
MikamiUitOpen | 0:a2686ef737c2 | 36 | L_(length), W_(width), |
MikamiUitOpen | 0:a2686ef737c2 | 37 | SIZE_(thumbSize), COLOR_L_(colorL), COLOR_H_(colorH), |
MikamiUitOpen | 5:9c3ea4d4bc6b | 38 | MIN_(min), MAX_(max), ORIENT_(hv), |
MikamiUitOpen | 6:b8f197b0012c | 39 | labelL(NULL), labelC(NULL), labelR(NULL), |
MikamiUitOpen | 6:b8f197b0012c | 40 | v_(initialValue), active_(true) |
MikamiUitOpen | 6:b8f197b0012c | 41 | { Draw(initialValue); } |
MikamiUitOpen | 6:b8f197b0012c | 42 | |
MikamiUitOpen | 6:b8f197b0012c | 43 | // Constructor with scale value (only horizontal) |
MikamiUitOpen | 6:b8f197b0012c | 44 | SeekBar(uint16_t x, uint16_t y, uint16_t length, |
MikamiUitOpen | 6:b8f197b0012c | 45 | float min, float max, float initialValue, |
MikamiUitOpen | 6:b8f197b0012c | 46 | string left, string center, string right, |
MikamiUitOpen | 6:b8f197b0012c | 47 | uint32_t thumbColor = LCD_COLOR_WHITE, |
MikamiUitOpen | 6:b8f197b0012c | 48 | uint16_t thumbSize = 30, uint16_t width = 4, |
MikamiUitOpen | 6:b8f197b0012c | 49 | uint32_t colorL = LCD_COLOR_LIGHTGRAY, |
MikamiUitOpen | 6:b8f197b0012c | 50 | uint32_t colorH = 0xFFB0B0B0, |
MikamiUitOpen | 6:b8f197b0012c | 51 | uint32_t backColor = GuiBase::ENUM_BACK); |
MikamiUitOpen | 0:a2686ef737c2 | 52 | |
MikamiUitOpen | 0:a2686ef737c2 | 53 | bool Slide(); |
MikamiUitOpen | 0:a2686ef737c2 | 54 | float GetValue() { return v_; } |
MikamiUitOpen | 0:a2686ef737c2 | 55 | int GetIntValue() { return Round(v_); } |
MikamiUitOpen | 9:c379410bda15 | 56 | |
MikamiUitOpen | 5:9c3ea4d4bc6b | 57 | void Activate(); |
MikamiUitOpen | 5:9c3ea4d4bc6b | 58 | void Inactivate(); |
MikamiUitOpen | 9:c379410bda15 | 59 | bool IsActive() { return active_; } |
MikamiUitOpen | 9:c379410bda15 | 60 | |
MikamiUitOpen | 9:c379410bda15 | 61 | bool IsOnThumb(uint16_t &x, uint16_t &y); |
MikamiUitOpen | 9:c379410bda15 | 62 | void Draw(float value, bool fill = false); |
MikamiUitOpen | 9:c379410bda15 | 63 | float ToValue(Point pt); |
MikamiUitOpen | 9:c379410bda15 | 64 | |
MikamiUitOpen | 9:c379410bda15 | 65 | void SetValue(float v) { v_ = v; } |
MikamiUitOpen | 9:c379410bda15 | 66 | void SetSlided(bool tf) { slided_ = tf; } |
MikamiUitOpen | 9:c379410bda15 | 67 | bool GetSlided() { return slided_; } |
MikamiUitOpen | 9:c379410bda15 | 68 | |
MikamiUitOpen | 9:c379410bda15 | 69 | int Round(float x) { return x + 0.5f - (x < 0); } // Round up on 5 |
MikamiUitOpen | 0:a2686ef737c2 | 70 | |
MikamiUitOpen | 0:a2686ef737c2 | 71 | private: |
MikamiUitOpen | 0:a2686ef737c2 | 72 | const uint16_t L_, W_; |
MikamiUitOpen | 0:a2686ef737c2 | 73 | const uint16_t SIZE_; // Size of thumb |
MikamiUitOpen | 0:a2686ef737c2 | 74 | const uint32_t COLOR_L_, COLOR_H_; |
MikamiUitOpen | 0:a2686ef737c2 | 75 | const float MIN_, MAX_; |
MikamiUitOpen | 0:a2686ef737c2 | 76 | const Orientation ORIENT_; |
MikamiUitOpen | 0:a2686ef737c2 | 77 | |
MikamiUitOpen | 6:b8f197b0012c | 78 | Label *labelL, *labelC, *labelR; |
MikamiUitOpen | 0:a2686ef737c2 | 79 | float v_; // value of seekbar |
MikamiUitOpen | 0:a2686ef737c2 | 80 | bool slided_; |
MikamiUitOpen | 5:9c3ea4d4bc6b | 81 | bool active_; |
MikamiUitOpen | 0:a2686ef737c2 | 82 | |
MikamiUitOpen | 0:a2686ef737c2 | 83 | Point ToPoint(float value); |
MikamiUitOpen | 0:a2686ef737c2 | 84 | float Saturate(float value); |
MikamiUitOpen | 0:a2686ef737c2 | 85 | |
MikamiUitOpen | 0:a2686ef737c2 | 86 | // disallow copy constructor and assignment operator |
MikamiUitOpen | 0:a2686ef737c2 | 87 | SeekBar(const SeekBar&); |
MikamiUitOpen | 0:a2686ef737c2 | 88 | SeekBar& operator=(const SeekBar&); |
MikamiUitOpen | 0:a2686ef737c2 | 89 | }; |
MikamiUitOpen | 0:a2686ef737c2 | 90 | } |
MikamiUitOpen | 0:a2686ef737c2 | 91 | #endif // F746_SEEKBAR_HPP |