GUI parts for DISCO-F746NG. GuiBase, Button, ButtonGroup, ResetButton, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup
Dependencies: Array_Matrix BSP_DISCO_F746NG
Fork of F746_GUI by
SeekbarGroup.cpp@34:b670891b3114, 2018-03-09 (annotated)
- Committer:
- no111u3
- Date:
- Fri Mar 09 15:10:31 2018 +0000
- Revision:
- 34:b670891b3114
- Parent:
- 28:e2b7ea78b7a0
Updates for compile.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 11:7debdaa7b503 | 1 | //----------------------------------------------------------- |
MikamiUitOpen | 11:7debdaa7b503 | 2 | // SeekbarGroup class |
MikamiUitOpen | 11:7debdaa7b503 | 3 | // |
MikamiUitOpen | 28:e2b7ea78b7a0 | 4 | // 2017/01/25, Copyright (c) 2017 MIKAMI, Naoki |
MikamiUitOpen | 11:7debdaa7b503 | 5 | //----------------------------------------------------------- |
MikamiUitOpen | 11:7debdaa7b503 | 6 | |
MikamiUitOpen | 11:7debdaa7b503 | 7 | #include "SeekbarGroup.hpp" |
MikamiUitOpen | 11:7debdaa7b503 | 8 | |
MikamiUitOpen | 11:7debdaa7b503 | 9 | namespace Mikami |
MikamiUitOpen | 11:7debdaa7b503 | 10 | { |
MikamiUitOpen | 11:7debdaa7b503 | 11 | SeekbarGroup::SeekbarGroup( |
MikamiUitOpen | 11:7debdaa7b503 | 12 | uint16_t x0, uint16_t y0, uint16_t length, |
MikamiUitOpen | 11:7debdaa7b503 | 13 | uint16_t number, uint16_t space, |
MikamiUitOpen | 11:7debdaa7b503 | 14 | float min, float max, float initialValue, |
MikamiUitOpen | 11:7debdaa7b503 | 15 | SeekBar::Orientation hv, |
MikamiUitOpen | 28:e2b7ea78b7a0 | 16 | uint32_t thumbColor, uint16_t thumbSize, uint16_t width, |
MikamiUitOpen | 28:e2b7ea78b7a0 | 17 | uint32_t colorL, uint32_t colorH, uint32_t backColor) |
MikamiUitOpen | 28:e2b7ea78b7a0 | 18 | : NUMBER_(number) |
MikamiUitOpen | 11:7debdaa7b503 | 19 | { |
MikamiUitOpen | 28:e2b7ea78b7a0 | 20 | seekBars_.SetSize(number); |
MikamiUitOpen | 11:7debdaa7b503 | 21 | for (int n=0; n<number; n++) |
MikamiUitOpen | 11:7debdaa7b503 | 22 | { |
MikamiUitOpen | 11:7debdaa7b503 | 23 | uint16_t x = x0; |
MikamiUitOpen | 11:7debdaa7b503 | 24 | uint16_t y = y0; |
MikamiUitOpen | 11:7debdaa7b503 | 25 | if (hv == SeekBar::Holizontal) y += space*n; |
MikamiUitOpen | 11:7debdaa7b503 | 26 | else x += space*n; |
MikamiUitOpen | 11:7debdaa7b503 | 27 | seekBars_[n] = |
MikamiUitOpen | 11:7debdaa7b503 | 28 | new SeekBar(x, y, length, min, max, initialValue, hv, |
MikamiUitOpen | 11:7debdaa7b503 | 29 | thumbColor, thumbSize, width, |
MikamiUitOpen | 11:7debdaa7b503 | 30 | colorL, colorH, backColor); |
MikamiUitOpen | 11:7debdaa7b503 | 31 | } |
MikamiUitOpen | 11:7debdaa7b503 | 32 | } |
MikamiUitOpen | 11:7debdaa7b503 | 33 | |
MikamiUitOpen | 11:7debdaa7b503 | 34 | // Get slided number |
MikamiUitOpen | 11:7debdaa7b503 | 35 | bool SeekbarGroup::GetSlidedNumber(int &num) |
MikamiUitOpen | 11:7debdaa7b503 | 36 | { |
MikamiUitOpen | 11:7debdaa7b503 | 37 | bool active = false; |
MikamiUitOpen | 28:e2b7ea78b7a0 | 38 | for (int n=0; n<NUMBER_; n++) |
MikamiUitOpen | 11:7debdaa7b503 | 39 | if (seekBars_[n]->IsActive()) active = true; |
MikamiUitOpen | 11:7debdaa7b503 | 40 | if (!active) return false; |
MikamiUitOpen | 11:7debdaa7b503 | 41 | |
MikamiUitOpen | 28:e2b7ea78b7a0 | 42 | if (!GuiBase::PanelTouched()) |
MikamiUitOpen | 11:7debdaa7b503 | 43 | { |
MikamiUitOpen | 28:e2b7ea78b7a0 | 44 | for (int n=0; n<NUMBER_; n++) |
MikamiUitOpen | 11:7debdaa7b503 | 45 | { |
MikamiUitOpen | 11:7debdaa7b503 | 46 | if (seekBars_[n]->GetSlided()) |
MikamiUitOpen | 11:7debdaa7b503 | 47 | seekBars_[n]->Draw(seekBars_[n]->GetValue()); |
MikamiUitOpen | 11:7debdaa7b503 | 48 | seekBars_[n]->SetSlided(false); |
MikamiUitOpen | 11:7debdaa7b503 | 49 | } |
MikamiUitOpen | 11:7debdaa7b503 | 50 | return false; |
MikamiUitOpen | 11:7debdaa7b503 | 51 | } |
MikamiUitOpen | 11:7debdaa7b503 | 52 | |
MikamiUitOpen | 11:7debdaa7b503 | 53 | bool rtn = false; |
MikamiUitOpen | 11:7debdaa7b503 | 54 | uint16_t x, y; |
MikamiUitOpen | 28:e2b7ea78b7a0 | 55 | for (int n=0; n<NUMBER_; n++) |
MikamiUitOpen | 11:7debdaa7b503 | 56 | { |
MikamiUitOpen | 11:7debdaa7b503 | 57 | if (seekBars_[n]->IsOnThumb(x, y)) |
MikamiUitOpen | 11:7debdaa7b503 | 58 | { |
MikamiUitOpen | 11:7debdaa7b503 | 59 | if ((num != n) && Range(num)) |
MikamiUitOpen | 11:7debdaa7b503 | 60 | seekBars_[num]->Draw(seekBars_[num]->GetValue()); |
MikamiUitOpen | 11:7debdaa7b503 | 61 | num = n; |
MikamiUitOpen | 11:7debdaa7b503 | 62 | seekBars_[n]->SetValue(seekBars_[n]->ToValue(SeekBar::Point(x, y))); |
MikamiUitOpen | 11:7debdaa7b503 | 63 | seekBars_[n]->Draw(seekBars_[n]->GetValue(), true); |
MikamiUitOpen | 11:7debdaa7b503 | 64 | seekBars_[n]->SetSlided(true); |
MikamiUitOpen | 11:7debdaa7b503 | 65 | rtn = true; |
MikamiUitOpen | 11:7debdaa7b503 | 66 | } |
MikamiUitOpen | 12:687ec6183385 | 67 | if (rtn) break; |
MikamiUitOpen | 11:7debdaa7b503 | 68 | } |
MikamiUitOpen | 11:7debdaa7b503 | 69 | return rtn; |
MikamiUitOpen | 11:7debdaa7b503 | 70 | } |
MikamiUitOpen | 11:7debdaa7b503 | 71 | } |
MikamiUitOpen | 28:e2b7ea78b7a0 | 72 |