Skip to content

Commit

Permalink
Rename components to ui_components (#160)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

<!--- Describe your changes in detail -->
Renames `components` to `ui_components`

<!--- What does this sample do? What problem does it solve? -->
<!--- If it fixes/closes/resolves an open issue, please link to the
issue here -->
Makes the source more clear as to its functionality

<!-- (if applicable) -->
<!--- Please describe in detail how you tested your sample/changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

<!-- (if appropriate): -->

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Improvement (non-breaking change that adds a new feature)
- [ ] Bug fix (fixes an issue)
- [ ] Breaking change (breaking change)
- [ ] Documentation Improvement
- [ ] Config and build (change in the configuration and build system,
has no impact on code or features)

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

<!--- It would be nice if you could sign off your contribution by
replacing the name with your GitHub user name and GitHub email contact.
-->
Signed-off-by: GITHUB_USER <GITHUB_USER_EMAIL>
  • Loading branch information
networkfusion committed Nov 11, 2024
1 parent 0d30a6f commit 96506ed
Show file tree
Hide file tree
Showing 25 changed files with 198 additions and 204 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ SRCS = \
libs/miniz/miniz.c \
menu/actions.c \
menu/cart_load.c \
menu/components/background.c \
menu/components/boxart.c \
menu/components/common.c \
menu/components/context_menu.c \
menu/components/file_list.c \
menu/disk_info.c \
menu/fonts.c \
menu/hdmi.c \
Expand All @@ -56,6 +51,11 @@ SRCS = \
menu/rom_info.c \
menu/settings.c \
menu/sound.c \
menu/ui_components/background.c \
menu/ui_components/boxart.c \
menu/ui_components/common.c \
menu/ui_components/context_menu.c \
menu/ui_components/file_list.c \
menu/usb_comm.c \
menu/views/browser.c \
menu/views/credits.c \
Expand Down
4 changes: 2 additions & 2 deletions src/menu/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void menu_init (boot_params_t *boot_params) {
directory_create(path_get(path));

path_push(path, BACKGROUND_CACHE_FILE);
component_background_init(path_get(path));
ui_components_background_init(path_get(path));

path_free(path);

Expand All @@ -103,7 +103,7 @@ static void menu_init (boot_params_t *boot_params) {
static void menu_deinit (menu_t *menu) {
hdmi_send_game_id(menu->boot_params);

component_background_free();
ui_components_background_free();

path_free(menu->load.disk_path);
path_free(menu->load.rom_path);
Expand Down
64 changes: 29 additions & 35 deletions src/menu/components.h → src/menu/ui_components.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
/**
* @file components.h
* @file ui_components.h
* @brief Menu Graphical User Interface Components
* @ingroup menu
*/

#ifndef COMPONENTS_H__
#define COMPONENTS_H__
#ifndef UI_COMPONENTS_H__
#define UI_COMPONENTS_H__

#include <libdragon.h>
#include "menu_state.h"

/**
* @addtogroup menu_ui_components
* @{
*/

/**
* @brief File image Enumeration.
*
* Enumeration for different types of file images used in the GUI.
* Enumeration for different types of file images used in the user interface.
*/
typedef enum {
IMAGE_BOXART_FRONT, /**< Boxart image from the front */
Expand All @@ -42,7 +38,7 @@ typedef enum {
* @param y1 Ending y-coordinate.
* @param color Color of the box.
*/
void component_box_draw(int x0, int y0, int x1, int y1, color_t color);
void ui_components_box_draw(int x0, int y0, int x1, int y1, color_t color);

/**
* @brief Draw a border component.
Expand All @@ -52,12 +48,12 @@ void component_box_draw(int x0, int y0, int x1, int y1, color_t color);
* @param x1 Ending x-coordinate.
* @param y1 Ending y-coordinate.
*/
void component_border_draw(int x0, int y0, int x1, int y1);
void ui_components_border_draw(int x0, int y0, int x1, int y1);

/**
* @brief Draw the layout component.
*/
void component_layout_draw(void);
void ui_components_layout_draw(void);

/**
* @brief Draw a progress bar component.
Expand All @@ -68,21 +64,21 @@ void component_layout_draw(void);
* @param y1 Ending y-coordinate.
* @param progress Progress value (0.0 to 1.0).
*/
void component_progressbar_draw(int x0, int y0, int x1, int y1, float progress);
void ui_components_progressbar_draw(int x0, int y0, int x1, int y1, float progress);

/**
* @brief Draw a seek bar component.
*
* @param progress Progress value (0.0 to 1.0).
*/
void component_seekbar_draw(float progress);
void ui_components_seekbar_draw(float progress);

/**
* @brief Draw a loader component.
*
* @param position Position value (0.0 to 1.0).
*/
void component_loader_draw(float position);
void ui_components_loader_draw(float position);

/**
* @brief Draw a scrollbar component.
Expand All @@ -95,7 +91,7 @@ void component_loader_draw(float position);
* @param items Total number of items.
* @param visible_items Number of visible items.
*/
void component_scrollbar_draw(int x, int y, int width, int height, int position, int items, int visible_items);
void ui_components_scrollbar_draw(int x, int y, int width, int height, int position, int items, int visible_items);

/**
* @brief Draw a list scrollbar component.
Expand All @@ -104,23 +100,23 @@ void component_scrollbar_draw(int x, int y, int width, int height, int position,
* @param items Total number of items.
* @param visible_items Number of visible items.
*/
void component_list_scrollbar_draw(int position, int items, int visible_items);
void ui_components_list_scrollbar_draw(int position, int items, int visible_items);

/**
* @brief Draw a dialog component.
*
* @param width Width of the dialog.
* @param height Height of the dialog.
*/
void component_dialog_draw(int width, int height);
void ui_components_dialog_draw(int width, int height);

/**
* @brief Draw a message box component.
*
* @param fmt Format string for the message.
* @param ... Additional arguments for the format string.
*/
void component_messagebox_draw(char *fmt, ...);
void ui_components_messagebox_draw(char *fmt, ...);

/**
* @brief Draw the main text component.
Expand All @@ -130,7 +126,7 @@ void component_messagebox_draw(char *fmt, ...);
* @param fmt Format string for the text.
* @param ... Additional arguments for the format string.
*/
void component_main_text_draw(rdpq_align_t align, rdpq_valign_t valign, char *fmt, ...);
void ui_components_main_text_draw(rdpq_align_t align, rdpq_valign_t valign, char *fmt, ...);

/**
* @brief Draw the actions bar text component.
Expand All @@ -140,31 +136,31 @@ void component_main_text_draw(rdpq_align_t align, rdpq_valign_t valign, char *fm
* @param fmt Format string for the text.
* @param ... Additional arguments for the format string.
*/
void component_actions_bar_text_draw(rdpq_align_t align, rdpq_valign_t valign, char *fmt, ...);
void ui_components_actions_bar_text_draw(rdpq_align_t align, rdpq_valign_t valign, char *fmt, ...);

/**
* @brief Initialize the background component.
*
* @param cache_location Location of the cache.
*/
void component_background_init(char *cache_location);
void ui_components_background_init(char *cache_location);

/**
* @brief Free the background component resources.
*/
void component_background_free(void);
void ui_components_background_free(void);

/**
* @brief Replace the background image.
*
* @param image New background image.
*/
void component_background_replace_image(surface_t *image);
void ui_components_background_replace_image(surface_t *image);

/**
* @brief Draw the background component.
*/
void component_background_draw(void);
void ui_components_background_draw(void);

/**
* @brief Draw the file list component.
Expand All @@ -173,7 +169,7 @@ void component_background_draw(void);
* @param entries Number of entries.
* @param selected Index of the selected entry.
*/
void component_file_list_draw(entry_t *list, int entries, int selected);
void ui_components_file_list_draw(entry_t *list, int entries, int selected);

/**
* @brief Context menu structure.
Expand All @@ -199,14 +195,14 @@ typedef struct component_context_menu {
*
* @param cm Pointer to the context menu structure.
*/
void component_context_menu_init(component_context_menu_t *cm);
void ui_components_context_menu_init(component_context_menu_t *cm);

/**
* @brief Show the context menu component.
*
* @param cm Pointer to the context menu structure.
*/
void component_context_menu_show(component_context_menu_t *cm);
void ui_components_context_menu_show(component_context_menu_t *cm);

/**
* @brief Process the context menu component.
Expand All @@ -215,14 +211,14 @@ void component_context_menu_show(component_context_menu_t *cm);
* @param cm Pointer to the context menu structure.
* @return True if the context menu was processed, false otherwise.
*/
bool component_context_menu_process(menu_t *menu, component_context_menu_t *cm);
bool ui_components_context_menu_process(menu_t *menu, component_context_menu_t *cm);

/**
* @brief Draw the context menu component.
*
* @param cm Pointer to the context menu structure.
*/
void component_context_menu_draw(component_context_menu_t *cm);
void ui_components_context_menu_draw(component_context_menu_t *cm);

/**
* @brief Box Art Structure.
Expand All @@ -240,22 +236,20 @@ typedef struct {
* @param current_image_view Current image view type.
* @return Pointer to the initialized box art component.
*/
component_boxart_t *component_boxart_init(const char *storage_prefix, char *game_code, file_image_type_t current_image_view);
component_boxart_t *ui_components_boxart_init(const char *storage_prefix, char *game_code, file_image_type_t current_image_view);

/**
* @brief Free the box art component resources.
*
* @param b Pointer to the box art component.
*/
void component_boxart_free(component_boxart_t *b);
void ui_components_boxart_free(component_boxart_t *b);

/**
* @brief Draw the box art component.
*
* @param b Pointer to the box art component.
*/
void component_boxart_draw(component_boxart_t *b);

/** @} */ /* menu_ui_components */
void ui_components_boxart_draw(component_boxart_t *b);

#endif /* COMPONENTS_H__ */
#endif /* UI_COMPONENTS_H__ */
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>

#include "../components.h"
#include "../ui_components.h"
#include "constants.h"
#include "utils/fs.h"

Expand Down Expand Up @@ -157,7 +157,7 @@ static void display_list_free (void *arg) {
}


void component_background_init (char *cache_location) {
void ui_components_background_init (char *cache_location) {
if (!background) {
background = calloc(1, sizeof(component_background_t));
background->cache_location = strdup(cache_location);
Expand All @@ -166,7 +166,7 @@ void component_background_init (char *cache_location) {
}
}

void component_background_free (void) {
void ui_components_background_free (void) {
if (background) {
if (background->image) {
surface_free(background->image);
Expand All @@ -185,7 +185,7 @@ void component_background_free (void) {
}
}

void component_background_replace_image (surface_t *image) {
void ui_components_background_replace_image (surface_t *image) {
if (!background) {
return;
}
Expand All @@ -206,7 +206,7 @@ void component_background_replace_image (surface_t *image) {
prepare_background(background);
}

void component_background_draw (void) {
void ui_components_background_draw (void) {
if (background && background->image_display_list) {
rspq_block_run(background->image_display_list);
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/menu/components/boxart.c → src/menu/ui_components/boxart.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <stdlib.h>

#include "../components.h"
#include "../ui_components.h"
#include "../path.h"
#include "../png_decoder.h"
#include "constants.h"
Expand All @@ -17,7 +17,7 @@ static void png_decoder_callback (png_err_t err, surface_t *decoded_image, void
}


component_boxart_t *component_boxart_init (const char *storage_prefix, char *game_code, file_image_type_t current_image_view) {
component_boxart_t *ui_components_boxart_init (const char *storage_prefix, char *game_code, file_image_type_t current_image_view) {
component_boxart_t *b;
char boxart_id_path[8];

Expand Down Expand Up @@ -120,7 +120,7 @@ component_boxart_t *component_boxart_init (const char *storage_prefix, char *gam
return NULL;
}

void component_boxart_free (component_boxart_t *b) {
void ui_components_boxart_free (component_boxart_t *b) {
if (b) {
if (b->loading) {
png_decoder_abort();
Expand All @@ -133,7 +133,7 @@ void component_boxart_free (component_boxart_t *b) {
}
}

void component_boxart_draw (component_boxart_t *b) {
void ui_components_boxart_draw (component_boxart_t *b) {
int box_x = BOXART_X;
int box_y = BOXART_Y;

Expand All @@ -150,7 +150,7 @@ void component_boxart_draw (component_boxart_t *b) {
rdpq_tex_blit(b->image, box_x, box_y, NULL);
rdpq_mode_pop();
} else {
component_box_draw(
ui_components_box_draw(
BOXART_X,
BOXART_Y,
BOXART_X + BOXART_WIDTH,
Expand Down
Loading

0 comments on commit 96506ed

Please sign in to comment.