static void glui_navigation_set(bool scroll) { menu_display_t *disp = menu_display_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr(); float scroll_pos = 0; if (!menu || !disp || !scroll) return; scroll_pos = glui_get_scroll(); if (menu->userdata) { unsigned height = 0, num_lines = 0, end = 0; glui_handle_t *glui = (glui_handle_t*)menu->userdata; menu_navigation_t *nav = menu_navigation_get_ptr(); video_driver_get_size(NULL, &height); num_lines = height / glui->line_height; end = menu_entries_get_end(); if (nav->selection_ptr < num_lines / 2 || end <= num_lines) menu_entries_set_start(0); else if (nav->selection_ptr < (end - num_lines / 2)) menu_entries_set_start(nav->selection_ptr - num_lines / 2); else menu_entries_set_start(end - num_lines); if (menu_entries_get_start() >= 5) menu_entries_set_start(menu_entries_get_start() - 5); } menu_animation_push(disp->animation, 10, scroll_pos, &menu->scroll_y, EASING_IN_OUT_QUAD, -1, NULL); }
static void glui_navigation_clear(bool pending_push) { menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) return; menu_entries_set_start(0); menu->scroll_y = 0; }
static void glui_render(void) { int bottom; unsigned width, height; glui_handle_t *glui = NULL; menu_display_t *disp = menu_display_get_ptr(); menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); settings_t *settings = config_get_ptr(); if (!menu || !menu->userdata) return; video_driver_get_size(&width, &height); glui = (glui_handle_t*)menu->userdata; menu_animation_update(disp->animation, disp->animation->delta_time / IDEAL_DT); /* TODO/FIXME - we don't use framebuffer at all * for GLUI, we should refactor this dependency * away. */ frame_buf->width = width; frame_buf->height = height; if (settings->menu.pointer.enable) { menu_input->pointer.ptr = (menu_input->pointer.y - glui->line_height + menu->scroll_y - 16) / glui->line_height; if (menu_input->pointer.dragging) menu->scroll_y -= menu_input->pointer.dy; } if (settings->menu.mouse.enable) { if (menu_input->mouse.scrolldown) menu->scroll_y += 10; if (menu_input->mouse.scrollup) menu->scroll_y -= 10; menu_input->mouse.ptr = (menu_input->mouse.y - glui->line_height + menu->scroll_y - 16) / glui->line_height; } if (menu_entries_get_end() < height / glui->line_height) menu_entries_set_start(0); if (menu->scroll_y < 0) menu->scroll_y = 0; bottom = menu_entries_get_end() * glui->line_height - height + disp->header_height * 2; if (menu->scroll_y > bottom) menu->scroll_y = bottom; if (menu_entries_get_end() * glui->line_height < height - disp->header_height*2) menu->scroll_y = 0; }
static void glui_render(void) { float delta_time, dt; int bottom; unsigned width, height, header_height; glui_handle_t *glui = NULL; menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); if (!menu || !menu->userdata) return; video_driver_get_size(&width, &height); glui = (glui_handle_t*)menu->userdata; menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time); dt = delta_time / IDEAL_DT; menu_animation_ctl(MENU_ANIMATION_CTL_UPDATE, &dt); menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &width); menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &height); menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); if (settings->menu.pointer.enable) { int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS); float old_accel_val, new_accel_val; unsigned new_pointer_val = (pointer_y - glui->line_height + menu->scroll_y - 16) / glui->line_height; menu_input_ctl(MENU_INPUT_CTL_POINTER_ACCEL_READ, &old_accel_val); menu_input_ctl(MENU_INPUT_CTL_POINTER_PTR, &new_pointer_val); menu->scroll_y -= old_accel_val / 60.0; new_accel_val = old_accel_val * 0.96; menu_input_ctl(MENU_INPUT_CTL_POINTER_ACCEL_WRITE, &new_accel_val); } if (settings->menu.mouse.enable) { unsigned new_mouse_ptr = 0; bool mouse_scrolldown, mouse_scrollup; int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS); menu_input_ctl(MENU_INPUT_CTL_MOUSE_SCROLL_DOWN, &mouse_scrolldown); menu_input_ctl(MENU_INPUT_CTL_MOUSE_SCROLL_UP, &mouse_scrollup); if (mouse_scrolldown) menu->scroll_y += 10; if (mouse_scrollup) menu->scroll_y -= 10; new_mouse_ptr = (mouse_y - glui->line_height + menu->scroll_y - 16) / glui->line_height; menu_input_ctl(MENU_INPUT_CTL_MOUSE_PTR, &new_mouse_ptr); } if (menu->scroll_y < 0) menu->scroll_y = 0; bottom = menu_entries_get_end() * glui->line_height - height + header_height * 2; if (menu->scroll_y > bottom) menu->scroll_y = bottom; if (menu_entries_get_end() * glui->line_height < height - header_height*2) menu->scroll_y = 0; if (menu_entries_get_end() < height / glui->line_height) menu_entries_set_start(0); else menu_entries_set_start(menu->scroll_y / glui->line_height); }