1 /* 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 23 class GRSurface; 24 struct GRFont; 25 26 namespace android { 27 28 #define CENTER_VAL INT_MAX 29 30 struct animation { 31 struct frame { 32 int disp_time; 33 int min_level; 34 int max_level; 35 36 GRSurface* surface; 37 }; 38 39 struct text_field { 40 std::string font_file; 41 int pos_x; 42 int pos_y; 43 int color_r; 44 int color_g; 45 int color_b; 46 int color_a; 47 48 GRFont* font; 49 }; 50 51 // When libminui loads PNG images: 52 // - When treating paths as relative paths, it adds ".png" suffix. 53 // - When treating paths as absolute paths, it doesn't add the suffix. Hence, the suffix 54 // is added here. set_resource_rootanimation55 void set_resource_root(const std::string& root) { 56 if (!animation_file.empty()) { 57 animation_file = root + animation_file + ".png"; 58 } 59 if (!fail_file.empty()) { 60 fail_file = root + fail_file + ".png"; 61 } 62 if (!text_clock.font_file.empty()) { 63 text_clock.font_file = root + text_clock.font_file + ".png"; 64 } 65 if (!text_percent.font_file.empty()) { 66 text_percent.font_file = root + text_percent.font_file + ".png"; 67 } 68 } 69 70 std::string animation_file; 71 std::string fail_file; 72 73 text_field text_clock; 74 text_field text_percent; 75 76 bool run; 77 78 frame* frames; 79 int cur_frame; 80 int num_frames; 81 int first_frame_repeats; // Number of times to repeat the first frame in the current cycle 82 83 int cur_cycle; 84 int num_cycles; // Number of cycles to complete before blanking the screen 85 86 int cur_level; // current battery level being animated (0-100) 87 int cur_status; // current battery status - see BatteryService.h for BATTERY_STATUS_* 88 }; 89 90 } 91 92 #endif // HEALTHD_ANIMATION_H 93