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
Revision 5:9c3ea4d4bc6b, committed 2016-04-10
- Comitter:
- MikamiUitOpen
- Date:
- Sun Apr 10 09:25:36 2016 +0000
- Parent:
- 4:cbf7ed9092a3
- Child:
- 6:b8f197b0012c
- Commit message:
- 6
Changed in this revision
| SeekBar.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SeekBar.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SeekBar.cpp Fri Apr 08 09:32:49 2016 +0000
+++ b/SeekBar.cpp Sun Apr 10 09:25:36 2016 +0000
@@ -1,7 +1,7 @@
//-----------------------------------------------------------
// SeekBar class
//
-// 2016/03/29, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/04/10, Copyright (c) 2016 MIKAMI, Naoki
//-----------------------------------------------------------
#include "SeekBar.hpp"
@@ -12,6 +12,8 @@
// If the thumb is not touched, return false
bool SeekBar::Slide()
{
+ if (!active_) return false;
+
if (!PanelTouched())
{
if (slided_) Draw(v_);
@@ -30,6 +32,18 @@
return rtn;
}
+
+ void SeekBar::Activate()
+ {
+ active_ = true;
+ Draw(v_);
+ }
+
+ void SeekBar::Inactivate()
+ {
+ active_ = false;
+ Draw(v_);
+ }
// Draw seekbar
void SeekBar::Draw(float value, bool fill)
@@ -40,25 +54,28 @@
lcd_.FillRect(X_-SIZE_/2, Y_-SIZE_/2, L_+SIZE_+1, SIZE_+1);
else
lcd_.FillRect(X_-SIZE_/2, Y_-SIZE_/2, SIZE_+1, L_+SIZE_+1);
-
+
Point pt = ToPoint(Saturate(value)); // Position of thumb
// Draw upper line
- lcd_.SetTextColor(COLOR_H_);
+ if (active_) lcd_.SetTextColor(COLOR_H_);
+ else lcd_.SetTextColor(INACTIVE_TEXT_COLOR_-0x404040);
if (ORIENT_ == Holizontal)
lcd_.FillRect(pt.x, Y_-W_/4, X_+L_-pt.x, W_/2);
else
lcd_.FillRect(X_-W_/4, Y_, W_/2, pt.y-Y_);
// Draw lower line
- lcd_.SetTextColor(COLOR_L_);
+ if (active_) lcd_.SetTextColor(COLOR_L_);
+ else lcd_.SetTextColor(INACTIVE_TEXT_COLOR_-0x202020);
if ((ORIENT_ == Holizontal) && ((pt.x-X_) > 0))
lcd_.FillRect(X_, Y_-W_/2, pt.x-X_, W_);
if ((ORIENT_ == Vertical) && ((Y_+L_-pt.y) > 0))
lcd_.FillRect(X_-W_/2, pt.y, W_, Y_+L_-pt.y);
// Draw thumb
- lcd_.SetTextColor(CREATED_COLOR_);
+ if (active_) lcd_.SetTextColor(CREATED_COLOR_);
+ else lcd_.SetTextColor(INACTIVE_TEXT_COLOR_);
if (fill)
lcd_.FillCircle(pt.x, pt.y, SIZE_/2);
else
@@ -111,3 +128,4 @@
return value;
}
}
+
--- a/SeekBar.hpp Fri Apr 08 09:32:49 2016 +0000
+++ b/SeekBar.hpp Sun Apr 10 09:25:36 2016 +0000
@@ -1,7 +1,7 @@
//-----------------------------------------------------------
// SeekBar class -- Header
//
-// 2016/03/29, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/04/10, Copyright (c) 2016 MIKAMI, Naoki
//-----------------------------------------------------------
#ifndef F746_SEEKBAR_HPP
@@ -28,12 +28,15 @@
: GuiBase(x, y, Font12, 0, backColor, thumbColor),
L_(length), W_(width),
SIZE_(thumbSize), COLOR_L_(colorL), COLOR_H_(colorH),
- MIN_(min), MAX_(max), ORIENT_(hv), v_(value)
+ MIN_(min), MAX_(max), ORIENT_(hv),
+ v_(value), active_(true)
{ Draw(value); }
bool Slide();
float GetValue() { return v_; }
int GetIntValue() { return Round(v_); }
+ void Activate();
+ void Inactivate();
private:
struct Point
@@ -50,6 +53,7 @@
float v_; // value of seekbar
bool slided_;
+ bool active_;
void Draw(float value, bool fill = false);
bool IsOnThumb(uint16_t &x, uint16_t &y);
