/* * * meh_popup_button_pressed moves the currently selected position. */ static void meh_simple_popup_move_selection(App* app, Screen* screen, gboolean down) { g_assert(app); g_assert(screen); SimplePopupData* data = meh_simple_popup_get_data(screen); g_assert(data); int old = data->action; if (down) { data->action += 1; } else { data->action -= 1; } int actions_count = g_queue_get_length(data->actions); if (data->action < 0) { data->action = actions_count-1; } else if (data->action >= actions_count) { data->action = 0; } data->selection_widget->y = meh_transition_start(MEH_TRANSITION_LINEAR, (data->y+54) + old*32, (data->y+54) + (data->action*32), 100); meh_screen_add_rect_transitions(screen, data->selection_widget); }
static void meh_screen_popup_close(Screen* screen) { g_assert(screen != NULL); PopupData* data = meh_screen_popup_get_data(screen); data->background_widget->y = meh_transition_start(MEH_TRANSITION_LINEAR, data->background_widget->y.value, MEH_FAKE_HEIGHT, 150); meh_screen_add_rect_transitions(screen, data->background_widget); data->quitting = TRUE; }
Screen* meh_screen_launch_new(App* app, Screen* src_screen, Platform* platform, Executable* executable, WidgetImage* src_widget) { g_assert(app != NULL); g_assert(src_screen != NULL); g_assert(platform != NULL); g_assert(executable != NULL); Screen* screen = meh_screen_new(app->window); screen->name = g_strdup("Launch screen"); screen->messages_handler = &meh_screen_launch_messages_handler; screen->destroy_data = &meh_screen_launch_destroy_data; /* * custom data */ LaunchData* data = g_new(LaunchData, 1); data->src_screen = src_screen; data->image_widget = NULL; data->executable = executable; data->platform = platform; data->src_widget = src_widget; data->zoom_logo = FALSE; /* fading rect */ SDL_Color black = { 0, 0, 0 ,0 }; data->fade_widget = meh_widget_rect_new(0, 0, MEH_FAKE_WIDTH, MEH_FAKE_HEIGHT, black, TRUE); data->fade_widget->a = meh_transition_start(MEH_TRANSITION_LINEAR, 1, 254, app->settings.fade_duration*4); meh_screen_add_rect_transitions(screen, data->fade_widget); if (app->settings.zoom_logo && src_widget != NULL) { /* cover image */ data->image_widget = meh_widget_image_new( src_widget->texture, src_widget->x.value, src_widget->y.value, src_widget->h.value, src_widget->w.value); /* starts the cover transitions */ data->image_widget->x = meh_transition_start(MEH_TRANSITION_CUBIC, src_widget->x.value, -(MEH_FAKE_WIDTH), app->settings.fade_duration*4); data->image_widget->y = meh_transition_start(MEH_TRANSITION_CUBIC, src_widget->y.value, -(MEH_FAKE_HEIGHT), app->settings.fade_duration*4); data->image_widget->w = meh_transition_start(MEH_TRANSITION_CUBIC, src_widget->w.value, MEH_FAKE_WIDTH*3, app->settings.fade_duration*4); data->image_widget->h = meh_transition_start(MEH_TRANSITION_CUBIC, src_widget->h.value, MEH_FAKE_HEIGHT*3, app->settings.fade_duration*4); meh_screen_add_image_transitions(screen, data->image_widget); data->zoom_logo = TRUE; } screen->data = data; return screen; }
/* * * meh_popup_button_pressed moves the currently selected position. */ static void meh_screen_popup_move_selection(App* app, Screen* screen, gboolean down) { g_assert(app); g_assert(screen); PopupData* data = meh_screen_popup_get_data(screen); g_assert(data); int old = data->action; data->action = data->action == 0 ? 1 : 0; data->selection_widget->y = meh_transition_start(MEH_TRANSITION_LINEAR, (data->y+54) + old*32, (data->y+54) + (data->action*32), 100); meh_screen_add_rect_transitions(screen, data->selection_widget); }
/* * meh_main_popup_button_pressed moves the currently selected position. */ static void meh_main_popup_move_selection(App* app, Screen* screen, gboolean down) { g_assert(app); g_assert(screen); MainPopupData* data = meh_main_popup_get_data(screen); g_assert(data); int old = data->action; data->action = down == TRUE ? data->action+1 : data->action-1; if (data->action > 2) { data->action = 0; } else if (data->action == -1) { data->action = 2; } data->selection_widget->y = meh_transition_start(MEH_TRANSITION_LINEAR, (data->y+54) + old*32, (data->y+54) + (data->action*32), 100); meh_screen_add_rect_transitions(screen, data->selection_widget); }
void meh_exec_selection_prepare(App* app, Screen* screen) { g_assert(app != NULL); g_assert(screen != NULL); ExecutableListData* data = meh_exec_list_get_data(screen); SDL_Color white = { 255, 255, 255, 255 }; SDL_Color white_transparent = { 255, 255, 255, 50 }; /* Selection */ data->selection_widget = meh_widget_rect_new(0, -100, 415, 28, white_transparent, TRUE); data->selection_widget->y = meh_transition_start(MEH_TRANSITION_CUBIC, -100, 130, 500); meh_screen_add_rect_transitions(screen, data->selection_widget); /* Executables */ for (int i = 0; i < MEH_EXEC_LIST_SIZE; i++) { WidgetText* text = meh_widget_text_new(app->small_font, "", 55, 130+(i*32), 350, 30, white, FALSE); text->uppercase = TRUE; /* executables name in uppercase */ g_queue_push_tail(data->executable_widgets, text); } }
Screen* meh_screen_popup_new(App* app, Screen* src_screen, Executable* executable) { g_assert(app != NULL); g_assert(src_screen != NULL); g_assert(executable != NULL); Screen* screen = meh_screen_new(app->window); screen->name = g_strdup("Popup screen"); screen->messages_handler = &meh_screen_popup_messages_handler; screen->destroy_data = &meh_screen_popup_destroy_data; /* * Custom data */ PopupData* data = g_new(PopupData, 1); data->src_screen = src_screen; data->executable = executable; data->action = 0; data->width = 400; data->height = 200; data->x = MEH_FAKE_WIDTH/2 - data->width/2; data->y = MEH_FAKE_HEIGHT/2 - data->height/2; data->quitting = FALSE; /* Popup background */ SDL_Color white = { 255, 255, 255, 255 }; SDL_Color black = { 0, 0, 0, 240 }; SDL_Color gray = { 15, 15, 15, 120 }; SDL_Color light_gray = { 90, 90, 90, 220 }; SDL_Color very_light_gray = { 40, 40, 40, 220 }; data->background_widget = meh_widget_rect_new(data->x, data->y, data->width, data->height, very_light_gray, TRUE); data->background_widget->y = meh_transition_start(MEH_TRANSITION_LINEAR, -data->height, data->background_widget->y.value, 150); meh_screen_add_rect_transitions(screen, data->background_widget); screen->data = data; black.a = 150; data->hover_widget = meh_widget_rect_new(0, 0, MEH_FAKE_WIDTH, MEH_FAKE_HEIGHT, black, TRUE); /* Title */ data->title_widget = meh_widget_text_new(app->small_bold_font, "OPTIONS", data->x+10, data->y+5, data->width-10, 40, white, TRUE); data->title_bg_widget = meh_widget_rect_new(data->x, data->y, data->width, 45, gray, TRUE); data->selection_widget = meh_widget_rect_new( data->x+5, data->y+54, data->width-10, 30, light_gray, TRUE); /* Add/Remove to favorite */ data->favorite_widget = meh_widget_text_new( app->small_font, executable->favorite == 1 ? "Remove from favorite" : "Add to favorite", data->x+20, data->y+55, data->width-20, 30, white, TRUE); screen->data = data; return screen; }