Experimental touch support
This commit is contained in:
@@ -815,6 +815,30 @@ static void alarm_window_unload() {
|
||||
fonts_unload_custom_font(s_font_mansalva_small);
|
||||
}
|
||||
|
||||
static void alarm_touch_handler(const TouchEvent *event, void *context) {
|
||||
GRect s_function_grect_fuzzy = GRect(s_drop_function_grect.origin.x - 10, s_drop_function_grect.origin.y - 10, s_drop_function_grect.size.w + 20, s_drop_function_grect.size.h + 20);
|
||||
GRect s_over_grect_fuzzy = GRect(s_drop_over_grect.origin.x - 10, s_drop_over_grect.origin.y - 10, s_drop_over_grect.size.w + 20, s_drop_over_grect.size.h + 10);
|
||||
GRect s_under_grect_fuzzy = GRect(s_drop_under_grect.origin.x - 10, s_drop_under_grect.origin.y - 5, s_drop_under_grect.size.w + 20, 50);
|
||||
|
||||
if (event->type == TouchEvent_Liftoff) {
|
||||
GPoint liftoff_point = GPoint(event->x, event->y);
|
||||
if (grect_contains_point(&s_function_grect_fuzzy, &liftoff_point)) {
|
||||
s_highlight_pos = 0;
|
||||
set_alarm_highlighter_frame();
|
||||
alarm_select_click_handler(NULL, NULL);
|
||||
} else if (grect_contains_point(&s_drop_under_grect, &liftoff_point)) {
|
||||
// check under first since it's harder to touch
|
||||
s_highlight_pos = 2;
|
||||
set_alarm_highlighter_frame();
|
||||
alarm_select_click_handler(NULL, NULL);
|
||||
} else if (grect_contains_point(&s_drop_over_grect, &liftoff_point)) {
|
||||
s_highlight_pos = 1;
|
||||
set_alarm_highlighter_frame();
|
||||
alarm_select_click_handler(NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void push_alarm_window() {
|
||||
s_alarm_reason = persist_read_int(STORAGE_KEY_ALARM_REASON);
|
||||
|
||||
@@ -837,6 +861,8 @@ static void push_alarm_window() {
|
||||
s_window,
|
||||
(WindowHandlers){.load = alarm_window_load, .unload = alarm_window_unload});
|
||||
window_set_click_config_provider(s_window, alarm_click_config_provider);
|
||||
window_set_touch_bridge_disabled(s_window, true);
|
||||
touch_service_subscribe(alarm_touch_handler, NULL);
|
||||
window_stack_push(s_window, false);
|
||||
}
|
||||
|
||||
@@ -1059,10 +1085,12 @@ static void push_setter_window() {
|
||||
s_window,
|
||||
(WindowHandlers){.load = setter_window_load, .unload = setter_window_unload});
|
||||
window_set_click_config_provider(s_window, setter_click_config_provider);
|
||||
window_set_touch_bridge_disabled(s_window, true);
|
||||
window_stack_push(s_window, false);
|
||||
}
|
||||
|
||||
static void init() {
|
||||
app_touch_navigation_enable(true);
|
||||
s_window = window_create();
|
||||
s_font_lecoish_small = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LECOISH_MONO_BOLD_20));
|
||||
the_time.HourWIP = persist_read_int(STORAGE_KEY_ALARM_HOUR);
|
||||
|
||||
Reference in New Issue
Block a user