GUI parts for DISCO-F469I a fork of DISCO-F746NG. GuiBase, Button, ButtonGroup, ResetButton, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup
Dependents: DISCO-F469NI_LCDTS_GUI_demo DISCO-F469NI_LCDTS_GUI_demo projekt_PSW_v1 DISCO-F469NI_LCDTS_GUI_demoaaaaaaaaaxxxx ... more
Fork of F746_GUI by
SeekBar.hpp@5:9c3ea4d4bc6b, 2016-04-10 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sun Apr 10 09:25:36 2016 +0000
- Revision:
- 5:9c3ea4d4bc6b
- Parent:
- 0:a2686ef737c2
- Child:
- 6:b8f197b0012c
6
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 | 5:9c3ea4d4bc6b | 4 | // 2016/04/10, 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 | 0:a2686ef737c2 | 11 | |
MikamiUitOpen | 0:a2686ef737c2 | 12 | namespace Mikami |
MikamiUitOpen | 0:a2686ef737c2 | 13 | { |
MikamiUitOpen | 0:a2686ef737c2 | 14 | class SeekBar : public GuiBase |
MikamiUitOpen | 0:a2686ef737c2 | 15 | { |
MikamiUitOpen | 0:a2686ef737c2 | 16 | public: |
MikamiUitOpen | 0:a2686ef737c2 | 17 | enum Orientation { Holizontal, Vertical }; |
MikamiUitOpen | 0:a2686ef737c2 | 18 | |
MikamiUitOpen | 0:a2686ef737c2 | 19 | // Constructor |
MikamiUitOpen | 0:a2686ef737c2 | 20 | SeekBar(uint16_t x, uint16_t y, uint16_t length, |
MikamiUitOpen | 0:a2686ef737c2 | 21 | float min, float max, float value, |
MikamiUitOpen | 0:a2686ef737c2 | 22 | Orientation hv = Holizontal, |
MikamiUitOpen | 0:a2686ef737c2 | 23 | uint32_t thumbColor = LCD_COLOR_WHITE, |
MikamiUitOpen | 0:a2686ef737c2 | 24 | uint16_t thumbSize = 30, uint16_t width = 4, |
MikamiUitOpen | 0:a2686ef737c2 | 25 | uint32_t colorL = LCD_COLOR_LIGHTGRAY, |
MikamiUitOpen | 0:a2686ef737c2 | 26 | uint32_t colorH = 0xFFB0B0B0, |
MikamiUitOpen | 0:a2686ef737c2 | 27 | uint32_t backColor = GuiBase::ENUM_BACK) |
MikamiUitOpen | 0:a2686ef737c2 | 28 | : GuiBase(x, y, Font12, 0, backColor, thumbColor), |
MikamiUitOpen | 0:a2686ef737c2 | 29 | L_(length), W_(width), |
MikamiUitOpen | 0:a2686ef737c2 | 30 | SIZE_(thumbSize), COLOR_L_(colorL), COLOR_H_(colorH), |
MikamiUitOpen | 5:9c3ea4d4bc6b | 31 | MIN_(min), MAX_(max), ORIENT_(hv), |
MikamiUitOpen | 5:9c3ea4d4bc6b | 32 | v_(value), active_(true) |
MikamiUitOpen | 0:a2686ef737c2 | 33 | { Draw(value); } |
MikamiUitOpen | 0:a2686ef737c2 | 34 | |
MikamiUitOpen | 0:a2686ef737c2 | 35 | bool Slide(); |
MikamiUitOpen | 0:a2686ef737c2 | 36 | float GetValue() { return v_; } |
MikamiUitOpen | 0:a2686ef737c2 | 37 | int GetIntValue() { return Round(v_); } |
MikamiUitOpen | 5:9c3ea4d4bc6b | 38 | void Activate(); |
MikamiUitOpen | 5:9c3ea4d4bc6b | 39 | void Inactivate(); |
MikamiUitOpen | 0:a2686ef737c2 | 40 | |
MikamiUitOpen | 0:a2686ef737c2 | 41 | private: |
MikamiUitOpen | 0:a2686ef737c2 | 42 | struct Point |
MikamiUitOpen | 0:a2686ef737c2 | 43 | { |
MikamiUitOpen | 0:a2686ef737c2 | 44 | uint16_t x, y; |
MikamiUitOpen | 0:a2686ef737c2 | 45 | Point(uint16_t x0 = 0, uint16_t y0 = 0) : x(x0), y(y0) {} |
MikamiUitOpen | 0:a2686ef737c2 | 46 | }; |
MikamiUitOpen | 0:a2686ef737c2 | 47 | |
MikamiUitOpen | 0:a2686ef737c2 | 48 | const uint16_t L_, W_; |
MikamiUitOpen | 0:a2686ef737c2 | 49 | const uint16_t SIZE_; // Size of thumb |
MikamiUitOpen | 0:a2686ef737c2 | 50 | const uint32_t COLOR_L_, COLOR_H_; |
MikamiUitOpen | 0:a2686ef737c2 | 51 | const float MIN_, MAX_; |
MikamiUitOpen | 0:a2686ef737c2 | 52 | const Orientation ORIENT_; |
MikamiUitOpen | 0:a2686ef737c2 | 53 | |
MikamiUitOpen | 0:a2686ef737c2 | 54 | float v_; // value of seekbar |
MikamiUitOpen | 0:a2686ef737c2 | 55 | bool slided_; |
MikamiUitOpen | 5:9c3ea4d4bc6b | 56 | bool active_; |
MikamiUitOpen | 0:a2686ef737c2 | 57 | |
MikamiUitOpen | 0:a2686ef737c2 | 58 | void Draw(float value, bool fill = false); |
MikamiUitOpen | 0:a2686ef737c2 | 59 | bool IsOnThumb(uint16_t &x, uint16_t &y); |
MikamiUitOpen | 0:a2686ef737c2 | 60 | Point ToPoint(float value); |
MikamiUitOpen | 0:a2686ef737c2 | 61 | float ToValue(Point pt); |
MikamiUitOpen | 0:a2686ef737c2 | 62 | int Round(float x) { return x + 0.5f - (x < 0); } // Round up on 5 |
MikamiUitOpen | 0:a2686ef737c2 | 63 | float Saturate(float value); |
MikamiUitOpen | 0:a2686ef737c2 | 64 | |
MikamiUitOpen | 0:a2686ef737c2 | 65 | // disallow copy constructor and assignment operator |
MikamiUitOpen | 0:a2686ef737c2 | 66 | SeekBar(const SeekBar&); |
MikamiUitOpen | 0:a2686ef737c2 | 67 | SeekBar& operator=(const SeekBar&); |
MikamiUitOpen | 0:a2686ef737c2 | 68 | }; |
MikamiUitOpen | 0:a2686ef737c2 | 69 | } |
MikamiUitOpen | 0:a2686ef737c2 | 70 | #endif // F746_SEEKBAR_HPP |