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 TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG
SeekBar.hpp
00001 //----------------------------------------------------------- 00002 // SeekBar class -- Header 00003 // 00004 // 2017/01/25, Copyright (c) 2017 MIKAMI, Naoki 00005 //----------------------------------------------------------- 00006 00007 #ifndef F746_SEEKBAR_HPP 00008 #define F746_SEEKBAR_HPP 00009 00010 #include "GuiBase.hpp" 00011 #include "Label.hpp" 00012 00013 namespace Mikami 00014 { 00015 class SeekBar : public GuiBase 00016 { 00017 public: 00018 enum Orientation { Holizontal, Vertical }; 00019 00020 struct Point 00021 { 00022 uint16_t x, y; 00023 Point(uint16_t x0 = 0, uint16_t y0 = 0) : x(x0), y(y0) {} 00024 }; 00025 00026 // Constructor 00027 SeekBar(uint16_t x, uint16_t y, uint16_t length, 00028 float min, float max, float initialValue, 00029 Orientation hv = Holizontal, 00030 uint32_t thumbColor = 0xFFB0B0FF, 00031 uint16_t thumbSize = 30, uint16_t width = 4, 00032 uint32_t colorL = LCD_COLOR_LIGHTGRAY, 00033 uint32_t colorH = 0xFFB0B0B0, 00034 uint32_t backColor = GuiBase::ENUM_BACK) 00035 : GuiBase(x, y, Font12, 0, backColor, thumbColor), 00036 L_(length), W_(width), 00037 SIZE_(thumbSize), COLOR_L_(colorL), COLOR_H_(colorH), 00038 MIN_(min), MAX_(max), ORIENT_(hv), v_(initialValue), 00039 labelOn_(false), slided_(false), active_(true) 00040 { Draw(initialValue); } 00041 00042 // Constructor with scale value (only horizontal) 00043 SeekBar(uint16_t x, uint16_t y, uint16_t length, 00044 float min, float max, float initialValue, 00045 string left, string center, string right, 00046 uint32_t thumbColor = 0xFFB0B0FF, 00047 uint16_t thumbSize = 30, uint16_t width = 4, 00048 uint32_t colorL = LCD_COLOR_LIGHTGRAY, 00049 uint32_t colorH = 0xFFB0B0B0, 00050 uint32_t backColor = GuiBase::ENUM_BACK); 00051 00052 virtual ~SeekBar() 00053 { for (int n=0; n<3; n++) delete labelLCR_[n]; } 00054 00055 bool Slide(); 00056 float GetValue() { return v_; } 00057 int GetIntValue() { return Round(v_); } 00058 00059 void Activate(); 00060 void Inactivate(); 00061 bool IsActive() { return active_; } 00062 00063 bool IsOnThumb(uint16_t &x, uint16_t &y); 00064 void Draw(float value, bool fill = false); 00065 void Redraw(bool fill = false); 00066 float ToValue(Point pt); 00067 00068 void SetValue(float v) { v_ = v; } 00069 void SetSlided(bool tf) { slided_ = tf; } 00070 bool GetSlided() { return slided_; } 00071 00072 private: 00073 const uint16_t L_, W_; 00074 const uint16_t SIZE_; // Size of thumb 00075 const uint32_t COLOR_L_, COLOR_H_; 00076 const float MIN_, MAX_; 00077 const Orientation ORIENT_; 00078 00079 Label *labelLCR_[3]; 00080 float v_; // value of seekbar 00081 bool labelOn_; 00082 bool slided_; 00083 bool active_; 00084 00085 int Round(float x) { return x + 0.5f - (x < 0); } 00086 Point ToPoint(float value); 00087 float Saturate(float value); 00088 00089 // disallow copy constructor and assignment operator 00090 SeekBar(const SeekBar&); 00091 SeekBar& operator=(const SeekBar&); 00092 }; 00093 } 00094 #endif // F746_SEEKBAR_HPP 00095
Generated on Thu Jul 14 2022 07:59:59 by
