GUI parts for DISCO-F746NG. GuiBase, Button, ButtonGroup, Label, BlinkLabel, NumericLabel, SeekBar, SeekbarGroup

Dependents:   F746_SD_GraphicEqualizer_ren0620

Fork of F746_GUI by 不韋 呂

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SeekbarGroup.cpp Source File

SeekbarGroup.cpp

00001 //-----------------------------------------------------------
00002 //  SeekbarGroup class
00003 //
00004 //  2016/04/30, Copyright (c) 2016 MIKAMI, Naoki
00005 //-----------------------------------------------------------
00006 
00007 #include "SeekbarGroup.hpp"
00008 
00009 namespace Mikami
00010 {
00011     SeekbarGroup::SeekbarGroup(
00012             uint16_t x0, uint16_t y0, uint16_t length,
00013             uint16_t number, uint16_t space,
00014             float min, float max, float initialValue,
00015             SeekBar::Orientation hv,
00016             uint32_t thumbColor,
00017             uint16_t thumbSize, uint16_t width,
00018             uint32_t colorL, uint32_t colorH,
00019             uint32_t backColor)
00020         : GuiBase(x0, y0, Font12, GuiBase::ENUM_TEXT, backColor, thumbColor),
00021           numberOfSeekBar_(number)
00022     {
00023         seekBars_ = new SeekBar *[number];
00024         for (int n=0; n<number; n++)
00025         {
00026             uint16_t x = x0;
00027             uint16_t y = y0;
00028             if (hv == SeekBar::Holizontal) y += space*n;
00029             else                           x += space*n;
00030             seekBars_[n] =
00031                 new SeekBar(x, y, length, min, max, initialValue, hv,
00032                             thumbColor, thumbSize, width,
00033                             colorL, colorH, backColor);
00034         }
00035     }
00036 
00037     // Destructor
00038     SeekbarGroup::~SeekbarGroup()
00039     {
00040         for (int n=0; n<numberOfSeekBar_; n++) delete seekBars_[n];
00041         delete[] seekBars_;
00042     }
00043 
00044     // Get slided number
00045     bool SeekbarGroup::GetSlidedNumber(int &num)
00046     {
00047         bool active = false;
00048         for (int n=0; n<numberOfSeekBar_; n++)
00049             if (seekBars_[n]->IsActive()) active = true;
00050         if (!active) return false;
00051 
00052         if (!PanelTouched())
00053         {
00054             for (int n=0; n<numberOfSeekBar_; n++)
00055             {
00056                 if (seekBars_[n]->GetSlided())
00057                     seekBars_[n]->Draw(seekBars_[n]->GetValue());
00058                 seekBars_[n]->SetSlided(false);
00059             }
00060             return false;
00061         }
00062 
00063         bool rtn = false;
00064         uint16_t x, y;
00065         for (int n=0; n<numberOfSeekBar_; n++)
00066         {
00067             if (seekBars_[n]->IsOnThumb(x, y))
00068             {
00069                 if ((num != n) && Range(num))
00070                     seekBars_[num]->Draw(seekBars_[num]->GetValue());
00071                 num = n;
00072                 seekBars_[n]->SetValue(seekBars_[n]->ToValue(SeekBar::Point(x, y)));
00073                 seekBars_[n]->Draw(seekBars_[n]->GetValue(), true);
00074                 seekBars_[n]->SetSlided(true);
00075                 rtn = true;
00076             }
00077             if (rtn) break;
00078         }
00079         return rtn;
00080     }
00081 }