mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-20 21:23:25 +00:00
Scale numeric input to 75% screen
This commit is contained in:
@@ -108,7 +108,7 @@ void global_config_add_new_printer()
|
||||
|
||||
void global_config_set_printer(int idx)
|
||||
{
|
||||
if (idx < 0 || idx >= PRINTER_CONFIG_COUNT)
|
||||
if (idx < 0 || idx >= PRINTER_CONFIG_COUNT || global_config.printer_index == idx)
|
||||
return;
|
||||
|
||||
global_config.printer_index = idx;
|
||||
|
||||
@@ -104,11 +104,16 @@ void data_setup()
|
||||
{
|
||||
BasePrinter** available_printers = (BasePrinter**)malloc(sizeof(BasePrinter*) * PRINTER_CONFIG_COUNT);
|
||||
int count = 0;
|
||||
|
||||
int true_current_printer_index = 0;
|
||||
for (int i = 0; i < PRINTER_CONFIG_COUNT; i++)
|
||||
{
|
||||
if (global_config.printer_config[i].setup_complete)
|
||||
{
|
||||
if (global_config.printer_index == i)
|
||||
{
|
||||
true_current_printer_index = count;;
|
||||
}
|
||||
|
||||
switch (global_config.printer_config[i].printer_type)
|
||||
{
|
||||
case PrinterType::PrinterTypeKlipper:
|
||||
@@ -122,6 +127,7 @@ void data_setup()
|
||||
}
|
||||
|
||||
initialize_printers(available_printers, count);
|
||||
set_current_printer(true_current_printer_index);
|
||||
semaphore_init();
|
||||
fetch_printer_data();
|
||||
freeze_render_thread();
|
||||
|
||||
@@ -97,7 +97,7 @@ static void edit_move_increment(int column, float* idx)
|
||||
}
|
||||
|
||||
selected_column = column;
|
||||
lv_create_keyboard_text_entry(keyboard_cb_edit_move_increment, "Set increment", LV_KEYBOARD_MODE_NUMBER, CYD_SCREEN_PANEL_WIDTH_PX / 2, 6);
|
||||
lv_create_keyboard_text_entry(keyboard_cb_edit_move_increment, "Set increment", LV_KEYBOARD_MODE_NUMBER, LV_PCT(75), 6);
|
||||
}
|
||||
|
||||
static void x_line_button_press(lv_event_t * e) {
|
||||
@@ -214,15 +214,15 @@ static void z_line_custom_callback(lv_event_t * e) {
|
||||
}
|
||||
|
||||
static void x_line_custom(lv_event_t * e) {
|
||||
lv_create_keyboard_text_entry(x_line_custom_callback, "Set X position", LV_KEYBOARD_MODE_NUMBER, CYD_SCREEN_PANEL_WIDTH_PX / 2, 6);
|
||||
lv_create_keyboard_text_entry(x_line_custom_callback, "Set X position", LV_KEYBOARD_MODE_NUMBER, LV_PCT(75), 6);
|
||||
}
|
||||
|
||||
static void y_line_custom(lv_event_t * e) {
|
||||
lv_create_keyboard_text_entry(y_line_custom_callback, "Set Y position", LV_KEYBOARD_MODE_NUMBER, CYD_SCREEN_PANEL_WIDTH_PX / 2, 6);
|
||||
lv_create_keyboard_text_entry(y_line_custom_callback, "Set Y position", LV_KEYBOARD_MODE_NUMBER, LV_PCT(75), 6);
|
||||
}
|
||||
|
||||
static void z_line_custom(lv_event_t * e) {
|
||||
lv_create_keyboard_text_entry(z_line_custom_callback, "Set Z position", LV_KEYBOARD_MODE_NUMBER, CYD_SCREEN_PANEL_WIDTH_PX / 2, 6);
|
||||
lv_create_keyboard_text_entry(z_line_custom_callback, "Set Z position", LV_KEYBOARD_MODE_NUMBER, LV_PCT(75), 6);
|
||||
}
|
||||
|
||||
lv_event_cb_t custom_callbacks[] = {x_line_custom, y_line_custom, z_line_custom};
|
||||
|
||||
@@ -118,6 +118,7 @@ void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, const char*
|
||||
lv_obj_set_style_bg_opa(parent, LV_OPA_50, 0);
|
||||
lv_obj_align(parent, LV_ALIGN_TOP_RIGHT, 0, 0);
|
||||
lv_layout_flex_column(parent, LV_FLEX_ALIGN_SPACE_BETWEEN);
|
||||
lv_obj_clear_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
if (contain_in_panel)
|
||||
{
|
||||
@@ -128,7 +129,7 @@ void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, const char*
|
||||
lv_obj_set_size(parent, CYD_SCREEN_WIDTH_PX, CYD_SCREEN_HEIGHT_PX);
|
||||
}
|
||||
|
||||
if (title != nullptr)
|
||||
if (title != nullptr && keyboard_mode != LV_KEYBOARD_MODE_NUMBER)
|
||||
{
|
||||
lv_obj_t * empty_panel = lv_create_empty_panel(parent);
|
||||
lv_obj_set_size(empty_panel, 0, 0);
|
||||
@@ -147,6 +148,12 @@ void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, const char*
|
||||
lv_obj_t * ta = lv_textarea_create(parent);
|
||||
lv_obj_t * keyboard = lv_keyboard_create(parent);
|
||||
|
||||
if (keyboard_mode == LV_KEYBOARD_MODE_NUMBER)
|
||||
{
|
||||
lv_textarea_set_placeholder_text(ta, title);
|
||||
lv_obj_set_height(keyboard, LV_PCT(75));
|
||||
}
|
||||
|
||||
lv_obj_set_width(ta, width);
|
||||
lv_textarea_set_max_length(ta, max_length);
|
||||
lv_textarea_set_one_line(ta, true);
|
||||
|
||||
@@ -39,7 +39,7 @@ void lv_layout_flex_row(lv_obj_t* obj, lv_flex_align_t allign = LV_FLEX_ALIGN_ST
|
||||
void lv_create_fullscreen_button_matrix_popup(lv_obj_t * root, lv_event_cb_t title, lv_button_column_t* columns, int column_count);
|
||||
void destroy_event_user_data(lv_event_t * e);
|
||||
void lv_obj_on_destroy_free_data(lv_obj_t * element, const void* ptr);
|
||||
void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, const char* title = NULL, lv_keyboard_mode_t keyboard_mode = LV_KEYBOARD_MODE_NUMBER, lv_coord_t width = CYD_SCREEN_PANEL_WIDTH_PX / 2, uint8_t max_length = 3, const char* fill_text = "", bool contain_in_panel= true);
|
||||
void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, const char* title = NULL, lv_keyboard_mode_t keyboard_mode = LV_KEYBOARD_MODE_NUMBER, lv_coord_t width = LV_PCT(75), uint8_t max_length = 3, const char* fill_text = "", bool contain_in_panel= true);
|
||||
void lv_create_custom_menu_entry(const char* label_text, lv_obj_t* object, lv_obj_t* root_panel, bool set_height = true, const char * comment = NULL);
|
||||
void lv_create_custom_menu_button(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_click, const char *btn_text, void * user_data = NULL, const char * comment = NULL);
|
||||
void lv_create_custom_menu_switch(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_toggle, bool state, void * user_data = NULL, const char * comment = NULL);
|
||||
|
||||
Reference in New Issue
Block a user