Class library: Button class and ButtonGroup class for DISCO-F746NG. クラスライブラリ: DISCO-F746NG 用の,Button クラス,ButtonGroup クラス.
Dependents: F746_SpectralAnalysis_NoPhoto F746_Fourier_series_of_square_wave_01 F746_ButtonGroup_Demo F746_Mandelbrot ... more
Revision 6:d268555e2f50, committed 2015-12-09
- Comitter:
- MikamiUitOpen
- Date:
- Wed Dec 09 01:55:25 2015 +0000
- Parent:
- 5:2cc388e91bde
- Child:
- 7:6913aebb3905
- Commit message:
- 7
Changed in this revision
button_group.cpp | Show annotated file Show diff for this revision Revisions of this file |
button_group.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/button_group.cpp Tue Dec 08 14:19:41 2015 +0000 +++ b/button_group.cpp Wed Dec 09 01:55:25 2015 +0000 @@ -1,7 +1,7 @@ //----------------------------------------------------------- // Button group class // -// 2015/12/07, Copyright (c) 2015 MIKAMI, Naoki +// 2015/12/09, Copyright (c) 2015 MIKAMI, Naoki //----------------------------------------------------------- #include "button_group.hpp" @@ -50,6 +50,20 @@ return false; } + // Check touch detected for specified button and redraw + bool ButtonGroup::Touched(int num, uint32_t color, + uint32_t textColor) + { + if (buttons_[num]->Touched(color, textColor)) + { + for (int n=0; n<numberOfButtons_; n++) + if (n != num) buttons_[n]->Redraw(); + return true; + } + else + return false; + } + // Get touched number and redraw button if touched bool ButtonGroup::GetTouchedNumber(int &num, uint32_t color) { @@ -59,7 +73,7 @@ if (n == num) buttons_[n]->Draw(color); else - buttons_[n]->Draw(buttons_[n]->GetOriginalColor()); + buttons_[n]->Redraw(); return true; } else
--- a/button_group.hpp Tue Dec 08 14:19:41 2015 +0000 +++ b/button_group.hpp Wed Dec 09 01:55:25 2015 +0000 @@ -1,7 +1,7 @@ //----------------------------------------------------------- // Button group class -- Header // -// 2015/12/05, Copyright (c) 2015 MIKAMI, Naoki +// 2015/12/09, Copyright (c) 2015 MIKAMI, Naoki //----------------------------------------------------------- #ifndef F746_BUTTON_GROUP_HPP @@ -30,11 +30,13 @@ ~ButtonGroup(); // Draw button - void Draw(int num, uint32_t color, uint32_t textColor = LCD_COLOR_WHITE) + void Draw(int num, uint32_t color, + uint32_t textColor = LCD_COLOR_WHITE) { buttons_[num]->Draw(color, textColor); } // Draw all button - void DrawAll(uint32_t color, uint32_t textColor = LCD_COLOR_WHITE) + void DrawAll(uint32_t color, + uint32_t textColor = LCD_COLOR_WHITE) { for (int n=0; n<numberOfButtons_; n++) buttons_[n]->Draw(color, textColor); @@ -42,7 +44,7 @@ // Redraw button with original color void Redraw(int num, uint32_t textColor = LCD_COLOR_WHITE) - { buttons_[num]->Draw(buttons_[num]->GetOriginalColor(), textColor); } + { buttons_[num]->Redraw(textColor); } // Erase button with selected color void Erase(int num, uint32_t color) @@ -52,9 +54,9 @@ bool Touched(int num) { return buttons_[num]->Touched(); } - // Check touch detected for specified button and redraw button - bool Touched(int num, uint32_t color, uint32_t textColor = LCD_COLOR_WHITE) - { return buttons_[num]->Touched(color, textColor); } + // Check touch detected for specified button and redraw + bool Touched(int num, uint32_t color, + uint32_t textColor = LCD_COLOR_WHITE); // Get touched number bool GetTouchedNumber(int &num);