Repository for import to local machine
Dependencies: DMBasicGUI DMSupport
ProgressBar.h@8:26e49e6955bd, 2017-07-31 (annotated)
- Committer:
- jmitc91516
- Date:
- Mon Jul 31 15:37:57 2017 +0000
- Revision:
- 8:26e49e6955bd
- Parent:
- 1:a5258871b33d
Method ramp scrolling improved, and more bitmaps moved to QSPI memory
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmitc91516 | 1:a5258871b33d | 1 | #ifndef PROGRESSBAR_H |
jmitc91516 | 1:a5258871b33d | 2 | #define PROGRESSBAR_H |
jmitc91516 | 1:a5258871b33d | 3 | |
jmitc91516 | 1:a5258871b33d | 4 | #include "GuiLib.h" |
jmitc91516 | 1:a5258871b33d | 5 | #include "GuiDisplay.h" |
jmitc91516 | 1:a5258871b33d | 6 | |
jmitc91516 | 1:a5258871b33d | 7 | |
jmitc91516 | 1:a5258871b33d | 8 | typedef enum { vertical, horizontal } progressBarOrientation; |
jmitc91516 | 1:a5258871b33d | 9 | |
jmitc91516 | 1:a5258871b33d | 10 | class ProgressBar |
jmitc91516 | 1:a5258871b33d | 11 | { |
jmitc91516 | 1:a5258871b33d | 12 | public: |
jmitc91516 | 1:a5258871b33d | 13 | ProgressBar(); |
jmitc91516 | 1:a5258871b33d | 14 | ProgressBar(int x, int y, int w, int h, progressBarOrientation o, double newCalibratedRange, GuiConst_INTCOLOR brColor, GuiConst_INTCOLOR bkColor, GuiConst_INTCOLOR brdColor); |
jmitc91516 | 1:a5258871b33d | 15 | |
jmitc91516 | 1:a5258871b33d | 16 | progressBarOrientation GetOrientation(void) { return orientation; } |
jmitc91516 | 1:a5258871b33d | 17 | |
jmitc91516 | 1:a5258871b33d | 18 | void UpdateCalibratedPosition(double newCalibratedPosition, bool forceFullDisplay); |
jmitc91516 | 1:a5258871b33d | 19 | |
jmitc91516 | 1:a5258871b33d | 20 | double GetCalibratedPosition(void) { return (barPosition * calibrationFactor); } |
jmitc91516 | 1:a5258871b33d | 21 | |
jmitc91516 | 1:a5258871b33d | 22 | void SetCalibratedRange(double newCalibratedRange); |
jmitc91516 | 1:a5258871b33d | 23 | double GetCalibratedRange(void) { return calibratedRange; } |
jmitc91516 | 1:a5258871b33d | 24 | |
jmitc91516 | 1:a5258871b33d | 25 | void DisplayBarComplete(bool forceFullDisplay); |
jmitc91516 | 1:a5258871b33d | 26 | |
jmitc91516 | 1:a5258871b33d | 27 | private: |
jmitc91516 | 1:a5258871b33d | 28 | int barX, barY; // This is the top left corner, in both orientations. |
jmitc91516 | 1:a5258871b33d | 29 | int barW, barH; // The width and height. |
jmitc91516 | 1:a5258871b33d | 30 | // The above apply to the (fixed) box containing the slider bar, not to the bar itself. |
jmitc91516 | 1:a5258871b33d | 31 | |
jmitc91516 | 1:a5258871b33d | 32 | GuiConst_INTCOLOR barColor; |
jmitc91516 | 1:a5258871b33d | 33 | GuiConst_INTCOLOR backColor; |
jmitc91516 | 1:a5258871b33d | 34 | GuiConst_INTCOLOR borderColor; |
jmitc91516 | 1:a5258871b33d | 35 | |
jmitc91516 | 1:a5258871b33d | 36 | progressBarOrientation orientation; |
jmitc91516 | 1:a5258871b33d | 37 | |
jmitc91516 | 1:a5258871b33d | 38 | int barPosition; // The RH end of the bar (horizontal), or top of the bar (vertical) - in display units (i.e. pixels) |
jmitc91516 | 1:a5258871b33d | 39 | // ** relative to the bottom (vertical) or left hand end (horizontal) of the bar as zero ** |
jmitc91516 | 1:a5258871b33d | 40 | int previousBarPositionDisplayed; // -1 if we have not yet displayed the bar |
jmitc91516 | 1:a5258871b33d | 41 | |
jmitc91516 | 1:a5258871b33d | 42 | double calibratedRange; |
jmitc91516 | 1:a5258871b33d | 43 | double calibrationFactor; // calibratedPosition = (barPosition * calibrationFactor), |
jmitc91516 | 1:a5258871b33d | 44 | // which is equivalent to: calibrationFactor = (calibratedRange / barW) |
jmitc91516 | 1:a5258871b33d | 45 | |
jmitc91516 | 1:a5258871b33d | 46 | void DisplayNewPosition(void); |
jmitc91516 | 1:a5258871b33d | 47 | |
jmitc91516 | 1:a5258871b33d | 48 | void DisplayFullBar(void); |
jmitc91516 | 1:a5258871b33d | 49 | void DisplayBarChangeOnly(void); |
jmitc91516 | 1:a5258871b33d | 50 | |
jmitc91516 | 1:a5258871b33d | 51 | // If this is false, we do not fill the background (at all) when we (re)draw the bar. |
jmitc91516 | 1:a5258871b33d | 52 | // This is an advantage when we are using a bitmap as the background - |
jmitc91516 | 1:a5258871b33d | 53 | // we do not have to redraw parts of the bitmap. |
jmitc91516 | 1:a5258871b33d | 54 | // *** This is OK as long as the bar always increases in length (which it should do, *** |
jmitc91516 | 1:a5258871b33d | 55 | // *** for a progress bar, unless the process we are representing somehow goes backwards). *** |
jmitc91516 | 1:a5258871b33d | 56 | bool fillBackground; |
jmitc91516 | 1:a5258871b33d | 57 | }; |
jmitc91516 | 1:a5258871b33d | 58 | |
jmitc91516 | 1:a5258871b33d | 59 | #endif // PROGRESSBAR_H |