BatteryComponent* battery_component_create(Layer *parent, int16_t x, int16_t y, bool align_right) { battery_state_service_subscribe(battery_handler); BatteryComponent *c = malloc(sizeof(BatteryComponent)); c->icon_layer = NULL; c->icon_bitmap = NULL; c->text_layer = NULL; if (get_prefs()->battery_as_number) { FontChoice font = get_font(BATTERY_FONT); c->text_layer = add_text_layer( parent, GRect(x, y - font.padding_top + font.padding_bottom, BATTERY_TEXT_WIDTH, font.height + font.padding_top + font.padding_bottom), fonts_get_system_font(font.key), element_fg(parent), align_right ? GTextAlignmentRight : GTextAlignmentLeft ); } else { c->icon_layer = bitmap_layer_create(GRect(x, y + BATTERY_ICON_TOP_FUDGE, BATTERY_ICON_WIDTH, BATTERY_ICON_HEIGHT)); bitmap_layer_set_compositing_mode(c->icon_layer, element_comp_op(parent)); layer_add_child(parent, bitmap_layer_get_layer(c->icon_layer)); } // XXX s_component = c; battery_handler(battery_state_service_peek()); return c; }
TrendArrowComponent* trend_arrow_component_create(Layer *parent, int x, int y) { BitmapLayer *icon_layer = bitmap_layer_create(GRect(x, y, TREND_ARROW_WIDTH, TREND_ARROW_WIDTH)); bitmap_layer_set_compositing_mode(icon_layer, element_comp_op(parent)); layer_set_hidden(bitmap_layer_get_layer(icon_layer), true); layer_add_child(parent, bitmap_layer_get_layer(icon_layer)); TrendArrowComponent *c = malloc(sizeof(TrendArrowComponent)); c->icon_layer = icon_layer; c->icon_bitmap = NULL; c->last_trend = -1; return c; }