summaryrefslogtreecommitdiffstats
path: root/ui.h
diff options
context:
space:
mode:
Diffstat (limited to 'ui.h')
-rw-r--r--ui.h38
1 files changed, 29 insertions, 9 deletions
diff --git a/ui.h b/ui.h
index 82d95a346..823eb6574 100644
--- a/ui.h
+++ b/ui.h
@@ -21,6 +21,8 @@
#include <pthread.h>
#include <time.h>
+#include <string>
+
// Abstract class for controlling the user interface during recovery.
class RecoveryUI {
public:
@@ -28,14 +30,13 @@ class RecoveryUI {
virtual ~RecoveryUI() { }
- // Initialize the object; called before anything else.
- virtual void Init();
+ // Initialize the object; called before anything else. UI texts will be
+ // initialized according to the given locale. Returns true on success.
+ virtual bool Init(const std::string& locale);
+
// Show a stage indicator. Call immediately after Init().
virtual void SetStage(int current, int max) = 0;
- // After calling Init(), you can tell the UI what locale it is operating in.
- virtual void SetLocale(const char* locale) = 0;
-
// Set the overall recovery state ("background image").
enum Icon { NONE, INSTALLING_UPDATE, ERASING, NO_COMMAND, ERROR };
virtual void SetBackground(Icon icon) = 0;
@@ -122,10 +123,21 @@ class RecoveryUI {
// statements will be displayed.
virtual void EndMenu() = 0;
-protected:
+ protected:
void EnqueueKey(int key_code);
-private:
+ // The locale that's used to show the rendered texts.
+ std::string locale_;
+ bool rtl_locale_;
+
+ // The normal and dimmed brightness percentages (default: 50 and 25, which means 50% and 25%
+ // of the max_brightness). Because the absolute values may vary across devices. These two
+ // values can be configured via subclassing. Setting brightness_normal_ to 0 to disable
+ // screensaver.
+ unsigned int brightness_normal_;
+ unsigned int brightness_dimmed_;
+
+ private:
// Key event input queue
pthread_mutex_t key_queue_mutex;
pthread_cond_t key_queue_cond;
@@ -153,8 +165,6 @@ private:
pthread_t input_thread_;
void OnKeyDetected(int key_code);
-
- static int InputCallback(int fd, uint32_t epevents, void* data);
int OnInputEvent(int fd, uint32_t epevents);
void ProcessKey(int key_code, int updown);
@@ -162,6 +172,16 @@ private:
static void* time_key_helper(void* cookie);
void time_key(int key_code, int count);
+
+ void SetLocale(const std::string&);
+
+ enum class ScreensaverState { DISABLED, NORMAL, DIMMED, OFF };
+ ScreensaverState screensaver_state_;
+ // The following two contain the absolute values computed from brightness_normal_ and
+ // brightness_dimmed_ respectively.
+ unsigned int brightness_normal_value_;
+ unsigned int brightness_dimmed_value_;
+ bool InitScreensaver();
};
#endif // RECOVERY_UI_H