ccextractor/docs/guidoc.md
2017-10-13 14:42:03 -07:00

46 KiB

Documentation

CCExtractor Graphical User Interface

Code Structure:

src/GUI
├── activity.c             -Activity window definitions
├── activity.h             -Activity window declarations
├── ccextractorGUI.c       -Contains main()  and GUI code for 'Main' Tab + 'Menu'
├── ccextractorGUI.h       -Function and structure declarations
├── ccx_cli_thread.c       -All the functions (definitions) passed in threads
├── ccx_cli_thread.h       -Function, variables & structs declaration used in thread
├── command_builder.c      -Builds command to pass to CLI CCExtractor
├── command_builder.h      -Function, variables & structs declaration used
├── file_browser.c         -Function definition for File Browser
├── file_browser.h         -Function, struct & variable declaration
├── nuklear_lib            -Diretory contains Library Files
│   ├── nuklear_glfw_gl2.h -GLFW backend source header to interact with Nuklear
│   └── nuklear.h          -Nuklear library source code
├── popups.c               -Function definitions for all Popups used
├── popups.h               -Function & network struct declaration for all Popups
├── preview.c              -Preview window definitions
├── preview.h              -Preview window definitions
├── save_load_data.c       -Function definition to save last run state
├── save_load_data.h       -Function declaration to save last run state
├── stb_image.h            -Code to load images
├── tabs.c                 -Function definitions for all tabs except 'Main' tab
├── tabs.h                 -Function, variable and structure declarations
├── terminal.c             -Code for terminal Window
└── win_dirent.h           -Dirent API for Windows

File by File functions:

activity.c

nk_begin(ctx, "Activity", nk_rect(x, y, width, height), NK_WINDOW_TITLE|NK_WINDOW_BACKGROUND);
nk_end(ctx);
nk_layout_row_dynamic(ctx, 40, 1);
nk_label_wrap(ctx, main_settings->activity_string[i]);
nk_window_is_closed(ctx, "Activity");

activity.h

int activity(struct nk_context *ctx, int x, int y, int width, int height, struct main_tab *main_settings);

ccextractorGUI.c

nk_menubar_begin(ctx);
nk_layout_row_begin(ctx, NK_STATIC, 30, 3);
nk_layout_row_push(ctx, 80);
nk_menu_begin_label(ctx, "Preferences", NK_TEXT_LEFT, nk_vec2(120, 200));
nk_menu_end(ctx);
nk_menubar_end(ctx);
nk_layout_space_begin(ctx, NK_STATIC, 15, 1);
nk_layout_space_end(ctx);
nk_style_push_vec2(ctx, &ctx->style.window.spacing, nk_vec2(0, 0));
nk_style_push_float(ctx, &ctx->style.button.rounding, 0);
nk_button_label(ctx, names[i]);
nk_style_pop_float(ctx);
nk_group_begin(ctx, "Advanced Tabs", NK_WINDOW_NO_SCROLLBAR);
nk_group_end(ctx);
nk_layout_row(ctx, NK_DYNAMIC, 20, 3, ratio_adv_mode);
nk_spacing(ctx, 1);
nk_checkbox_label(ctx, "Advanced Mode", &advanced_mode_check);
nk_option_label(ctx, "Extract from files below:", main_settings.port_or_files == FILES));
nk_selectable_label(ctx, truncate_path_string(main_settings.filenames[i]), NK_TEXT_LEFT, &main_settings.is_file_selected[i]);
nk_combo(ctx, main_settings.port_type, 2, main_settings.port_select, 20, nk_vec2_(85,100));
nk_label(ctx, "Drag and Drop files for extraction.", NK_TEXT_CENTERED
nk_progress(ctx, &main_settings.progress_cursor, 101, nk_true);

ccextractorGUI.h

void setup_main_settings(struct main_tab *main_settings);
char* truncate_path_string(char *filePath);
void remove_path_entry(struct main_tab *main_settings, int indexToRemove);

ccx_cli_thread.c || ccx_cli_thread.h

void* read_activity_data(void *read_args);
void* read_data_from_thread(void* read_args);
void* extract_thread(void* extract_args);
void* feed_files_for_extraction(void* file_args);
void setup_and_create_thread(struct main_tab *main_settings, struct built_string *command);
void&asst; find_hd_homerun_devices(void *args);
void* setup_hd_homerun_device(void *args);

command_builder.c || command_builder.h

void command_builder(struct built_string *command,
        struct main_tab *main_settings,
        struct network_popup *network_settings,
        struct input_tab *input,
        struct advanced_input_tab *advanced_input,
        struct output_tab *output,
        struct decoders_tab *decoders,
        struct credits_tab *credits,
        struct debug_tab *debug,
        struct burned_subs_tab *burned_subs);

file_browser.c || file_browser.h

void die(const char *fmt, ...);
char* file_load(const char* path, size_t* siz);
char* str_duplicate(const char *src);
void dir_free_list(char **list, size_t size);
char** dir_list(const char *dir, int return_subdirs, size_t *count);
struct file_group FILE_GROUP(enum file_groups group, const char *name, struct nk_image *icon);
struct file FILE_DEF(enum file_types type, const char *suffix, enum file_groups group);
struct nk_image* media_icon_for_file(struct media *media, const char *file);
void media_init(struct media *media);
void file_browser_reload_directory_content(struct file_browser *browser, const char *path);
void get_drives(struct file_browser *browser);
void file_browser_init(struct file_browser *browser, struct media *media);
void file_browser_free(struct file_browser *browser);
int file_browser_run(struct file_browser *browser, struct nk_context *ctx, struct main_tab *main_settings, struct output_tab *output, struct debug_tab *debug, struct hd_homerun_tab *hd_homerun);

popups.c || popups.h

void draw_network_popup(struct nk_context *ctx, int *show_preferences_network, struct network_popup *network_settings);
void draw_getting_started_popup(struct nk_context *ctx, int *show_getting_started);
void draw_about_ccx_popup(struct nk_context *ctx, int *show_about_ccx, struct nk_user_font *droid_big, struct nk_user_font *droid_head);
void draw_progress_details_popup(struct nk_context *ctx, int *show_progress_details, struct main_tab *main_settings);
void draw_color_popup(struct nk_context *ctx, struct output_tab *output);
void draw_thread_popup(struct nk_context *ctx, int *show_thread_popup);
void setup_network_settings(struct network_popup *network_settings);

preview.c || preview.h

int preview(struct nk_context *ctx, int x, int y, int width, int height, struct main_tab *main_settings);

save_load_data.c || save_load_data.h

void load_data(FILE *file,
        struct main_tab *main_settings,
        struct input_tab *input,
        struct advanced_input_tab *advanced_input,
        struct output_tab *output,
        struct decoders_tab *decoders,
        struct credits_tab *credits,
        struct debug_tab *debug,
        struct hd_homerun_tab *hd_homerun,
        struct burned_subs_tab *burned_subs);

void save_data(FILE *file,
        struct main_tab *main_settings,
        struct input_tab *input,
        struct advanced_input_tab *advanced_input,
        struct output_tab *output,
        struct decoders_tab *decoders,
        struct credits_tab *credits,
        struct debug_tab *debug,
        struct hd_homerun_tab *hd_homerun,
        struct burned_subs_tab *burned_subs);

void write_credits(FILE* file, struct credits_tab *credits);
void read_credits(FILE* file, struct credits_tab *credits);

terminal.c

int terminal(struct nk_context *ctx, int x, int y, int width, int height, char *command);

About CCExtractor specific functions

int activity(struct nk_context *ctx, int x, int y, int width, int height, struct main_tab *main_settings);

Info:

--Contains the procedure to be carried out when Activity Window is toggled.

Parameters:
  • *ctx - pointer to nk_context structure.
  • x - X co-ordinate to draw Activity Window
  • y - Y co-ordinate to draw Activty Window.
  • width - width of window to draw.
  • height - height of window to draw.
  • *main_settings - pointer to main_tab structure.
Return Type: int
  • Returns non-zero value if window is not closed.
  • Returns zero if window is closed.

void setup_main_settings(struct main_tab *main_settings);

Info:

Setups the required defaults of variables in main_tab structure.

Parameters:
  • *main_settings - pointer to main_tab structure.
Return Type: void

char* truncate_path_string(char *filePath);

Info:

Truncated the Path String of file to visible area using ...

Parameters:
  • *filePath - Pointer to string to be truncated.
Return Type: *char
  • Returns pointer to truncated string.

void remove_path_entry(struct main_tab *main_settings, int indexToRemove);

Info:

Removes the selected path in the extraction queue (Selected entry's index is passed).

Parameters:
  • *main_settings - pointer to main_tab structure.
  • indexToRemove - index of the string to be removed from dynamic array of many strings.
Return Type: void

void* read_activity_data(void *read_args);

Info:

Reads activity data related to CCExtractor on stdout. And outputs to activity window (Updates variables that code of activity window uses).

Parameters:
  • *read_args - Pointer to void, because thread functions don't allow any datatype as argument or return type. Therefore they are passed as void then typecasted later in the function.
Return type: void*

void* <a id="func-read-data-from-thread>read_data_from_thread(void* read_args);

Info:

Reads data from--gui_mode_reports redirected from stderr to a file. Reads the subtitles extracted in realtime and updates the variables for the same, updates the state of progress bar. Also, lanches read_activity_data in a new thread.

Parameters:
  • *read_args - Pointer to void, because thread functions don't allow any datatype as argument or return type. Therefore they are passed as void then typecasted later in the function.
Return type: void*

void* extract_thread(void* extract_args);

Info:

Passes command with all options from GUI to CLI CCExtractor.

Parameters:
  • *extract_args - Pointer to void, because thread functions don't allow any datatype as argument or return type. Therefore they are passed as void then typecasted later in the function.
Return type: void*

void* feed_files_for_extraction(void* file_args);

Info:

Feeds file by file to a new thread and waits until its extraction is done. This is done until all the files in extraction queue are extracted.

Parameters:
  • *file_args - Pointer to void, because thread functions don't allow any datatype as argument or return type. Therefore they are passed as void then typecasted later in the function.
Return type: void*

void setup_and_create_thread(struct main_tab *main_settings, struct built_string *command);

Info:

Initialises some values for the structure used in thread arguments and creates feed_files_for_extraction.

Parameters:
  • *main_settings - Pointer to main_tab struct.
  • *command - Pointer to built_string struct.
Return type: void*

void* find_hd_homerun_devices(void *args);

Finds devices connected to HD HomeRun Network.

Parameters:

  • *args - Pointer to void, because thread functions don't allow any datatype as argument or return type. Therefore they are passed as void then typecasted later in the function.

Return type: void*

void* setup_hd_homerun_device(void *args);

Info:

Sets up various parameters required to extract subtitle from incoming stream from a HD HomeRun Device.

Parameters:
  • *args - Pointer to void, because thread functions don't allow any datatype as argument or return type. Therefore they are passed as void then typecasted later in the function.
Return type: void*

void command_builder(struct built_string *command, struct main_tab *main_settings, struct network_popup *network_settings, struct input_tab *input, struct advanced_input_tab *advanced_input, struct output_tab *output, struct decoders_tab *decoders, struct credits_tab *credits, struct debug_tab *debug, struct burned_subs_tab *burned_subs);

Info:

Fetches the options from the whole GUI and adds the respective CLI commands to the term_string in built_string struct.

Parameters:
  • *command - Pointer to built_string command.
  • *main_settings - Pointer to main_tab struct.
  • *network_settings - Pointer to network_popup struct.
  • *input - Pointer to input_tab struct.
  • *advance_input - Pointer to advanced_input struct.
  • *output - Pointer to output_tab struct.
  • *decoders - Pointer to decoders_tab struct.
  • *credits - Pointer to credits_tab struct.
  • *debug - Pointer to debug_tab struct.
  • *burned_subs - Pointer to burned_subs_tab struct.
Return type: void

void die(const char *fmt, ...);

Info:

Custom function to generate error if something in File Browser goes wrong.

Parameters:
  • *fmt - Format of char string along with place holder for variables.
  • ... - Variables in order of their specified place holder.
Return type: void

char* file_load(const char* path, size_t* siz);

Info:

Custom function to load file and read data from loaded file.

Parameters:
  • *path - Pointer to string literal (Path of the file).
  • *siz - Size of string literal provided (To allocate memory accordingly).
Return type: void

char* str_duplicate(const char *src);

Info:

Dynamically copies specified string to memory.

Parameters:
  • *src - The String to be copied.
Return type: char*
  • Pointer to the string in the memory.

void dir_free_list(char **list, size_t size);

Info:

Frees the memory allocated to Files' and Directories' name and path.

Parameters:
  • **char - Pointer to list (array of strings) to be freed
Return type: void

char** dir_list(const char *dir, int return_subdirs, size_t *count);

Info:

Opens the selected directory and adds its path to list and returns the same list. #####Parameters:

  • *dir - Pointer to string (name of directory to be opened).
  • return_subdirs - nk_true if subdirectories are to be returned then.
  • *count - Number of directories in opened directories.

Retrun type: char**

  • Pointer to List (Array of strings, name of directories and files) is returned.

struct file_group FILE_GROUP(enum file_groups group, const char *name, struct nk_image *icon);

Info:

Initialises variables for file_group struct.

Parameters:
  • group - specifies to which group does the file belong to. Selected from file_groups enum, like FILE_GROUP_MUSIC.
  • *name - Pointer to a string literal (to set name member in file_group.
  • *icon - Pointer to nk_image struct (Holds attributes for loaded image file) to set to iconmember of file_group.
Returnt type: struct file_group
  • Returns a file_group instance with set variables.

struct file FILE_DEF(enum file_types type, const char *suffix, enum file_groups group);

Info:

Initialises variables for file struct.

Parameters:
  • type - specifies which type does the file belong to. Selected from file_types enum, like FILE_TEXT.
  • *suffix - Pointer to string( to set suffix member in file).
  • group - specifies to which group does the file belong to. Selected from file_groups enum, like FILE_GROUP_MUSIC.
Return type: struct file
  • Returns a file instance with set variables.

struct nk_image* media_icon_for_file(struct media *media, const char *file);

Info:

Analyses the files and checks to which file or file_group they belong and assign appropriate icon to the file and returns the same.

Parameters:
  • *media - pointer to media struct.
  • *file - pointer to string literal (name of file with extension)
Return type: struct nk_image*
  • Returns appropriate nk_image corresponding to the file.

void media_init(struct media *media);

Info:

Assigns icons to file and file_group members from.

Parameters:
  • *media - pointer to media struct.

Return type: void

void file_browser_reload_directory_content(struct file_browser *browser, const char *path);

Info:

Updates various variables related to Files/Directories path and names when screen of File Browser reloads. (Due to clicking on a directory or any other button leading to different directory).

Parameters:
  • *browser - Pointer to file_browser struct.
  • *path - Path of the new directory whose contents are to be reloaded and showed on file browser.
Return type: void

void get_drives(struct file_browser *browser);

Info:

NOTE: Windows Specific Function. Detects the number of drives and their respective Drive Letters to show the same in File Browser. #####Parameters:

  • *browser - pointer to file_browser struct.
Return type: void

void file_browser_init(struct file_browser *browser, struct media *media);

Info:

Initialised various variables/attributes required whenever the File Browser is run.

Parameters:
  • *browser - Pointer to file_browser struct.
  • *media - pointer to media struct.
Return type: void

void file_browser_free(struct file_browser *browser);

Info:

Frees the memory allocated to various variables in file_browser_init.

Parameters:
  • *browser - pointer to file_browser struct.
Return type: void

int file_browser_run(struct file_browser *browser, struct nk_context *ctx, struct main_tab *main_settings, struct output_tab *output, struct debug_tab *debug, struct hd_homerun_tab *hd_homerun);

Info:

Provides runtime of File Browser on GUI.

Parameters:
  • *browser - pointer to file_browser struct.
  • *ctx - pointer to nk_context struct.
  • *main_settings - pointer to main_tab struct.
  • *output - poiter to output_tab struct.
  • *debug - pointer to debug_tab struct.
  • *hd_homerun - pointer to hd_homerun_tab struct.
Return type: int
  • Returns 1 if any File name/path is copied to current variable.
  • Returns 0 otherwise.

void <a -d="func-draw-network-popup">draw_network_popup(struct nk_context *ctx, int *show_preferences_network, struct network_popup *network_settings);

Info:

Draws popup with Network Settings on GUI.

Parameters:
  • *ctx - pointer to nk_context struct.
  • *show_preferences_network - pointer to variable status if which triggers the popup.
  • *network_settings - pointer to network_popup struct.
Return type: void

void draw_getting_started_popup(struct nk_context *ctx, int *show_getting_started);

Info:

Draws popup on screen which shows Getting Started Info.

Parameters:
  • *ctx - pointer to nk_context struct.
  • *show_getting_started - pointer to variable status if which triggers the popup.
Return type: void

void draw_about_ccx_popup(struct nk_context *ctx, int *show_about_ccx, struct nk_user_font *droid_big, struct nk_user_font *droid_head);

Info:

Draws popup on screen containing information about CCExtractor.

Parameters:
  • *ctx - pointer to nk_context struct.
  • *show_about_ccx - pointer to variable status if which triggers the popup.
  • *droid_big - pointer to nk_user_font struct.
  • *droid_head - pointer to nk_user_font struct.
Return type: void

void draw_progress_details_popup(struct nk_context *ctx, int *show_progress_details, struct main_tab *main_settings);

Info:

Draws popup on screen which shows progress details.

Parameters:
  • *ctx - pointer to nk_context struct.
  • *show_pogress_details - pointer to variable status if which triggers the popup.
  • *main_settings - pointer to main_tab struct.
Return type: void

void draw_color_popup(struct nk_context *ctx, struct output_tab *output);

Info:

Draws popup on screen which shows color-picker.

Parameters:
  • *ctx - pointer to nk_context struct.
  • *output - pointer to output_tab struct.
Return type: void

void draw_thread_popup(struct nk_context *ctx, int *show_thread_popup);

Info:

This popup is shown if anyhow the GUI is unable to read file.

Parameters:
  • *ctx - pointer to nk_context struct.
  • *show_thread_popup - pointer to variable status if which triggers the popup.
Return type: void

void setup_network_settings(struct network_popup *network_settings);

Info:

Sets up defaults for Network Settings.

Parameters:
  • *network_settings - pointer to network_popup struct.
Return type: void

int preview(struct nk_context *ctx, int x, int y, int width, int height, struct main_tab *main_settings);

Info:

Draws Preview Nuklear window and shows preview strings (lines of subtitles extracted in realtime).

Parameters:
  • *ctx - pointer to nk_context struct.
  • x - X co-ordinate from where to draw window.
  • y - Y co-ordinate from where to draw window.
  • width - width of window.
  • height - height of window.
  • *main_settings - pointer to main_tab struct.
Return type:
  • Returns non-zero value if window is not closed.
  • Returns zero if window is closed.

void load_data(FILE *file, struct main_tab *main_settings, struct input_tab *input, struct advanced_input_tab *advanced_input, struct output_tab *output, struct decoders_tab *decoders, struct credits_tab *credits, struct debug_tab *debug, struct hd_homerun_tab *hd_homerun, struct burned_subs_tab *burned_subs);

Info:

Loads values of all the variables stored in a file at last exit of GUI.

Parameters:
  • *file - pointer to FILE.
  • *main_settings - pointer to main_tab struct.
  • *intput - pointer to input_tab struct.
  • *advanced_input - pointer to advanced_input_tab struct.
  • *output - pointer to output_tab struct.
  • *decoders - pointer to decoders_tab struct.
  • *credits - poitner to credits_tab struct.
  • *debug - pointer to debug_tab struct.
  • *hd_homerun - pointer to hd_homerun_tab struct.
  • *burned_subs - pointer to burned_subs_tab struct.
Return type: void

void save_data(FILE *file, struct main_tab *main_settings, struct input_tab *input, struct advanced_input_tab *advanced_input, struct output_tab *output, struct decoders_tab *decoders, struct credits_tab *credits, struct debug_tab *debug, struct hd_homerun_tab *hd_homerun, struct burned_subs_tab *burned_subs);

info:

Saves values of all the variables as a "Current State" in a file on exit.

Parameters:
  • *file - pointer to FILE.
  • *main_settings - pointer to main_tab struct.
  • *intput - pointer to input_tab struct.
  • *advanced_input - pointer to advanced_input_tab struct.
  • *output - pointer to output_tab struct.
  • *decoders - pointer to decoders_tab struct.
  • *credits - poitner to credits_tab struct.
  • *debug - pointer to debug_tab struct.
  • *hd_homerun - pointer to hd_homerun_tab struct.
  • *burned_subs - pointer to burned_subs_tab struct.
Return type: void

void write_credits(FILE *file, struct credits_tab *credits);

Info:

Writes Credits to files after some operations, since extra\n character gives problems while reading file.

Parameters:
  • *file - pointer to FILE.
  • *credits - pointer to credits_tab struct.
Return type: void

void read_credits(FILE* file, struct credits_tab *credits);

Info:

Reads credits from file in a specific format (as written by write_credits) from file.

Parameters:
  • *file - pointer to FILE.
  • *credits - pointer to credits_tab struct.
Return type: void

int terminal(struct nk_context *ctx, int x, int y, int width, int height, char *command);

Info:

Writes the command string (that would be passed to CLI CCExtractor) in "Terminal" Nuklear Window.

Parameters:
  • *ctx - pointer to nk_context struct.
  • x - X co-ordinate from where to draw the window.
  • y - Y co-ordinate from where to draw the window.
  • width - Width of the window.
  • height - height of the window.
  • *command - String to write on window (the command to be passed).
Return type: int
  • Returns non-zero value if window is not closed.
  • Returns zero if window is closed.

About CCExtractor specific Structures/Variables

main_tab

Info:

Contains all the variables for Main tab.

Variables worth noting:
  • int is_file_browser_active
  • nk_true if File Browser is triggered by any event.
  • nk_false otherwise.
  • int scaleWindowForFileBrowser
  • Sets to nk_true if is_file_browser_active is nk_true to scale the glfwWindow to required size to accommodate File Browser.
  • Sets to nk_false otherwise.

input_tab

Info:

Contains all variables to hold data of options selected/changed and view dynamically generated data to GUI in Input tab.

advanced_input_tab

Info: Contains all variables to hold data of options selected/changed and view dynamically generated data to GUI in Advanced Input tab.

output_tab

#####Info: Contains all variables to hold data of options selected/changed and view dynamically generated data to GUI in Advanced Input tab.

decoders_tab

Info:

Contains all variables to hold data of options selected/changed and view dynamically generated data to GUI in Decoders tab.

credits_tab

Info:

Contains all variables to hold data of options selected/changed and view dynamically generated data to GUI in Credits tab.

debug_tab

Info:

Contains all variables to hold data of options selected/changed and view dynamically generated data to GUI in Debug tab.

hd_homerun_tab

Info:

Contains all variables to hold data of options selected/changed and view dynamically generated data to GUI in HDHomeRun tab.

burned_subs

Info:

Contains all variables to hold data of options selected/changed and view dynamically generated data to GUI in HDHomeRun tab.

networ_popup

Info:

Contains all the variables to store all the Network related options or showing them in GUI dynamically.

About Nuklear Specific functions

int nk_begin(struct nk_context*, const char *title, struct nk_rect bounds, nk_flags flags);

Info:

Draws a basic(and blank) window(Nuklear Window inside main GLFW window) to hold other Nuklear widgets.

Parameters:
  • nk_context* - Pointer to nk_context structure.
  • *title - Title for the so drawn Nuklear Window.
  • bounds - instance of nk_rect structure to hold co-ordinates, width and height of the Nuklear Window.
  • flags - Which flags to pass( from those contained in enum flags) to change behaviour of the Nuklear Window.
Return Type: int
  • Returns true if window creation is successful.
  • Returns false if window creation fails.

void nk_end(struct nk_context *ctx)

Info:

Marks the end of the Nuklear Window.

Parameter:
  • *ctx - Pointer to nk_context structure.
Return type: void

void nk_layout_row_dynamic(struct nk_context*, float height, int cols);

Info:

Used to define a dynamic row layout(to hold widgets), dynamic in the sense that the width is dynamically allocated to widgets.

Parameters:
  • *nk_context - Pointer to nk_context structure.
  • height - height to set for widgets of that row.
  • cols - Columns to set for layout (generally the number of widgets to place).
Return Type: void

void nk_label_wrap(struct nk_context*, const char*);

Info:

Writes a label ( A plain String) and wraps it to the next line if the border of Nuklear Window, Group or Popup is reached. Note: If the text wraps to next line, height for a new line must be considered while defining a layout, else the wrapped text won't be visible (but it will be there).

Parameters:
  • nk_context* - Pointer to nk_context structure.
  • char* - Pointer to string literal (to view).

int nk_window_is_closed(struct nk_context *ctx, const char *name);

Info:

Checks if the active Nuklear Window is closed (by any trigger).

Parameters:
  • *ctx - Pointer to nk_context structure.
  • *name - Pointer to String literal(Name of window to check).
Return type: int
  • Returns true if window is closed (by any trigger).
  • Returns false of window is not closed.

void nk_menubar_begin(struct nk_context *ctx);

Info:

Marks the end of Menu Bar definition(Menubar code).

Parameters:
  • *ctx - Pointer to nk_context structure.
Return type: void

void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);

Info:

Marks the beginning of custom layout. Which means, marking that layout has begun, now the widgets will be pushed row by row as per requirement using nk_layout_row_push.

Parameters:
  • *ctx - Pointer to nk_context structure.
  • fmt - Layout format from provided formats (enum nk_layout_format), example - NK_STATIC, NK_DYNAMIC.
  • row_height - height of row pushed.
  • cols - Number of columns pushed in row.
Return type: void

void nk_layout_row_push(struct nk_context*, float value);

Info:

Pushes a row to hold widgets after defining the beginning of custom layout by nk_layout_row_begin.

Parameters:
  • nk_context* - Pointer to nk_context structure.
  • value - ratio or width of the widget to be pushed next.
Return Type: void

int nk_menu_begin_label(struct nk_context *ctx, const char *text, nk_flags align, struct nk_vec2 size);

Info:

The label of the Menu Item to be pushed, for example - "Preferences" is marked by this function.

Parameters:
  • *ctx - pointer to nk_context structure.
  • *text - pointer to string literal (Title of the Menu, example - "Settings").
  • align - alignment enumeration in nk_flags, example NK_TEXT_LEFT.
  • size - Size of label (as nk_vec2 struct)
Return type: int
  • Returns true if label creation successful.
  • Returns false if label creation fails.

void nk_menubar_end(struct nk_context*);

Info:

Marks the end of the MenuBar definition.

Parameters:
  • nk_context* - Pointer to nk_context structure.
Return type: void

void nk_layout_space_begin(struct nk_context *ctx, enum nk_layout_format fmt, float height, int widget_count);

Info:

Marks the beginning of an empty space (Custom space for proper placement of widgets).

Parameters:
  • *ctx - pointer to nk_context structure.
  • fmt - Layout format as in enu nk_layout_format, example - NK_STATIC, NK_DYNAMIC.
  • height = height of space to be added.
  • widget_count - Number of spaces to add.
Return type: void

void nk_layout_space_end(struct nk_context *ctx);

Info:

Marks the end of custom space (empty) definition.

Parameters:
  • *ctx - pointer to nk_context structure.
Return type: void

int nk_style_push_vec2(struct nk_context* struct nk_vec2*, struct nk_vec2);

Info:

Comes under Style Stack. Used to temporarily modify length, width, spacing related attributes of Styles of Nuklear Context.

Parameters:
  • nk_context* - Pointer to nk_context structure.
  • nk_vec2* - Pointer to attribute to be modified.
  • nk_vec2* - New value in the form nk_vec2(x, y) as an instance of nk_vec2 structure.
Return type: int
  • Returns true if successful.
  • Returns false if unsuccessful.

int nk_style_push_float(struct nk_context*, float*, float);

Info:

Comes under Style Stack. Used to temporarily modify attributes requiring precision with floating point such as rounding value for buttons.

Parameters:
  • nk_context* - Pointer to nk_context structure.
  • float* - Pointer to variable whose value is to be changed.
  • float - new value to set.

int nk_button_label(struct nk_context*, const char *title);

Info:

Draws a Button with provided label.

Parameters:
  • nk_context* - Pointer to nk_context struct.
  • *title - Pointer to string literal (Label to put on button).
Return type: int
  • Returns true of Button is clicked.
  • Returns false of Button is in 'unclicked' state.

int nk_style_pop_float(struct nk_context*);

Info:

Pops the float values modified off the Style Stack. Which means, returns them to original state as they were before being modified by nk_style_push_float.

Paramaters:
  • nk_context* - Pointer to nk_context struct.
Return type: int
  • Returns true if successful.
  • Returns false if unsuccessful.

int nk_group_begin(struct nk_context *ctx, const char *title, nk_flags flags);

Info:

Makes a group with given flags. Looks just like a window created by nk_begin but can be created inside a window.

Parameters:
  • *ctx - pointer to nk_context struct.
  • *title - string literal (Title of the group).
  • flags - All the required flags among available flags in nk_flags.
Return Type: int
  • Returns false if creation unsuccessful.
  • Returns true if creation successful.

void nk_group_end(struct nk_context *ctx);

Info:

Marks the end of the group created by nk_group_begin.

Parameters:
  • *ctx - pointer to nk_context struct.
Return type: void

void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);

Info:

Used to create custom row layout in which widget placement (including spacing) is done using ratios in floating point. Maximum ratio allowed is one. So, if there are two widgets (say buttons) need to placed in 50% available area each. Then ratio will be {0.5f, 0.5f}.

Parameters:
  • nk_context* - pointer to nk_context struct.
  • nk_layout_format - format from available formats in enum nk_layout_format like NK_STATIC , NK_DYNAMIC.
  • height - height of the layout.
  • cols - Number of widgets(including spaces) to be used.
  • *ratio - Ratio for widget placement.
Return type: void

void nk_spacing(struct nk_context*, int cols);

Info:

Used to create spacing (blank) of specified columns.

Parameters:
  • nk_context* - pointer to nk_context struct.
  • cols - Number of columns for which spacing has to be true.
Return type: void

int nk_checkbox_label(struct nk_context *ctx, const char *label, int *active);

Info:

Creates a checkbox with specified label.

Parameters:
  • *ctx - Pointer to nk_context struct.
  • * - Pointer to string literal(Label of checkbox).
  • * - Pointer to variable to store the active value. nk_false if unchecked, nk_true if checked.
Return type: int
  • Returns false if unable to draw widget or old value of *active = new value of *active.
  • Returns true of old value of *active != new value of *active.

int nk_option_label(struct nk_context *ctx, const char *label, int active);

Info:

Draws radio button (among radio group) with specified label.

Parameters:
  • *ctx - pointer to nk_context struct.
  • *label - Pointer to string literal (label of radio button).
  • active - Any check to specify if the radio button is active.
Return type: int
  • Returns true if radio button is active.
  • Returns false if radio button is inactive.

int nk_selectable_label(struct nk_context*, const char*, nk_flags align, int *value);

Info:

Draws a selectable label. (Just like a regular nk_label but with a difference that it can be selected)

Parameters:
  • nk_context* - pointer to nk_context struct.
  • char* - Pointer to string literal (Label to display on GUI).
  • align - required alignment flags from nk_flags like NK_TEXT_LEFT.
  • *value - Pointer to integer variable to store the value if the label is triggered or not.
    • Sets to nk_true if label selected.
    • Sets to nk_false if label is in unselected state.
Return type: int
  • Returns false if unable to draw widget or old value of *value = new value of *value.
  • Returns true of old value of *value != new value of *value.

int nk_combo(struct nk_context*, const char **items, int count, int selected, int item_height, struct nk_vec2 size);

Info:

Draws combobox with given items as array of strings.

Parameters:
  • nk_context* - Pointer to nk_context structure.
  • **items - Array of strings of items to populate the list of combobox.
  • count - Number of items in the combobox.
  • selected - variable to store the index of selected item.
  • item_height - Height to allocate to each item in combobox.
  • size - size of combobox after expansion(when dropdown arrow is clicked). Given as nk_vec2(x, y).
Return type: int
  • Returns the index of selected item.

void nk_label(struct nk_context *ctx, const char *str, nk_flags alignment);

Info:

Draws a plain text on Nuklear Window, Popup or group.

Parameters:
  • *ctx - pointer to nk_context structure.
  • *str - Pointer to string literal (Text to draw).
  • alignment - required flags for text alignment from nk_flags, like NK_TEXT_LEFT.
Return type: void

int nk_progress(struct nk_context *ctx, nk_size *cur, nk_size max, int is_modifyable);

Info:

Draws a progress bar.

Parameters:
  • *ctx - Poitner to nk_context struct.
  • *cur - Realtime value to update in progress bar.
  • max - Maximum value *cur can achieve (usually 100, for 100% progress).
  • is_modifyable -
  • nk_true if progress bar can be modified with other events like mouse click and drag.
  • nk_false if progress bar needs to be modified only by value of *cur
Return type: int
  • Returns false if unable to draw widget or old value of *cur = new value of *cur.
  • Returns true of old value of *cur != new value of *cur.

About Nuklear Specific Structures/Variables

nk_context

Info:

Contains various Variables/attributes related to current Window.

nk_vec2

Info:

A simple structure containing 2 variables x and y. Used for various purposes where 2 variables are required for example.. using offset for position or size of any widget/window.