Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Array_Matrix BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
Fork of F746_GUI by
SeekBarGroup.cpp@9:c379410bda15, 2016-04-24 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sun Apr 24 11:49:42 2016 +0000
- Revision:
- 9:c379410bda15
- Child:
- 10:5a2068884fd9
10
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| MikamiUitOpen | 9:c379410bda15 | 1 | //----------------------------------------------------------- |
| MikamiUitOpen | 9:c379410bda15 | 2 | // SeekBarGroup class |
| MikamiUitOpen | 9:c379410bda15 | 3 | // |
| MikamiUitOpen | 9:c379410bda15 | 4 | // 2016/04/24, Copyright (c) 2016 MIKAMI, Naoki |
| MikamiUitOpen | 9:c379410bda15 | 5 | //----------------------------------------------------------- |
| MikamiUitOpen | 9:c379410bda15 | 6 | |
| MikamiUitOpen | 9:c379410bda15 | 7 | #include "SeekBarGroup.hpp" |
| MikamiUitOpen | 9:c379410bda15 | 8 | |
| MikamiUitOpen | 9:c379410bda15 | 9 | namespace Mikami |
| MikamiUitOpen | 9:c379410bda15 | 10 | { |
| MikamiUitOpen | 9:c379410bda15 | 11 | SeekbarGroup::SeekbarGroup( |
| MikamiUitOpen | 9:c379410bda15 | 12 | uint16_t x0, uint16_t y0, uint16_t length, |
| MikamiUitOpen | 9:c379410bda15 | 13 | uint16_t number, uint16_t space, |
| MikamiUitOpen | 9:c379410bda15 | 14 | float min, float max, float initialValue, |
| MikamiUitOpen | 9:c379410bda15 | 15 | SeekBar::Orientation hv, |
| MikamiUitOpen | 9:c379410bda15 | 16 | uint32_t thumbColor, |
| MikamiUitOpen | 9:c379410bda15 | 17 | uint16_t thumbSize, uint16_t width, |
| MikamiUitOpen | 9:c379410bda15 | 18 | uint32_t colorL, uint32_t colorH, |
| MikamiUitOpen | 9:c379410bda15 | 19 | uint32_t backColor) |
| MikamiUitOpen | 9:c379410bda15 | 20 | : GuiBase(x0, y0, Font12, GuiBase::ENUM_TEXT, backColor, thumbColor), |
| MikamiUitOpen | 9:c379410bda15 | 21 | numberOfSeekBar_(number) |
| MikamiUitOpen | 9:c379410bda15 | 22 | { |
| MikamiUitOpen | 9:c379410bda15 | 23 | seekBars_ = new SeekBar *[number]; |
| MikamiUitOpen | 9:c379410bda15 | 24 | for (int n=0; n<number; n++) |
| MikamiUitOpen | 9:c379410bda15 | 25 | { |
| MikamiUitOpen | 9:c379410bda15 | 26 | uint16_t x = x0; |
| MikamiUitOpen | 9:c379410bda15 | 27 | uint16_t y = y0; |
| MikamiUitOpen | 9:c379410bda15 | 28 | if (hv == SeekBar::Holizontal) y += space*n; |
| MikamiUitOpen | 9:c379410bda15 | 29 | else x += space*n; |
| MikamiUitOpen | 9:c379410bda15 | 30 | seekBars_[n] = |
| MikamiUitOpen | 9:c379410bda15 | 31 | new SeekBar(x, y, length, min, max, initialValue, hv, |
| MikamiUitOpen | 9:c379410bda15 | 32 | thumbColor, thumbSize, width, |
| MikamiUitOpen | 9:c379410bda15 | 33 | colorL, colorH, backColor); |
| MikamiUitOpen | 9:c379410bda15 | 34 | } |
| MikamiUitOpen | 9:c379410bda15 | 35 | } |
| MikamiUitOpen | 9:c379410bda15 | 36 | |
| MikamiUitOpen | 9:c379410bda15 | 37 | // Destructor |
| MikamiUitOpen | 9:c379410bda15 | 38 | SeekbarGroup::~SeekbarGroup() |
| MikamiUitOpen | 9:c379410bda15 | 39 | { |
| MikamiUitOpen | 9:c379410bda15 | 40 | for (int n=0; n<numberOfSeekBar_; n++) delete seekBars_[n]; |
| MikamiUitOpen | 9:c379410bda15 | 41 | delete[] *seekBars_; |
| MikamiUitOpen | 9:c379410bda15 | 42 | } |
| MikamiUitOpen | 9:c379410bda15 | 43 | |
| MikamiUitOpen | 9:c379410bda15 | 44 | // Get slided number |
| MikamiUitOpen | 9:c379410bda15 | 45 | bool SeekbarGroup::GetSlidedNumber(int &num) |
| MikamiUitOpen | 9:c379410bda15 | 46 | { |
| MikamiUitOpen | 9:c379410bda15 | 47 | bool active = false; |
| MikamiUitOpen | 9:c379410bda15 | 48 | for (int n=0; n<numberOfSeekBar_; n++) |
| MikamiUitOpen | 9:c379410bda15 | 49 | if (seekBars_[n]->IsActive()) active = true; |
| MikamiUitOpen | 9:c379410bda15 | 50 | if (!active) return false; |
| MikamiUitOpen | 9:c379410bda15 | 51 | |
| MikamiUitOpen | 9:c379410bda15 | 52 | if (!PanelTouched()) |
| MikamiUitOpen | 9:c379410bda15 | 53 | { |
| MikamiUitOpen | 9:c379410bda15 | 54 | for (int n=0; n<numberOfSeekBar_; n++) |
| MikamiUitOpen | 9:c379410bda15 | 55 | { |
| MikamiUitOpen | 9:c379410bda15 | 56 | if (seekBars_[n]->GetSlided()) |
| MikamiUitOpen | 9:c379410bda15 | 57 | seekBars_[n]->Draw(seekBars_[n]->GetValue()); |
| MikamiUitOpen | 9:c379410bda15 | 58 | seekBars_[n]->SetSlided(false); |
| MikamiUitOpen | 9:c379410bda15 | 59 | } |
| MikamiUitOpen | 9:c379410bda15 | 60 | return false; |
| MikamiUitOpen | 9:c379410bda15 | 61 | } |
| MikamiUitOpen | 9:c379410bda15 | 62 | |
| MikamiUitOpen | 9:c379410bda15 | 63 | bool rtn = false; |
| MikamiUitOpen | 9:c379410bda15 | 64 | uint16_t x, y; |
| MikamiUitOpen | 9:c379410bda15 | 65 | for (int n=0; n<numberOfSeekBar_; n++) |
| MikamiUitOpen | 9:c379410bda15 | 66 | { |
| MikamiUitOpen | 9:c379410bda15 | 67 | if (seekBars_[n]->IsOnThumb(x, y)) |
| MikamiUitOpen | 9:c379410bda15 | 68 | { |
| MikamiUitOpen | 9:c379410bda15 | 69 | num = n; |
| MikamiUitOpen | 9:c379410bda15 | 70 | seekBars_[n]->SetValue(seekBars_[n]->ToValue(SeekBar::Point(x, y))); |
| MikamiUitOpen | 9:c379410bda15 | 71 | seekBars_[n]->Draw(seekBars_[n]->GetValue(), true); |
| MikamiUitOpen | 9:c379410bda15 | 72 | seekBars_[n]->SetSlided(true); |
| MikamiUitOpen | 9:c379410bda15 | 73 | rtn = true; |
| MikamiUitOpen | 9:c379410bda15 | 74 | } |
| MikamiUitOpen | 9:c379410bda15 | 75 | } |
| MikamiUitOpen | 9:c379410bda15 | 76 | return rtn; |
| MikamiUitOpen | 9:c379410bda15 | 77 | } |
| MikamiUitOpen | 9:c379410bda15 | 78 | } |
