blob: 6a6138b2f2e4ca9531957e9571429eebe0e240c1 [file] [log] [blame]
Damien Bargiacchi565ba022016-08-11 15:29:50 -07001/*
2 * Copyright (C) 2016 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 HEALTHD_ANIMATION_H
18#define HEALTHD_ANIMATION_H
19
20#include <inttypes.h>
21#include <string>
22
Tao Bao777af952018-10-22 12:34:22 -070023class GRSurface;
Damien Bargiacchi565ba022016-08-11 15:29:50 -070024struct GRFont;
25
26namespace android {
27
28#define CENTER_VAL INT_MAX
29
30struct animation {
31 struct frame {
yushixianabc69132021-06-03 14:26:00 +080032 const char *name;
Damien Bargiacchi565ba022016-08-11 15:29:50 -070033 int disp_time;
34 int min_level;
35 int max_level;
36
37 GRSurface* surface;
38 };
39
40 struct text_field {
41 std::string font_file;
42 int pos_x;
43 int pos_y;
44 int color_r;
45 int color_g;
46 int color_b;
47 int color_a;
48
49 GRFont* font;
50 };
51
Yifan Hong082d2952019-01-28 12:55:54 -080052 // When libminui loads PNG images:
53 // - When treating paths as relative paths, it adds ".png" suffix.
54 // - When treating paths as absolute paths, it doesn't add the suffix. Hence, the suffix
55 // is added here.
56 void set_resource_root(const std::string& root) {
57 if (!animation_file.empty()) {
58 animation_file = root + animation_file + ".png";
59 }
60 if (!fail_file.empty()) {
61 fail_file = root + fail_file + ".png";
62 }
63 if (!text_clock.font_file.empty()) {
64 text_clock.font_file = root + text_clock.font_file + ".png";
65 }
66 if (!text_percent.font_file.empty()) {
67 text_percent.font_file = root + text_percent.font_file + ".png";
68 }
69 }
70
Damien Bargiacchi565ba022016-08-11 15:29:50 -070071 std::string animation_file;
72 std::string fail_file;
73
74 text_field text_clock;
75 text_field text_percent;
76
77 bool run;
78
Yifan Hong7dcf7b02019-10-08 17:27:11 -070079 frame* frames = nullptr;
Damien Bargiacchi565ba022016-08-11 15:29:50 -070080 int cur_frame;
81 int num_frames;
82 int first_frame_repeats; // Number of times to repeat the first frame in the current cycle
83
84 int cur_cycle;
85 int num_cycles; // Number of cycles to complete before blanking the screen
86
87 int cur_level; // current battery level being animated (0-100)
88 int cur_status; // current battery status - see BatteryService.h for BATTERY_STATUS_*
Yifan Hong7dcf7b02019-10-08 17:27:11 -070089
90 ~animation() { delete frames; }
Damien Bargiacchi565ba022016-08-11 15:29:50 -070091};
92
93}
94
95#endif // HEALTHD_ANIMATION_H