xref: /OK3568_Linux_fs/external/rk_pcba_test/pcba_minui/screen_ui.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef RECOVERY_SCREEN_UI_H
18 #define RECOVERY_SCREEN_UI_H
19 
20 #include <pthread.h>
21 
22 #include "ui.h"
23 #include "../../bootable/recovery/minui/minui.h"
24 
25 #ifdef RK3288_PCBA
26 #define CHAR_WIDTH  36
27 #define CHAR_HEIGHT 50
28 #else
29 #define CHAR_WIDTH  10
30 #define CHAR_HEIGHT 18
31 #endif
32 
33 // Implementation of RecoveryUI appropriate for devices with a screen
34 // (shows an icon + a progress bar, text logging, menu, etc.)
35 class ScreenRecoveryUI : public RecoveryUI {
36   public:
37     ScreenRecoveryUI();
38 
39     void Init();
40 
41     // overall recovery state ("background image")
42     void SetBackground(Icon icon);
43 
44     // progress indicator
45     void SetProgressType(ProgressType type);
46     void ShowProgress(float portion, float seconds);
47     void SetProgress(float fraction);
48 
49     // text log
50     void ShowText(bool visible);
51     bool IsTextVisible();
52     bool WasTextEverVisible();
53 
54     // printing messages
55     void Print(const char* fmt, ...); // __attribute__((format(printf, 1, 2)));
56     void Print(int t_col,int t_row,int r,int g,int b,int a, const char* fmt,...);
57 	void ChangeMenuItem(int index,int t_col,int t_row,int r,int g,int b,int a, const char* fmt,...);
58 
59 	void FillColor(int r,int g,int b,int a,int left,int top,int width,int height);
60 
61     // menu display
62     void StartMenu(const char* const * headers, const char* const * items,
63                            int initial_selection);
64     void StartMenu(const char* const * headers, const char* const * items,
65                            int initial_selection,int left_col,int top_row);
66     int SelectMenu(int sel);
67     void EndMenu();
68 
69   private:
70     Icon currentIcon;
71     int installingFrame;
72 
73     pthread_mutex_t updateMutex;
74     gr_surface backgroundIcon[3];
75     gr_surface *installationOverlay;
76     gr_surface *progressBarIndeterminate;
77     gr_surface progressBarEmpty;
78     gr_surface progressBarFill;
79 
80     ProgressType progressBarType;
81 
82     float progressScopeStart, progressScopeSize, progress;
83     double progressScopeTime, progressScopeDuration;
84 
85     // true when both graphics pages are the same (except for the
86     // progress bar)
87     bool pagesIdentical;
88 
89     static const int kMaxCols = 96;
90     static const int kMaxRows = 32;
91 	static const int kMaxTiles = 50;
92 
93 	static const int DEFAULT_R = 64;
94 	static const int DEFAULT_G = 96;
95 	static const int DEFAULT_B = 255;
96 	static const int DEFAULT_A = 255;
97 
98 	static const int SELECT_MENU_R = 255;
99 	static const int SELECT_MENU_G = 255;
100 	static const int SELECT_MENU_B = 255;
101 	static const int SELECT_MENU_A = 255;
102 
103     // Log text overlay, displayed when a magic key is pressed
104     char text[kMaxRows][kMaxCols];
105 	typedef struct{
106 		int t_col,t_row,r,g,b,a;
107     } textInfo;
108 	textInfo itemsInfo[kMaxRows];
109     typedef struct{
110 		int left,top,right,bottom,r,g,b,a;
111     } FillColorTile;
112 	FillColorTile  tiles[kMaxTiles];
113 	int tiles_count;
114     int text_cols, text_rows;
115     int text_col, text_row, text_top;
116     bool show_text;
117     bool show_text_ever;   // has show_text ever been true?
118 
119     char menu[kMaxRows][kMaxCols];
120 	textInfo menuItemsInfo[kMaxRows];
121     bool show_menu;
122     int menu_top, menu_items, menu_sel;
123 
124     pthread_t progress_t;
125 
126     int animation_fps;
127     int indeterminate_frames;
128     int installing_frames;
129     int install_overlay_offset_x, install_overlay_offset_y;
130 
131     void draw_install_overlay_locked(int frame);
132     void draw_background_locked(Icon icon);
133     void draw_progress_locked();
134     void draw_text_line(int left,int top, const char* t);
135     void draw_screen_locked();
136     void update_screen_locked();
137     void update_progress_locked();
138     static void* progress_thread(void* cookie);
139     void progress_loop();
140 
141     void LoadBitmap(const char* filename, gr_surface* surface);
142 
143 };
144 
145 #endif  // RECOVERY_UI_H
146