// Down click handler static void prv_down_click_handler(ClickRecognizerRef recognizer, void *ctx) { // rewind timer if clicked while timer is going off if (main_timer_rewind() || main_data.control_mode == ControlModeCounting) { return; } // increment timer int64_t increment; if (main_data.control_mode == ControlModeEditHr) { increment = -MSEC_IN_HR; } else if (main_data.control_mode == ControlModeEditMin) { increment = -MSEC_IN_MIN; } else { increment = -MSEC_IN_SEC; } timer_increment(increment); // check if switched out of ControlModeEditHr if (timer_get_value_ms() / MSEC_IN_HR == 0 && main_data.control_mode == ControlModeEditHr) { main_data.control_mode = ControlModeEditMin; } // animate and refresh if (!click_recognizer_is_repeating(recognizer)) { drawing_start_bounce_animation(false); } drawing_update(); layer_mark_dirty(main_data.layer); }
void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) { Layer *layer = (Layer*)context; SelectionLayerData *data = layer_get_data(layer); if (data->is_active) { if (click_recognizer_is_repeating(recognizer)) { // Don't animate if the button is being held down. Just update the text data->callbacks.decrement(data->selected_cell_idx, click_number_of_clicks_counted(recognizer), data->context); layer_mark_dirty(layer); } else { data->bump_is_upwards = false; prv_run_value_change_animation(layer); } } }
// Up click handler static void prv_up_click_handler(ClickRecognizerRef recognizer, void *ctx) { // rewind timer if clicked while timer is going off if (main_timer_rewind() || main_data.control_mode == ControlModeCounting) { return; } // increment timer int64_t increment; if (main_data.control_mode == ControlModeEditHr) { increment = MSEC_IN_HR; } else if (main_data.control_mode == ControlModeEditMin) { increment = MSEC_IN_MIN; } else { increment = MSEC_IN_SEC; } // get starting time components uint16_t o_hr, o_min, o_sec; timer_get_time_parts(&o_hr, &o_min, &o_sec); // increment timer timer_increment(increment); // compare final time parts and switch into edit hr mode uint16_t n_hr, n_min, n_sec; timer_get_time_parts(&n_hr, &n_min, &n_sec); if (o_min > n_min && !o_hr) { timer_increment(MSEC_IN_HR); main_data.control_mode = ControlModeEditHr; } // check if switched out of ControlModeEditHr if (timer_get_value_ms() / MSEC_IN_HR == 0 && main_data.control_mode == ControlModeEditHr) { main_data.control_mode = ControlModeEditMin; } // animate and refresh if (!click_recognizer_is_repeating(recognizer)) { drawing_start_bounce_animation(true); } drawing_update(); layer_mark_dirty(main_data.layer); }