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