From facadc840ddc4bdf8eecb25128e857f5b3f352cf Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 8 Jun 2026 15:35:04 +0200 Subject: [PATCH] paint: cleanup --- paint/sources/base.c | 18 ++-- paint/sources/config.c | 32 +++---- paint/sources/console.c | 2 +- paint/sources/globals.h | 72 +++++++-------- paint/sources/main.c | 8 +- .../nodes_material/bake_texture_node.c | 6 +- paint/sources/operator.c | 6 +- paint/sources/plugin.c | 8 +- paint/sources/project.c | 2 +- paint/sources/translator.c | 10 +-- paint/sources/ui/box_preferences.c | 24 ++--- paint/sources/ui/box_projects.c | 2 +- paint/sources/ui/tab_brushes.c | 12 +-- paint/sources/ui/tab_console.c | 12 +-- paint/sources/ui/tab_debug.c | 6 +- paint/sources/ui/tab_fonts.c | 12 +-- paint/sources/ui/tab_layers.c | 44 +++++----- paint/sources/ui/tab_materials.c | 22 ++--- paint/sources/ui/tab_meshes.c | 16 ++-- paint/sources/ui/tab_plugins.c | 4 +- paint/sources/ui/tab_scripts.c | 2 +- paint/sources/ui/tab_stages.c | 4 +- paint/sources/ui/tab_swatches.c | 8 +- paint/sources/ui/tab_textures.c | 14 +-- paint/sources/ui/tab_timeline.c | 28 +++--- paint/sources/ui/ui_base.c | 10 +-- paint/sources/ui/ui_box.c | 2 +- paint/sources/ui/ui_files.c | 34 +++---- paint/sources/ui/ui_header.c | 8 +- paint/sources/ui/ui_menu.c | 40 ++++----- paint/sources/ui/ui_menubar.c | 12 +-- paint/sources/ui/ui_nodes.c | 62 ++++++------- paint/sources/ui/ui_search.c | 6 +- paint/sources/ui/ui_sidebar.c | 46 +++++----- paint/sources/ui/ui_statusbar.c | 2 +- paint/sources/ui/ui_toolbar.c | 88 +++++++++---------- paint/sources/ui/ui_view2d.c | 6 +- 37 files changed, 345 insertions(+), 345 deletions(-) diff --git a/paint/sources/base.c b/paint/sources/base.c index ee4c030f..0ef1d8b3 100644 --- a/paint/sources/base.c +++ b/paint/sources/base.c @@ -140,7 +140,7 @@ gpu_texture_t *base_get_drag_image() { gc_unroot(base_drag_rect); base_drag_rect = string_index_of(base_drag_file, ".") > 0 ? resource_tile50(icons, ICON_FILE) : resource_tile50(icons, ICON_FOLDER_FULL); gc_root(base_drag_rect); - base_drag_tint = g_ui->ops->theme->HIGHLIGHT_COL; + base_drag_tint = g_theme->HIGHLIGHT_COL; return icons; } @@ -160,7 +160,7 @@ gpu_texture_t *base_get_drag_image() { gc_unroot(base_drag_rect); base_drag_rect = base_drag_layer->show_panel ? folder_open : folder_closed; gc_root(base_drag_rect); - base_drag_tint = base_darker(g_ui->ops->theme->LABEL_COL, 0x00202020); + base_drag_tint = base_darker(g_theme->LABEL_COL, 0x00202020); return icons; } if (base_drag_layer != NULL && slot_layer_is_mask(base_drag_layer) && base_drag_layer->fill_material == NULL) { @@ -473,8 +473,8 @@ void base_init() { sys_notify_on_app_state(&base_on_foreground, &base_on_background, &base_on_shutdown); iron_set_save_and_quit_callback(base_save_and_quit_callback); - base_font = data_get_font("font.ttf"); - gc_root(base_font); + g_font = data_get_font("font.ttf"); + gc_root(g_font); base_color_wheel = data_get_image("color_wheel.k"); gc_root(base_color_wheel); @@ -482,9 +482,9 @@ void base_init() { base_color_wheel_gradient = data_get_image("color_wheel_gradient.k"); gc_root(base_color_wheel_gradient); config_load_theme(g_config->theme, false); - base_default_element_w = base_theme->ELEMENT_W; - base_default_element_h = base_theme->ELEMENT_H; - base_default_font_size = base_theme->FONT_SIZE; + base_default_element_w = g_theme->ELEMENT_W; + base_default_element_h = g_theme->ELEMENT_H; + base_default_font_size = g_theme->FONT_SIZE; translator_load_translations(g_config->locale); ui_files_filename = string_copy(tr("untitled")); @@ -495,10 +495,10 @@ void base_init() { // Baked font for fast startup if (string_equals(g_config->locale, "en")) { - draw_font_13(base_font); + draw_font_13(g_font); } else { - draw_font_init(base_font); + draw_font_init(g_font); } ui_nodes_enum_texts = base_combo_enum_texts; diff --git a/paint/sources/config.c b/paint/sources/config.c index c35d0b9c..6c26725c 100644 --- a/paint/sources/config.c +++ b/paint/sources/config.c @@ -460,37 +460,37 @@ i32 config_get_texture_res_pos(i32 i) { } void config_load_theme(char *theme, bool tag_redraw) { - gc_unroot(base_theme); - base_theme = ui_theme_create(); - gc_root(base_theme); + gc_unroot(g_theme); + g_theme = ui_theme_create(); + gc_root(g_theme); if (!string_equals(theme, "default.json")) { buffer_t *b = data_get_blob(string("themes/%s", theme)); ui_theme_t *parsed = json_parse(sys_buffer_to_string(b)); - gc_unroot(base_theme); - base_theme = parsed; - gc_root(base_theme); + gc_unroot(g_theme); + g_theme = parsed; + gc_root(g_theme); } - base_theme->FILL_WINDOW_BG = true; + g_theme->FILL_WINDOW_BG = true; if (tag_redraw) { - g_ui->ops->theme = base_theme; + g_ui->ops->theme = g_theme; base_redraw_ui(); } if (g_config->touch_ui) { // Enlarge elements - base_theme->FULL_TABS = true; - base_theme->ELEMENT_H = 24 + 6; - base_theme->BUTTON_H = 22 + 6; - base_theme->FONT_SIZE = 13 + 2; - base_theme->ARROW_SIZE = 5 + 2; - base_theme->CHECK_SIZE = 15 + 4; - base_theme->CHECK_SELECT_SIZE = 8 + 2; + g_theme->FULL_TABS = true; + g_theme->ELEMENT_H = 24 + 6; + g_theme->BUTTON_H = 22 + 6; + g_theme->FONT_SIZE = 13 + 2; + g_theme->ARROW_SIZE = 5 + 2; + g_theme->CHECK_SIZE = 15 + 4; + g_theme->CHECK_SELECT_SIZE = 8 + 2; } else { - base_theme->FULL_TABS = false; + g_theme->FULL_TABS = false; } } diff --git a/paint/sources/console.c b/paint/sources/console.c index 76dc70f8..2ee2e684 100644 --- a/paint/sources/console.c +++ b/paint/sources/console.c @@ -11,7 +11,7 @@ void console_draw_toast(char *s) { f32 x = iron_window_width() / 2.0; f32 y = iron_window_height() - 200 * scale; draw_filled_rect(x - 200 * scale, y, 400 * scale, 80 * scale); - draw_set_font(base_font, math_floor(22 * scale)); + draw_set_font(g_font, math_floor(22 * scale)); draw_set_color(0xffffffff); draw_string(s, x - draw_string_width(draw_font, draw_font_size, s) / 2.0, y + 40 * scale - draw_font_height(draw_font, draw_font_size) / 2.0); draw_end(); diff --git a/paint/sources/globals.h b/paint/sources/globals.h index 81b1126a..52215cc0 100644 --- a/paint/sources/globals.h +++ b/paint/sources/globals.h @@ -13,23 +13,26 @@ char *manifest_url = "https://armorpaint.org"; char *manifest_url_android = "https://play.google.com/store/apps/details?id=org.armorpaint"; char *manifest_url_ios = "https://apps.apple.com/app/armorpaint/id1533967534"; -context_t *g_context; -project_t *g_project; -config_t *g_config; -any_map_t *g_keymap; -ui_t *g_ui; +context_t *g_context; +project_t *g_project; +config_t *g_config; +any_map_t *g_keymap; +ui_t *g_ui; +draw_font_t *g_font; +ui_theme_t *g_theme; +any_map_t *g_plugins; +any_map_t *g_operators; any_map_t *ui_children; any_map_t *ui_nodes_custom_buttons; -gpu_texture_t *lut_image = NULL; -i32 lut_size = 0; -gpu_texture_t *layers_temp_image = NULL; -gpu_texture_t *layers_expa = NULL; -gpu_texture_t *layers_expb = NULL; -gpu_texture_t *layers_expc = NULL; -f32 layers_default_base = 0.5; -f32 layers_default_rough = 0.4; -any_map_t *operator_ops; +gpu_texture_t *lut_image = NULL; +i32 lut_size = 0; +gpu_texture_t *layers_temp_image = NULL; +gpu_texture_t *layers_expa = NULL; +gpu_texture_t *layers_expb = NULL; +gpu_texture_t *layers_expc = NULL; +f32 layers_default_base = 0.5; +f32 layers_default_rough = 0.4; ui_align_t config_button_align = UI_ALIGN_LEFT; char *config_button_spacing = " "; any_imap_t *physics_body_object_map; @@ -109,19 +112,17 @@ char *ui_files_default_path = "/"; char *ui_files_filename; char *ui_files_path; -char *ui_files_last_path = ""; -bool base_ui_enabled = true; -bool base_view3d_show = true; -bool base_is_dragging = false; -bool base_is_resizing = false; -asset_t *base_drag_asset = NULL; -swatch_color_t *base_drag_swatch = NULL; -char *base_drag_file = NULL; -gpu_texture_t *base_drag_file_icon = NULL; -f32 base_drag_off_x = 0.0; -f32 base_drag_off_y = 0.0; -draw_font_t *base_font = NULL; -ui_theme_t *base_theme; +char *ui_files_last_path = ""; +bool base_ui_enabled = true; +bool base_view3d_show = true; +bool base_is_dragging = false; +bool base_is_resizing = false; +asset_t *base_drag_asset = NULL; +swatch_color_t *base_drag_swatch = NULL; +char *base_drag_file = NULL; +gpu_texture_t *base_drag_file_icon = NULL; +f32 base_drag_off_x = 0.0; +f32 base_drag_off_y = 0.0; i32 base_default_element_w = 100; i32 base_default_element_h = 28; i32 base_default_font_size = 13; @@ -245,7 +246,6 @@ any_map_t *util_mesh_unwrappers; i32 ui_header_default_h = 30; i32 ui_header_h; ui_handle_t *ui_header_handle; -any_map_t *plugin_map; any_map_t *parser_logic_custom_nodes; any_map_t *resource_bundled; i32 render_path_raytrace_bake_rays_pix = 0; @@ -333,14 +333,6 @@ mat4_t render_path_raytrace_help_mat; gpu_texture_t *render_path_raytrace_last_envmap = NULL; bool render_path_raytrace_is_bake = false; -#ifdef IRON_DIRECT3D12 -char *render_path_raytrace_ext = ".cso"; -#elif defined(IRON_METAL) -char *render_path_raytrace_ext = ".metal"; -#else -char *render_path_raytrace_ext = ".spirv"; -#endif - bool sculpt_push_undo = false; i32 ui_statusbar_default_h = 33; char *parser_material_bake_passthrough_strength = "0.0"; @@ -352,6 +344,14 @@ ui_node_t *neural_node_current; i32 neural_node_downloading = 0; neural_node_model_t_array_t *neural_node_models = NULL; +#ifdef IRON_DIRECT3D12 +char *render_path_raytrace_ext = ".cso"; +#elif defined(IRON_METAL) +char *render_path_raytrace_ext = ".metal"; +#else +char *render_path_raytrace_ext = ".spirv"; +#endif + char *str_hue_sat = "\ fun hsv_to_rgb(c: float3): float3 { \ var K: float4 = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); \ diff --git a/paint/sources/main.c b/paint/sources/main.c index c7c5e2a9..5ad4011b 100644 --- a/paint/sources/main.c +++ b/paint/sources/main.c @@ -246,8 +246,8 @@ void _kickstart() { ui_nodes_custom_buttons = any_map_create(); gc_root(ui_nodes_custom_buttons); - operator_ops = any_map_create(); - gc_root(operator_ops); + g_operators = any_map_create(); + gc_root(g_operators); physics_body_object_map = any_imap_create(); gc_root(physics_body_object_map); @@ -431,8 +431,8 @@ void _kickstart() { ui_header_handle = ui_handle_create(); gc_root(ui_header_handle); - plugin_map = any_map_create(); - gc_root(plugin_map); + g_plugins = any_map_create(); + gc_root(g_plugins); parser_logic_custom_nodes = any_map_create(); gc_root(parser_logic_custom_nodes); diff --git a/paint/sources/nodes_material/bake_texture_node.c b/paint/sources/nodes_material/bake_texture_node.c index eb1e54a2..8f48535f 100644 --- a/paint/sources/nodes_material/bake_texture_node.c +++ b/paint/sources/nodes_material/bake_texture_node.c @@ -147,15 +147,15 @@ static void bake_texture_node_button(i32 node_id) { progress = 1.0; } - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->HIGHLIGHT_COL; + i32 _BUTTON_COL = g_theme->BUTTON_COL; + g_theme->BUTTON_COL = g_theme->HIGHLIGHT_COL; ui_handle_t *bake_h = ui_nest(h, 12); bake_h->f = progress; char *label = string("%d%%", (i32)(progress * 100)); ui_slider(bake_h, label, 0.0, 1.0, true, 100, false, UI_ALIGN_CENTER, true); - g_ui->ops->theme->BUTTON_COL = _BUTTON_COL; + g_theme->BUTTON_COL = _BUTTON_COL; if (g_ui->is_hovered && g_ui->input_released) { g_context->pdirty = 0; // Stop baking diff --git a/paint/sources/operator.c b/paint/sources/operator.c index ebc5a254..143b5dbc 100644 --- a/paint/sources/operator.c +++ b/paint/sources/operator.c @@ -2,12 +2,12 @@ #include "global.h" void operator_register(char *name, void (*call)(void)) { - any_map_set(operator_ops, name, call); + any_map_set(g_operators, name, call); } void operator_run(char *name) { - if (any_map_get(operator_ops, name) != NULL) { - void (*cb)(void) = any_map_get(operator_ops, name); + if (any_map_get(g_operators, name) != NULL) { + void (*cb)(void) = any_map_get(g_operators, name); cb(); } } diff --git a/paint/sources/plugin.c b/paint/sources/plugin.c index 9c158212..91eb7b47 100644 --- a/paint/sources/plugin.c +++ b/paint/sources/plugin.c @@ -6,7 +6,7 @@ char *_plugin_name; plugin_t *plugin_create() { plugin_t *p = GC_ALLOC_INIT(plugin_t, {0}); p->name = string_copy(_plugin_name); - any_map_set(plugin_map, p->name, p); + any_map_set(g_plugins, p->name, p); return p; } @@ -18,18 +18,18 @@ void plugin_start(char *plugin) { minic_ctx_t *ctx = minic_eval_named(sys_buffer_to_string(blob), plugin); data_delete_blob(string("plugins/%s", plugin)); // Store context on the plugin so callbacks can use it and it can be freed on stop - plugin_t *p = any_map_get(plugin_map, plugin); + plugin_t *p = any_map_get(g_plugins, plugin); p->ctx = ctx; } void plugin_stop(char *plugin) { - plugin_t *p = any_map_get(plugin_map, plugin); + plugin_t *p = any_map_get(g_plugins, plugin); if (p->on_delete != NULL) { minic_ctx_call_fn(p->ctx, p->on_delete, NULL, 0); } minic_ctx_free(p->ctx); p->ctx = NULL; - map_delete(plugin_map, plugin); + map_delete(g_plugins, plugin); } void plugin_notify_on_ui(plugin_t *plugin, void *f) { diff --git a/paint/sources/project.c b/paint/sources/project.c index 70affbea..7ec907c9 100644 --- a/paint/sources/project.c +++ b/paint/sources/project.c @@ -207,7 +207,7 @@ void project_new(bool reset_layers) { g_context->brush = g_project->_->brushes->buffer[0]; g_project->_->fonts = any_array_create_from_raw( (void *[]){ - slot_font_create("default.ttf", base_font, ""), + slot_font_create("default.ttf", g_font, ""), }, 1); g_context->font = g_project->_->fonts->buffer[0]; diff --git a/paint/sources/translator.c b/paint/sources/translator.c index 6785e4c7..ca484848 100644 --- a/paint/sources/translator.c +++ b/paint/sources/translator.c @@ -62,13 +62,13 @@ void translator_init_font_on_next_frame(void *_) { f->glyphs_version = 0; draw_font_init(f); } - gc_unroot(base_font); - base_font = f; + gc_unroot(g_font); + g_font = f; + gc_root(g_font); // Scale up the font size and elements width a bit - gc_root(base_font); - base_theme->FONT_SIZE = math_floor(base_default_font_size * font_scale); - base_theme->ELEMENT_W = math_floor(base_default_element_w * (!string_equals(g_config->locale, "en") ? 1.4 : 1.0)); + g_theme->FONT_SIZE = math_floor(base_default_font_size * font_scale); + g_theme->ELEMENT_W = math_floor(base_default_element_w * (!string_equals(g_config->locale, "en") ? 1.4 : 1.0)); ui_set_font(g_ui, f); ui_set_scale(UI_SCALE()); diff --git a/paint/sources/ui/box_preferences.c b/paint/sources/ui/box_preferences.c index 1689e646..e9e2030b 100644 --- a/paint/sources/ui/box_preferences.c +++ b/paint/sources/ui/box_preferences.c @@ -34,7 +34,7 @@ void box_preferences_interface_tab_reset_layout_menu() { } void box_preferences_interface_tab_restore_menu_import_on_next_frame(config_t *raw) { - g_ui->ops->theme->ELEMENT_H = base_default_element_h; + g_theme->ELEMENT_H = base_default_element_h; config_import_from(raw); box_preferences_set_scale(); make_material_parse_mesh_material(); @@ -48,7 +48,7 @@ void box_preferences_interface_tab_restore_menu_import(char *path) { } void box_preferences_interface_tab_restore_menu_confirm(void *_) { - g_ui->ops->theme->ELEMENT_H = base_default_element_h; + g_theme->ELEMENT_H = base_default_element_h; config_restore(); box_preferences_set_scale(); if (g_config->plugins != NULL) { @@ -63,7 +63,7 @@ void box_preferences_interface_tab_restore_menu_confirm(void *_) { box_preferences_files_keymap = NULL; make_material_parse_mesh_material(); make_material_parse_paint_material(true); - ui_base_set_viewport_col(g_ui->ops->theme->VIEWPORT_COL); + ui_base_set_viewport_col(g_theme->VIEWPORT_COL); } void box_preferences_interface_tab_restore_menu() { @@ -191,8 +191,8 @@ void box_preferences_interface_tab() { void box_preferences_theme_tab_theme_field_menu() { g_ui->changed = false; - i32 color = ui_color_wheel(_box_preferences_h, false, -1, 11 * g_ui->ops->theme->ELEMENT_H * UI_SCALE(), true, NULL, NULL); - u32 *u32_theme = base_theme; + i32 color = ui_color_wheel(_box_preferences_h, false, -1, 11 * g_theme->ELEMENT_H * UI_SCALE(), true, NULL, NULL); + u32 *u32_theme = g_theme; *(u32_theme + _box_preferences_i) = color; if (g_ui->changed) { ui_menu_keep_open = true; @@ -215,7 +215,7 @@ void box_preferences_theme_tab_export(char *path) { if (!ends_with(path, ".json")) { path = string("%s.json", path); } - iron_file_save_bytes(path, sys_string_to_buffer(box_preferences_theme_to_json(base_theme)), 0); + iron_file_save_bytes(path, sys_string_to_buffer(box_preferences_theme_to_json(g_theme)), 0); } void box_preferences_theme_tab_import(char *path) { @@ -230,7 +230,7 @@ void box_preferences_theme_tab_new_box() { } char *theme_name = ui_text_input(h, tr("Name"), UI_ALIGN_LEFT, true, false); if (ui_icon_button(tr("OK"), ICON_CHECK, UI_ALIGN_CENTER) || g_ui->is_return_down) { - char *template = box_preferences_theme_to_json(base_theme); + char *template = box_preferences_theme_to_json(g_theme); if (!ends_with(theme_name, ".json")) { theme_name = string("%s.json", theme_name); } @@ -289,7 +289,7 @@ void box_preferences_theme_tab() { // Theme fields char *theme_search = to_lower_case(box_preferences_theme_hsearch->text); ui_handle_t *h_list = ui_handle(__ID__); - u32 *u32_theme = base_theme; + u32 *u32_theme = g_theme; g_ui->input_enabled = !ui_menu_show; for (i32 i = 0; i < ui_theme_keys_count; ++i) { char *key = ui_theme_keys[i]; @@ -354,7 +354,7 @@ void box_preferences_theme_tab() { } if (g_ui->changed) { g_ui->elements_baked = false; - g_ui->font_size = g_ui->ops->theme->FONT_SIZE; + g_ui->font_size = g_theme->FONT_SIZE; } } g_ui->input_enabled = true; @@ -849,14 +849,14 @@ void box_preferences_model_panel(neural_node_model_t *m) { box_preferences_htab->redraws = 2; iron_delay_idle_sleep(); - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->HIGHLIGHT_COL; + i32 _BUTTON_COL = g_theme->BUTTON_COL; + g_theme->BUTTON_COL = g_theme->HIGHLIGHT_COL; ui_handle_t *h = ui_handle(__ID__); h->f = f / (float)parse_float(m->size); ui_slider(h, string("%s / %s", downloaded, m->size), 0.0, 1.0, true, 100, false, UI_ALIGN_CENTER, true); - g_ui->ops->theme->BUTTON_COL = _BUTTON_COL; + g_theme->BUTTON_COL = _BUTTON_COL; g_ui->enabled = true; } diff --git a/paint/sources/ui/box_projects.c b/paint/sources/ui/box_projects.c index 1d8cdde5..0c2d87b4 100644 --- a/paint/sources/ui/box_projects.c +++ b/paint/sources/ui/box_projects.c @@ -119,7 +119,7 @@ void box_projects_tab() { i32 uix = g_ui->_x; if (icon != NULL) { - ui_fill(0, 0, 128, 128, g_ui->ops->theme->SEPARATOR_COL); + ui_fill(0, 0, 128, 128, g_theme->SEPARATOR_COL); i32 state = ui_image(icon, 0xffffffff, 128 * UI_SCALE()); if (state == UI_STATE_RELEASED) { diff --git a/paint/sources/ui/tab_brushes.c b/paint/sources/ui/tab_brushes.c index c23a4887..2180b7af 100644 --- a/paint/sources/ui/tab_brushes.c +++ b/paint/sources/ui/tab_brushes.c @@ -120,10 +120,10 @@ void tab_brushes_draw(ui_handle_t *htab) { if (g_config->window_scale > 1) { w += math_floor(g_config->window_scale * 2); } - ui_fill(-1, -2, w + 3, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-1, w - off, w + 3, 2 + off, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-1, -2, 2, w + 3, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(w + 1, -2, 2, w + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-1, -2, w + 3, 2, g_theme->HIGHLIGHT_COL); + ui_fill(-1, w - off, w + 3, 2 + off, g_theme->HIGHLIGHT_COL); + ui_fill(-1, -2, 2, w + 3, g_theme->HIGHLIGHT_COL); + ui_fill(w + 1, -2, 2, w + 4, g_theme->HIGHLIGHT_COL); } uix = g_ui->_x; @@ -131,7 +131,7 @@ void tab_brushes_draw(ui_handle_t *htab) { i32 tile = UI_SCALE() > 1 ? 100 : 50; if (base_drag_brush != NULL && tab_brushes_drag_pos == i) { - ui_fill(-1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-1, -2, 2, imgw_val + 4, g_theme->HIGHLIGHT_COL); } ui_state_t state = g_project->_->brushes->buffer[i]->preview_ready @@ -199,7 +199,7 @@ void tab_brushes_draw(ui_handle_t *htab) { if (base_drag_brush != NULL && tab_brushes_drag_pos == g_project->_->brushes->length) { g_ui->_x = uix; g_ui->_y = uiy; - ui_fill(imgw_val + 1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(imgw_val + 1, -2, 2, imgw_val + 4, g_theme->HIGHLIGHT_COL); } if (!drag_pos_set) { diff --git a/paint/sources/ui/tab_console.c b/paint/sources/ui/tab_console.c index 9f895320..1382a7f4 100644 --- a/paint/sources/ui/tab_console.c +++ b/paint/sources/ui/tab_console.c @@ -124,11 +124,11 @@ void tab_console_draw(ui_handle_t *htab) { ui_end_sticky(); - draw_font_t *_font = g_ui->ops->font; - i32 _font_size = g_ui->font_size; - i32 _element_offset = g_ui->ops->theme->ELEMENT_OFFSET; - g_ui->ops->theme->ELEMENT_OFFSET = 0; - draw_font_t *f = data_get_font("font_mono.ttf"); + draw_font_t *_font = g_font; + i32 _font_size = g_ui->font_size; + i32 _element_offset = g_theme->ELEMENT_OFFSET; + g_theme->ELEMENT_OFFSET = 0; + draw_font_t *f = data_get_font("font_mono.ttf"); ui_set_font(g_ui, f); g_ui->font_size = math_floor(15 * UI_SCALE()); for (i32 i = 0; i < console_last_traces->length; ++i) { @@ -167,7 +167,7 @@ void tab_console_draw(ui_handle_t *htab) { } } - g_ui->ops->theme->ELEMENT_OFFSET = _element_offset; + g_theme->ELEMENT_OFFSET = _element_offset; row = f32_array_create_from_raw( (f32[]){ diff --git a/paint/sources/ui/tab_debug.c b/paint/sources/ui/tab_debug.c index 2801c203..701d89b9 100644 --- a/paint/sources/ui/tab_debug.c +++ b/paint/sources/ui/tab_debug.c @@ -12,7 +12,7 @@ void tab_debug_draw_list(ui_handle_t *list_handle, object_t *current_object) { // Highlight every other line if (tab_debug_line_counter % 2 == 0) { - draw_set_color(g_ui->ops->theme->SEPARATOR_COL); + draw_set_color(g_theme->SEPARATOR_COL); draw_filled_rect(0, g_ui->_y, g_ui->_window_w, UI_ELEMENT_H()); draw_set_color(0xffffffff); } @@ -36,7 +36,7 @@ void tab_debug_draw_list(ui_handle_t *list_handle, object_t *current_object) { g_ui->_x += 18; // Sign offset // Draw line that shows parent relations - draw_set_color(g_ui->ops->theme->BUTTON_COL); + draw_set_color(g_theme->BUTTON_COL); draw_line(g_ui->_x - 10, g_ui->_y + UI_ELEMENT_H() / 2.0, g_ui->_x, g_ui->_y + UI_ELEMENT_H() / 2.0, 1.0); draw_set_color(0xffffffff); @@ -59,7 +59,7 @@ void tab_debug_draw_list(ui_handle_t *list_handle, object_t *current_object) { } // Draw line that shows parent relations - draw_set_color(g_ui->ops->theme->BUTTON_COL); + draw_set_color(g_theme->BUTTON_COL); draw_line(g_ui->_x + 14, current_y, g_ui->_x + 14, g_ui->_y - UI_ELEMENT_H() / 2.0, 1.0); draw_set_color(0xffffffff); } diff --git a/paint/sources/ui/tab_fonts.c b/paint/sources/ui/tab_fonts.c index b04ab005..1a0430d9 100644 --- a/paint/sources/ui/tab_fonts.c +++ b/paint/sources/ui/tab_fonts.c @@ -110,10 +110,10 @@ void tab_fonts_draw(ui_handle_t *htab) { if (g_config->window_scale > 1) { w += math_floor(g_config->window_scale * 2); } - ui_fill(-1, -2, w + 3, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-1, w - off, w + 3, 2 + off, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-1, -2, 2, w + 3, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(w + 1, -2, 2, w + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-1, -2, w + 3, 2, g_theme->HIGHLIGHT_COL); + ui_fill(-1, w - off, w + 3, 2 + off, g_theme->HIGHLIGHT_COL); + ui_fill(-1, -2, 2, w + 3, g_theme->HIGHLIGHT_COL); + ui_fill(w + 1, -2, 2, w + 4, g_theme->HIGHLIGHT_COL); } uix = g_ui->_x; @@ -121,7 +121,7 @@ void tab_fonts_draw(ui_handle_t *htab) { i32 tile = UI_SCALE() > 1 ? 100 : 50; if (base_drag_font != NULL && tab_fonts_drag_pos == i) { - ui_fill(-1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-1, -2, 2, imgw_val + 4, g_theme->HIGHLIGHT_COL); } ui_state_t state = UI_STATE_IDLE; @@ -190,7 +190,7 @@ void tab_fonts_draw(ui_handle_t *htab) { if (base_drag_font != NULL && tab_fonts_drag_pos == g_project->_->fonts->length) { g_ui->_x = uix; g_ui->_y = uiy; - ui_fill(imgw_val + 1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(imgw_val + 1, -2, 2, imgw_val + 4, g_theme->HIGHLIGHT_COL); } if (!drag_pos_set) { diff --git a/paint/sources/ui/tab_layers.c b/paint/sources/ui/tab_layers.c index ce8f728f..e2a36f8c 100644 --- a/paint/sources/ui/tab_layers.c +++ b/paint/sources/ui/tab_layers.c @@ -129,11 +129,11 @@ ui_state_t tab_layers_draw_layer_icon(slot_layer_t *l, i32 i, f32 uix, f32 uiy, if (!is_typing) { if (i < 9 && operator_shortcut(any_map_get(g_keymap, "select_layer"), SHORTCUT_TYPE_DOWN)) { char *number = i32_to_string(i + 1); - i32 width = draw_string_width(g_ui->ops->font, g_ui->font_size, number) + 10; - i32 height = draw_font_height(g_ui->ops->font, g_ui->font_size); - draw_set_color(g_ui->ops->theme->TEXT_COL); + i32 width = draw_string_width(g_font, g_ui->font_size, number) + 10; + i32 height = draw_font_height(g_font, g_ui->font_size); + draw_set_color(g_theme->TEXT_COL); draw_filled_rect(uix, uiy, width, height); - draw_set_color(g_ui->ops->theme->BUTTON_COL); + draw_set_color(g_theme->BUTTON_COL); draw_string(number, uix + 5, uiy); } } @@ -144,7 +144,7 @@ ui_state_t tab_layers_draw_layer_icon(slot_layer_t *l, i32 i, f32 uix, f32 uiy, rect_t *folder_closed = resource_tile50(icons, ICON_FOLDER_FULL); rect_t *folder_open = resource_tile50(icons, ICON_FOLDER_OPEN); rect_t *folder = l->show_panel ? folder_open : folder_closed; - return ui_sub_image(icons, base_darker(g_ui->ops->theme->LABEL_COL, 0x00202020), icon_h, folder->x, folder->y, folder->w, folder->h); + return ui_sub_image(icons, base_darker(g_theme->LABEL_COL, 0x00202020), icon_h, folder->x, folder->y, folder->w, folder->h); } } @@ -154,7 +154,7 @@ void tab_layers_draw_layer_slot_mini(slot_layer_t *l, i32 i) { ui_state_t state = tab_layers_draw_layer_icon(l, i, uix, uiy, true); tab_layers_handle_layer_icon_state(l, i, state, uix, uiy); g_ui->_x = uix; - g_ui->_y = uiy + g_ui->ops->theme->ELEMENT_H * 2 * UI_SCALE(); + g_ui->_y = uiy + g_theme->ELEMENT_H * 2 * UI_SCALE(); } void tab_layers_delete_layer(slot_layer_t *l) { @@ -348,7 +348,7 @@ bool tab_layers_has_children(slot_layer_t *l) { } void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { - i32 step = g_ui->ops->theme->ELEMENT_H; + i32 step = g_theme->ELEMENT_H; f32 center = (step / 2.0) * UI_SCALE(); f32 uiw = g_ui->_w; f32 uix = g_ui->_x; @@ -367,7 +367,7 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { rect_t *r = resource_tile18(icons, l->visible ? ICON18_EYE_ON : ICON18_EYE_OFF); g_ui->_x = uix + 4; g_ui->_y = uiy + 3 + center; - i32 col = g_ui->ops->theme->HOVER_COL + 0x00282828; + i32 col = g_theme->HOVER_COL + 0x00282828; bool parent_hidden = l->parent != NULL && (!l->parent->visible || (l->parent->parent != NULL && !l->parent->parent->visible)); if (parent_hidden) { col -= 0x99000000; @@ -478,18 +478,18 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { } void tab_layers_draw_layer_highlight(slot_layer_t *l, bool mini) { - i32 step = g_ui->ops->theme->ELEMENT_H; + i32 step = g_theme->ELEMENT_H; // Separator line - ui_fill(0, 0, (g_ui->_w / (float)UI_SCALE() - 2), 1 * UI_SCALE(), g_ui->ops->theme->SEPARATOR_COL); + ui_fill(0, 0, (g_ui->_w / (float)UI_SCALE() - 2), 1 * UI_SCALE(), g_theme->SEPARATOR_COL); // Highlight selected if (g_context->layer == l) { if (mini) { - ui_rect(1, -step * 2, g_ui->_w / (float)UI_SCALE() - 1, step * 2 + (mini ? -1 : 1), g_ui->ops->theme->HIGHLIGHT_COL, 3); + ui_rect(1, -step * 2, g_ui->_w / (float)UI_SCALE() - 1, step * 2 + (mini ? -1 : 1), g_theme->HIGHLIGHT_COL, 3); } else { - ui_rect(1, -step * 2 - 1, g_ui->_w / (float)UI_SCALE() - 2, step * 2 + (mini ? -2 : 1), g_ui->ops->theme->HIGHLIGHT_COL, 2); + ui_rect(1, -step * 2 - 1, g_ui->_w / (float)UI_SCALE() - 2, step * 2 + (mini ? -2 : 1), g_theme->HIGHLIGHT_COL, 2); } } } @@ -921,7 +921,7 @@ void tab_layers_draw_layer_slot(slot_layer_t *l, i32 i, bool mini) { return; } - i32 step = g_ui->ops->theme->ELEMENT_H; + i32 step = g_theme->ELEMENT_H; f32 checkw = (g_ui->_window_w / 100.0 * 8) / (float)UI_SCALE(); // Highlight drag destination @@ -937,14 +937,14 @@ void tab_layers_draw_layer_slot(slot_layer_t *l, i32 i, bool mini) { bool nested_group = slot_layer_is_group(base_drag_layer) && to_group; if (!nested_group) { if (slot_layer_can_move(g_context->layer, g_context->drag_dest)) { - ui_fill(checkw, step * 2, (g_ui->_window_w / (float)UI_SCALE() - 2) - checkw, 2 * UI_SCALE(), g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(checkw, step * 2, (g_ui->_window_w / (float)UI_SCALE() - 2) - checkw, 2 * UI_SCALE(), g_theme->HIGHLIGHT_COL); } } } else if (i == g_project->_->layers->length - 1 && mouse_y < absy + step) { g_context->drag_dest = g_project->_->layers->length - 1; if (slot_layer_can_move(g_context->layer, g_context->drag_dest)) { - ui_fill(checkw, 0, (g_ui->_window_w / (float)UI_SCALE() - 2) - checkw, 2 * UI_SCALE(), g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(checkw, 0, (g_ui->_window_w / (float)UI_SCALE() - 2) - checkw, 2 * UI_SCALE(), g_theme->HIGHLIGHT_COL); } } } @@ -952,13 +952,13 @@ void tab_layers_draw_layer_slot(slot_layer_t *l, i32 i, bool mini) { if (mouse_y > absy + step && mouse_y < absy + step * 3) { g_context->drag_dest = i; if (tab_layers_can_drop_new_layer(i)) { - ui_fill(checkw, 2 * step, (g_ui->_window_w / (float)UI_SCALE() - 2) - checkw, 2 * UI_SCALE(), g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(checkw, 2 * step, (g_ui->_window_w / (float)UI_SCALE() - 2) - checkw, 2 * UI_SCALE(), g_theme->HIGHLIGHT_COL); } } else if (i == g_project->_->layers->length - 1 && mouse_y < absy + step) { g_context->drag_dest = g_project->_->layers->length; if (tab_layers_can_drop_new_layer(g_project->_->layers->length)) { - ui_fill(checkw, 0, (g_ui->_window_w / (float)UI_SCALE() - 2) - checkw, 2 * UI_SCALE(), g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(checkw, 0, (g_ui->_window_w / (float)UI_SCALE() - 2) - checkw, 2 * UI_SCALE(), g_theme->HIGHLIGHT_COL); } } } @@ -983,11 +983,11 @@ void tab_layers_draw_slots(bool mini) { } void tab_layers_highlight_odd_lines() { - i32 step = g_ui->ops->theme->ELEMENT_H * 2; + i32 step = g_theme->ELEMENT_H * 2; i32 full_h = g_ui->_window_h - ui_base_hwnds->buffer[0]->scroll_offset; for (i32 i = 0; i < math_floor(full_h / (float)step); ++i) { if (i % 2 == 0) { - ui_fill(0, i * step, (g_ui->_w / (float)UI_SCALE() - 2), step, base_darker(g_ui->ops->theme->WINDOW_BG_COL, 0x00040404)); + ui_fill(0, i * step, (g_ui->_w / (float)UI_SCALE() - 2), step, base_darker(g_theme->WINDOW_BG_COL, 0x00040404)); } } } @@ -1156,8 +1156,8 @@ void tab_layers_combo_filter() { void tab_layers_draw_mini(ui_handle_t *htab) { ui_set_hovered_tab_name(tr("Layers")); - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; - g_ui->ops->theme->ELEMENT_H = math_floor(ui_sidebar_w_mini / 2.0 / (float)UI_SCALE()); + i32 _ELEMENT_H = g_theme->ELEMENT_H; + g_theme->ELEMENT_H = math_floor(ui_sidebar_w_mini / 2.0 / (float)UI_SCALE()); ui_begin_sticky(); ui_separator(5, true); @@ -1172,7 +1172,7 @@ void tab_layers_draw_mini(ui_handle_t *htab) { tab_layers_highlight_odd_lines(); tab_layers_draw_slots(true); - g_ui->ops->theme->ELEMENT_H = _ELEMENT_H; + g_theme->ELEMENT_H = _ELEMENT_H; } void tab_layers_draw_full(ui_handle_t *htab) { diff --git a/paint/sources/ui/tab_materials.c b/paint/sources/ui/tab_materials.c index 39e86aa8..7016b9dd 100644 --- a/paint/sources/ui/tab_materials.c +++ b/paint/sources/ui/tab_materials.c @@ -217,15 +217,15 @@ void tab_materials_draw_slots(bool mini) { if (g_context->material == g_project->_->materials->buffer[i]) { if (mini) { f32 w = g_ui->_w / (float)UI_SCALE(); - ui_rect(0, -2, w - 2, w - 4, g_ui->ops->theme->HIGHLIGHT_COL, 3); + ui_rect(0, -2, w - 2, w - 4, g_theme->HIGHLIGHT_COL, 3); } else { i32 off = row % 2 == 1 ? 1 : 0; i32 w = 50 + math_floor(g_config->window_scale * 2); - ui_fill(-1, -2, w + 3, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-1, w - off, w + 3, 2 + off, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-1, -2, 2, w + 3, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(w + 1, -2, 2, w + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-1, -2, w + 3, 2, g_theme->HIGHLIGHT_COL); + ui_fill(-1, w - off, w + 3, 2 + off, g_theme->HIGHLIGHT_COL); + ui_fill(-1, -2, 2, w + 3, g_theme->HIGHLIGHT_COL); + ui_fill(w + 1, -2, 2, w + 4, g_theme->HIGHLIGHT_COL); } } @@ -236,7 +236,7 @@ void tab_materials_draw_slots(bool mini) { f32 imgh = mini ? ui_sidebar_default_w_mini * 0.85 * UI_SCALE() : 50 * UI_SCALE(); if (base_drag_material != NULL && tab_materials_drag_pos == i) { - ui_fill(-1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-1, -2, 2, imgw_val + 4, g_theme->HIGHLIGHT_COL); } ui_state_t state = g_project->_->materials->buffer[i]->preview_ready @@ -253,11 +253,11 @@ void tab_materials_draw_slots(bool mini) { if (!is_typing) { if (i < 9 && operator_shortcut(any_map_get(g_keymap, "select_material"), SHORTCUT_TYPE_DOWN)) { char *number = i32_to_string(i + 1); - i32 width = draw_string_width(g_ui->ops->font, g_ui->font_size, number) + 10; - i32 height = draw_font_height(g_ui->ops->font, g_ui->font_size); - draw_set_color(g_ui->ops->theme->TEXT_COL); + i32 width = draw_string_width(g_font, g_ui->font_size, number) + 10; + i32 height = draw_font_height(g_font, g_ui->font_size); + draw_set_color(g_theme->TEXT_COL); draw_filled_rect(uix, uiy, width, height); - draw_set_color(g_ui->ops->theme->BUTTON_COL); + draw_set_color(g_theme->BUTTON_COL); draw_string(number, uix + 5, uiy); } } @@ -328,7 +328,7 @@ void tab_materials_draw_slots(bool mini) { if (base_drag_material != NULL && tab_materials_drag_pos == g_project->_->materials->length) { g_ui->_x = uix; g_ui->_y = uiy; - ui_fill(imgw_val + 1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(imgw_val + 1, -2, 2, imgw_val + 4, g_theme->HIGHLIGHT_COL); } if (!drag_pos_set) { diff --git a/paint/sources/ui/tab_meshes.c b/paint/sources/ui/tab_meshes.c index 93914630..2d714128 100644 --- a/paint/sources/ui/tab_meshes.c +++ b/paint/sources/ui/tab_meshes.c @@ -211,7 +211,7 @@ void tab_meshes_draw_context_menu() { // } // } - // ui_text("Script", UI_ALIGN_LEFT, g_ui->ops->theme->SEPARATOR_COL); + // ui_text("Script", UI_ALIGN_LEFT, g_theme->SEPARATOR_COL); // char *script = any_map_get(sim_object_script_map, g_context->selected_object); // if (script == NULL) { @@ -221,7 +221,7 @@ void tab_meshes_draw_context_menu() { // ui_handle_t *hscript = ui_handle(__ID__); // hscript->text = string_copy(script); - // draw_font_t *_font = g_ui->ops->font; + // draw_font_t *_font = g_font; // i32 _font_size = g_ui->font_size; // draw_font_t *fmono = data_get_font("font_mono.ttf"); // ui_set_font(g_ui, fmono); @@ -598,7 +598,7 @@ void tab_meshes_draw(ui_handle_t *htab) { else { gpu_texture_t *icons = resource_get("icons.k"); rect_t *rect = resource_tile50(icons, ICON_CUBE); - state = ui_sub_image(icons, g_ui->ops->theme->BUTTON_COL, slotw, rect->x, rect->y, rect->w, rect->h); + state = ui_sub_image(icons, g_theme->BUTTON_COL, slotw, rect->x, rect->y, rect->w, rect->h); sys_notify_on_next_frame(tab_meshes_make_preview, o); } @@ -610,10 +610,10 @@ void tab_meshes_draw(ui_handle_t *htab) { g_ui->_y = uiy + 4; i32 hoff = i % 2 == 1 ? 1 : 0; i32 w = 75; - ui_fill(0, 0, w + 3, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(0, w - hoff + 2, w + 3, 2 + hoff, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(0, 0, 2, w + 3, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(w + 2, 0, 2, w + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(0, 0, w + 3, 2, g_theme->HIGHLIGHT_COL); + ui_fill(0, w - hoff + 2, w + 3, 2 + hoff, g_theme->HIGHLIGHT_COL); + ui_fill(0, 0, 2, w + 3, g_theme->HIGHLIGHT_COL); + ui_fill(w + 2, 0, 2, w + 4, g_theme->HIGHLIGHT_COL); g_ui->_x = _uix; g_ui->_y = _uiy; } @@ -645,7 +645,7 @@ void tab_meshes_draw(ui_handle_t *htab) { // Label i32 check_w = UI_ELEMENT_H(); - i32 text_w = draw_string_width(g_ui->ops->font, g_ui->font_size, o->base->name); + i32 text_w = draw_string_width(g_font, g_ui->font_size, o->base->name); i32 center_x = (slotw - check_w - text_w) / 2; g_ui->_x = uix + (center_x > 0 ? center_x : 0); g_ui->_y += slotw * 0.9 + 8; diff --git a/paint/sources/ui/tab_plugins.c b/paint/sources/ui/tab_plugins.c index 023020c6..f19ed10d 100644 --- a/paint/sources/ui/tab_plugins.c +++ b/paint/sources/ui/tab_plugins.c @@ -20,9 +20,9 @@ void tab_plugins_draw(ui_handle_t *htab) { ui_end_sticky(); // Draw plugins - string_array_t *keys = map_keys(plugin_map); + string_array_t *keys = map_keys(g_plugins); for (i32 i = 0; i < keys->length; ++i) { - plugin_t *p = any_map_get(plugin_map, keys->buffer[i]); + plugin_t *p = any_map_get(g_plugins, keys->buffer[i]); if (p->on_ui != NULL) { minic_ctx_call_fn(p->ctx, p->on_ui, NULL, 0); } diff --git a/paint/sources/ui/tab_scripts.c b/paint/sources/ui/tab_scripts.c index 09ec4b70..0c314958 100644 --- a/paint/sources/ui/tab_scripts.c +++ b/paint/sources/ui/tab_scripts.c @@ -145,7 +145,7 @@ void tab_scripts_draw(ui_handle_t *htab) { ui_end_sticky(); - draw_font_t *_font = g_ui->ops->font; + draw_font_t *_font = g_font; i32 _font_size = g_ui->font_size; draw_font_t *f = data_get_font("font_mono.ttf"); ui_set_font(g_ui, f); diff --git a/paint/sources/ui/tab_stages.c b/paint/sources/ui/tab_stages.c index 03b04041..44053ba4 100644 --- a/paint/sources/ui/tab_stages.c +++ b/paint/sources/ui/tab_stages.c @@ -55,7 +55,7 @@ void tab_stages_draw(ui_handle_t *htab) { slot_stage_t *s = project_stages->buffer[i]; tab_stages_show_context_menu = false; if (i == selected_stage) { - ui_fill(0, 0, g_ui->_window_w, g_ui->ops->theme->ELEMENT_H, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(0, 0, g_ui->_window_w, g_theme->ELEMENT_H, g_theme->HIGHLIGHT_COL); } ui_text(s->name, UI_ALIGN_LEFT, 0x00000000); if (g_ui->is_released) { @@ -67,7 +67,7 @@ void tab_stages_draw(ui_handle_t *htab) { gc_root(tab_stages_context_stage); tab_stages_show_context_menu = true; } - ui_fill(0, 0, (g_ui->_window_w / (float)UI_SCALE() - 2), 1 * UI_SCALE(), g_ui->ops->theme->SEPARATOR_COL); + ui_fill(0, 0, (g_ui->_window_w / (float)UI_SCALE() - 2), 1 * UI_SCALE(), g_theme->SEPARATOR_COL); if (tab_stages_show_context_menu) { ui_menu_draw(&tab_stages_context_menu_draw, -1, -1); } diff --git a/paint/sources/ui/tab_swatches.c b/paint/sources/ui/tab_swatches.c index 3a325fe4..11bdec15 100644 --- a/paint/sources/ui/tab_swatches.c +++ b/paint/sources/ui/tab_swatches.c @@ -71,7 +71,7 @@ void tab_swatches_draw_edit_menu() { ui_handle_t *h = ui_handle(__ID__); h->color = g_context->swatch->base; - g_context->swatch->base = ui_color_wheel(h, false, -1, 11 * g_ui->ops->theme->ELEMENT_H * UI_SCALE(), true, &tab_swatches_draw_color_picker, NULL); + g_context->swatch->base = ui_color_wheel(h, false, -1, 11 * g_theme->ELEMENT_H * UI_SCALE(), true, &tab_swatches_draw_color_picker, NULL); ui_handle_t *hopacity = ui_handle(__ID__); hopacity->f = g_context->swatch->opacity; @@ -199,7 +199,7 @@ void tab_swatches_draw(ui_handle_t *htab) { if (g_context->swatch == g_project->swatches->buffer[i]) { i32 w = 32; - ui_fill(-2, -2, w, w, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-2, -2, w, w, g_theme->HIGHLIGHT_COL); } uix = g_ui->_x; @@ -207,7 +207,7 @@ void tab_swatches_draw(ui_handle_t *htab) { // Draw the drag position indicator if (base_drag_swatch != NULL && tab_swatches_drag_pos == i) { - ui_fill(-1, -2, 2, 32, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-1, -2, 2, 32, g_theme->HIGHLIGHT_COL); } ui_state_t state = ui_image(tab_swatches_empty_get(), g_project->swatches->buffer[i]->base, slotw); @@ -256,7 +256,7 @@ void tab_swatches_draw(ui_handle_t *htab) { if (base_drag_swatch != NULL && tab_swatches_drag_pos == g_project->swatches->length) { g_ui->_x = uix; // Reset the position because otherwise it would start in the row below g_ui->_y = uiy; - ui_fill(28, -2, 2, 32, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(28, -2, 2, 32, g_theme->HIGHLIGHT_COL); } // Currently there is no valid drag_position so reset it diff --git a/paint/sources/ui/tab_textures.c b/paint/sources/ui/tab_textures.c index 613e263f..3d42296d 100644 --- a/paint/sources/ui/tab_textures.c +++ b/paint/sources/ui/tab_textures.c @@ -231,7 +231,7 @@ void tab_textures_draw(ui_handle_t *htab) { i32 sw = img->height < img->width ? img->height : 0; if (base_drag_asset != NULL && tab_textures_drag_pos == i) { - ui_fill(-1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-1, -2, 2, imgw_val + 4, g_theme->HIGHLIGHT_COL); } ui_state_t _state = ui_sub_image(img, 0xffffffff, slotw, 0, 0, sw, sw); @@ -262,10 +262,10 @@ void tab_textures_draw(ui_handle_t *htab) { g_ui->_y = uiy; i32 off = i % 2 == 1 ? 1 : 0; i32 w = 50; - ui_fill(0, 0, w + 3, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(0, w - off + 2, w + 3, 2 + off, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(0, 0, 2, w + 3, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(w + 2, 0, 2, w + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(0, 0, w + 3, 2, g_theme->HIGHLIGHT_COL); + ui_fill(0, w - off + 2, w + 3, 2 + off, g_theme->HIGHLIGHT_COL); + ui_fill(0, 0, 2, w + 3, g_theme->HIGHLIGHT_COL); + ui_fill(w + 2, 0, 2, w + 4, g_theme->HIGHLIGHT_COL); g_ui->_x = _uix; g_ui->_y = _uiy; } @@ -318,7 +318,7 @@ void tab_textures_draw(ui_handle_t *htab) { if (base_drag_asset != NULL && tab_textures_drag_pos == g_project->_->assets->length) { g_ui->_x = uix; g_ui->_y = uiy; - ui_fill(imgw_val + 1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(imgw_val + 1, -2, 2, imgw_val + 4, g_theme->HIGHLIGHT_COL); } if (!drag_pos_set) { @@ -328,7 +328,7 @@ void tab_textures_draw(ui_handle_t *htab) { else { gpu_texture_t *img = resource_get("icons.k"); rect_t *r = resource_tile50(img, ICON_DROP); - ui_sub_image(img, g_ui->ops->theme->BUTTON_COL, r->h, r->x, r->y, r->w, r->h); + ui_sub_image(img, g_theme->BUTTON_COL, r->h, r->x, r->y, r->w, r->h); if (g_ui->is_hovered) { ui_tooltip(tr("Drag and drop files here")); } diff --git a/paint/sources/ui/tab_timeline.c b/paint/sources/ui/tab_timeline.c index ea067100..6fb1b6f6 100644 --- a/paint/sources/ui/tab_timeline.c +++ b/paint/sources/ui/tab_timeline.c @@ -1021,8 +1021,8 @@ void tab_timeline_draw(ui_handle_t *htab) { f32 frame_w = 16.0f * UI_SCALE(); f32 start_x = g_ui->_x + layer_name_w; f32 start_y = g_ui->_y; - i32 font_h = draw_font_height(g_ui->ops->font, g_ui->font_size); - i32 strip_h = (i32)(g_ui->ops->theme->ELEMENT_H * UI_SCALE()); + i32 font_h = draw_font_height(g_font, g_ui->font_size); + i32 strip_h = (i32)(g_theme->ELEMENT_H * UI_SCALE()); f32 track_w = g_ui->_window_w - start_x; i32 visible = (i32)(track_w / frame_w); i32 max_scroll = math_max(tab_timeline_max_frames - visible, 0); @@ -1044,7 +1044,7 @@ void tab_timeline_draw(ui_handle_t *htab) { } // Frame number labels every 5 frames - draw_set_color(g_ui->ops->theme->LABEL_COL); + draw_set_color(g_theme->LABEL_COL); i32 label_start = (tab_timeline_scroll / 5) * 5; for (i32 i = label_start; i < tab_timeline_scroll + visible + 1 && i < tab_timeline_max_frames; i += 5) { f32 lx = start_x + (i - tab_timeline_scroll) * frame_w; @@ -1052,13 +1052,13 @@ void tab_timeline_draw(ui_handle_t *htab) { continue; } char *label = i32_to_string(i); - f32 label_w = draw_string_width(g_ui->ops->font, g_ui->font_size, label); + f32 label_w = draw_string_width(g_font, g_ui->font_size, label); draw_string(label, lx + (frame_w - label_w) / 2.0f, start_y); } - u32 base_col = g_ui->ops->theme->BUTTON_COL; + u32 base_col = g_theme->BUTTON_COL; u32 bright_col = base_col + 0x00101010; - u32 sel_col = g_ui->ops->theme->HIGHLIGHT_COL; + u32 sel_col = g_theme->HIGHLIGHT_COL; i32 row_count = g_project->_->layers->length; gpu_texture_t *icons = resource_get("icons.k"); @@ -1070,9 +1070,9 @@ void tab_timeline_draw(ui_handle_t *htab) { f32 icon_y = row_y + (strip_h - icon_size) / 2.0f; rect_t *rect = resource_tile50(icons, ICON_LAYERS); - draw_set_color(g_ui->ops->theme->LABEL_COL); + draw_set_color(g_theme->LABEL_COL); draw_scaled_sub_image(icons, rect->x, rect->y, rect->w, rect->h, g_ui->_x, icon_y, icon_size, icon_size); - draw_set_color(g_ui->ops->theme->LABEL_COL); + draw_set_color(g_theme->LABEL_COL); draw_string(layer->name, g_ui->_x + icon_size + 2, row_y + (strip_h - font_h) / 2.0f); for (i32 i = tab_timeline_scroll; i < tab_timeline_scroll + visible + 1 && i < tab_timeline_max_frames; i++) { @@ -1092,7 +1092,7 @@ void tab_timeline_draw(ui_handle_t *htab) { } if (i == 0 || (tab_timeline_keyframes != NULL && tab_timeline_find_keyframe(i, ri) >= 0)) { - draw_set_color(g_ui->ops->theme->LABEL_COL); + draw_set_color(g_theme->LABEL_COL); draw_filled_circle(x + frame_w / 2.0f, row_y + strip_h / 2.0f, 3.0f * UI_SCALE(), 12); } @@ -1129,9 +1129,9 @@ void tab_timeline_draw(ui_handle_t *htab) { f32 icon_y = row_y + (strip_h - icon_size) / 2.0f; rect_t *rect = resource_tile50(icons, ICON_CUBE); - draw_set_color(g_ui->ops->theme->LABEL_COL); + draw_set_color(g_theme->LABEL_COL); draw_scaled_sub_image(icons, rect->x, rect->y, rect->w, rect->h, g_ui->_x, icon_y, icon_size, icon_size); - draw_set_color(g_ui->ops->theme->LABEL_COL); + draw_set_color(g_theme->LABEL_COL); draw_string(mesh->base->name, g_ui->_x + icon_size + 2, row_y + (strip_h - font_h) / 2.0f); for (i32 i = tab_timeline_scroll; i < tab_timeline_scroll + visible + 1 && i < tab_timeline_max_frames; i++) { @@ -1151,7 +1151,7 @@ void tab_timeline_draw(ui_handle_t *htab) { } if (i == 0 || (tab_timeline_mesh_keyframes != NULL && tab_timeline_find_mesh_keyframe(i, mi) >= 0)) { - draw_set_color(g_ui->ops->theme->LABEL_COL); + draw_set_color(g_theme->LABEL_COL); draw_filled_circle(x + frame_w / 2.0f, row_y + strip_h / 2.0f, 3.0f * UI_SCALE(), 12); } @@ -1186,9 +1186,9 @@ void tab_timeline_draw(ui_handle_t *htab) { f32 handle_w = track_w * (f32)visible / tab_timeline_max_frames; f32 handle_x = start_x + (max_scroll > 0 ? tab_timeline_scroll * (track_w - handle_w) / max_scroll : 0); - draw_set_color(base_darker(g_ui->ops->theme->BUTTON_COL, 0x00101010)); + draw_set_color(base_darker(g_theme->BUTTON_COL, 0x00101010)); draw_filled_rect(start_x, scrollbar_y, track_w, scrollbar_h); - draw_set_color(g_ui->ops->theme->BUTTON_COL + 0x00202020); + draw_set_color(g_theme->BUTTON_COL + 0x00202020); draw_filled_rect(handle_x, scrollbar_y, handle_w, scrollbar_h); if (g_ui->input_started && g_ui->input_x > g_ui->_window_x + start_x && g_ui->input_x < g_ui->_window_x + start_x + track_w && diff --git a/paint/sources/ui/ui_base.c b/paint/sources/ui/ui_base.c index 616f2c45..15c3463d 100644 --- a/paint/sources/ui/ui_base.c +++ b/paint/sources/ui/ui_base.c @@ -101,7 +101,7 @@ void ui_base_init() { ui_menubar_w = math_floor(ui_menubar_default_w * g_config->window_scale); if (g_context->empty_envmap == NULL) { - ui_base_make_empty_envmap(base_theme->VIEWPORT_COL); + ui_base_make_empty_envmap(g_theme->VIEWPORT_COL); } if (g_context->preview_envmap == NULL) { u8_array_t *b = u8_array_create(4); @@ -133,7 +133,7 @@ void ui_base_init() { f32 scale = g_config->window_scale; ui_options_t *ops = GC_ALLOC_INIT( ui_options_t, - {.theme = base_theme, .font = base_font, .scale_factor = scale, .color_wheel = base_color_wheel, .black_white_gradient = base_color_wheel_gradient}); + {.theme = g_theme, .font = g_font, .scale_factor = scale, .color_wheel = base_color_wheel, .black_white_gradient = base_color_wheel_gradient}); g_ui = ui_create(ops); gc_root(g_ui); @@ -237,9 +237,9 @@ void ui_base_update(void *_) { operator_update(); - string_array_t *keys = map_keys(plugin_map); + string_array_t *keys = map_keys(g_plugins); for (i32 i = 0; i < keys->length; ++i) { - plugin_t *p = any_map_get(plugin_map, keys->buffer[i]); + plugin_t *p = any_map_get(g_plugins, keys->buffer[i]); if (p->on_update != NULL) { minic_ctx_call_fn(p->ctx, p->on_update, NULL, 0); } @@ -299,7 +299,7 @@ void ui_base_update(void *_) { // Nothing to display in the main area if (!base_view3d_show && !ui_nodes_show && !ui_view2d_show) { - draw_begin(NULL, true, base_theme->SEPARATOR_COL); + draw_begin(NULL, true, g_theme->SEPARATOR_COL); gpu_texture_t *img = data_get_image("badge_bw.k"); draw_set_color(0x22ffffff); draw_image(img, base_view3d_w() / 2.0 - img->width / 2.0, base_h() / 2.0 - img->height / 2.0); diff --git a/paint/sources/ui/ui_box.c b/paint/sources/ui/ui_box.c index 08c678d1..1e7d6c87 100644 --- a/paint/sources/ui/ui_box.c +++ b/paint/sources/ui/ui_box.c @@ -25,7 +25,7 @@ void ui_box_window_border() { gpu_disable_scissor(); } // Border - draw_set_color(g_ui->ops->theme->SEPARATOR_COL); + draw_set_color(g_theme->SEPARATOR_COL); draw_filled_rect(0, 0, 1, g_ui->_window_h); draw_filled_rect(0 + g_ui->_window_w - 1, 0, 1, g_ui->_window_h); draw_filled_rect(0, 0 + g_ui->_window_h - 1, g_ui->_window_w, 1); diff --git a/paint/sources/ui/ui_files.c b/paint/sources/ui/ui_files.c index db37c08b..225f6d71 100644 --- a/paint/sources/ui/ui_files.c +++ b/paint/sources/ui/ui_files.c @@ -319,9 +319,9 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, rect = cube; } - i32 col = rect == file ? g_ui->ops->theme->LABEL_COL : base_darker(g_ui->ops->theme->LABEL_COL, 0x00202020); + i32 col = rect == file ? g_theme->LABEL_COL : base_darker(g_theme->LABEL_COL, 0x00202020); if (ui_files_selected == i) - col = g_ui->ops->theme->HIGHLIGHT_COL; + col = g_theme->HIGHLIGHT_COL; f32 off = g_ui->_w / 2.0 - 25 * UI_SCALE(); g_ui->_x += off; @@ -362,10 +362,10 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, if (icon != NULL && icon != icons) { i32 w = 50; if (i == ui_files_selected) { - ui_fill(-2, -2, w + 4, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-2, w + 2, w + 4, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-2, 0, 2, w + 4, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(w + 2, -2, 2, w + 6, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-2, -2, w + 4, 2, g_theme->HIGHLIGHT_COL); + ui_fill(-2, w + 2, w + 4, 2, g_theme->HIGHLIGHT_COL); + ui_fill(-2, 0, 2, w + 4, g_theme->HIGHLIGHT_COL); + ui_fill(w + 2, -2, 2, w + 6, g_theme->HIGHLIGHT_COL); } state = ui_image(icon, 0xffffffff, w * UI_SCALE()); if (g_ui->is_hovered) { @@ -433,10 +433,10 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, if (icon != NULL) { i32 w = 50; if (i == ui_files_selected) { - ui_fill(-2, -2, w + 4, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-2, w + 2, w + 4, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-2, 0, 2, w + 4, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(w + 2, -2, 2, w + 6, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-2, -2, w + 4, 2, g_theme->HIGHLIGHT_COL); + ui_fill(-2, w + 2, w + 4, 2, g_theme->HIGHLIGHT_COL); + ui_fill(-2, 0, 2, w + 4, g_theme->HIGHLIGHT_COL); + ui_fill(w + 2, -2, 2, w + 6, g_theme->HIGHLIGHT_COL); } state = ui_image(icon, 0xffffffff, w * UI_SCALE()); if (g_ui->is_hovered) { @@ -472,10 +472,10 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, } if (icon != NULL) { if (i == ui_files_selected) { - ui_fill(-2, -2, w + 4, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-2, w + 2, w + 4, 2, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(-2, 0, 2, w + 4, g_ui->ops->theme->HIGHLIGHT_COL); - ui_fill(w + 2, -2, 2, w + 6, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(-2, -2, w + 4, 2, g_theme->HIGHLIGHT_COL); + ui_fill(-2, w + 2, w + 4, 2, g_theme->HIGHLIGHT_COL); + ui_fill(-2, 0, 2, w + 4, g_theme->HIGHLIGHT_COL); + ui_fill(w + 2, -2, 2, w + 6, g_theme->HIGHLIGHT_COL); } state = ui_image(icon, 0xffffffff, icon->height * UI_SCALE()); generic = false; @@ -539,7 +539,7 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, g_ui->_y += slotw * 0.75; char *label0 = (is_folder || ui_files_show_extensions || string_index_of(f, ".") <= 0) ? f : substring(f, 0, string_last_index_of(f, ".")); char *label1 = ""; - while (string_length(label0) > 0 && draw_string_width(g_ui->ops->font, g_ui->font_size, label0) > g_ui->_w - 6) { // 2 line split + while (string_length(label0) > 0 && draw_string_width(g_font, g_ui->font_size, label0) > g_ui->_w - 6) { // 2 line split label1 = string("%s%s", char_at(label0, string_length(label0) - 1), label1); label0 = string_copy(substring(label0, 0, string_length(label0) - 1)); } @@ -552,12 +552,12 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, } if (!string_equals(label1, "")) { // Second line g_ui->_x = _x; - g_ui->_y += draw_font_height(g_ui->ops->font, g_ui->font_size); + g_ui->_y += draw_font_height(g_font, g_ui->font_size); ui_text(label1, UI_ALIGN_CENTER, 0x00000000); if (g_ui->is_hovered) { ui_tooltip(string("%s%s", label0, label1)); } - g_ui->_y -= draw_font_height(g_ui->ops->font, g_ui->font_size); + g_ui->_y -= draw_font_height(g_font, g_ui->font_size); } g_ui->_y -= slotw * 0.75; diff --git a/paint/sources/ui/ui_header.c b/paint/sources/ui/ui_header.c index 2f3c213c..3ac514d1 100644 --- a/paint/sources/ui/ui_header.c +++ b/paint/sources/ui/ui_header.c @@ -99,9 +99,9 @@ void ui_header_draw_tool_properties_layer_preview_dirty(void *_) { } void ui_header_draw_tool_properties_color_picker_normal() { - ui_fill(0, 0, g_ui->_w / (float)UI_SCALE(), g_ui->ops->theme->ELEMENT_H * 9, g_ui->ops->theme->SEPARATOR_COL); + ui_fill(0, 0, g_ui->_w / (float)UI_SCALE(), g_theme->ELEMENT_H * 9, g_theme->SEPARATOR_COL); g_ui->changed = false; - ui_color_wheel(_ui_header_draw_tool_properties_h, false, -1, 10 * g_ui->ops->theme->ELEMENT_H * UI_SCALE(), false, NULL, NULL); + ui_color_wheel(_ui_header_draw_tool_properties_h, false, -1, 10 * g_theme->ELEMENT_H * UI_SCALE(), false, NULL, NULL); if (g_ui->changed) { g_context->picked_color->normal = _ui_header_draw_tool_properties_h->color; ui_header_handle->redraws = 2; @@ -110,9 +110,9 @@ void ui_header_draw_tool_properties_color_picker_normal() { } void ui_header_draw_tool_properties_color_picker_base() { - ui_fill(0, 0, g_ui->_w / (float)UI_SCALE(), g_ui->ops->theme->ELEMENT_H * 9, g_ui->ops->theme->SEPARATOR_COL); + ui_fill(0, 0, g_ui->_w / (float)UI_SCALE(), g_theme->ELEMENT_H * 9, g_theme->SEPARATOR_COL); g_ui->changed = false; - ui_color_wheel(_ui_header_draw_tool_properties_h, false, -1, 10 * g_ui->ops->theme->ELEMENT_H * UI_SCALE(), false, NULL, NULL); + ui_color_wheel(_ui_header_draw_tool_properties_h, false, -1, 10 * g_theme->ELEMENT_H * UI_SCALE(), false, NULL, NULL); if (g_ui->changed) { g_context->picked_color->base = _ui_header_draw_tool_properties_h->color; ui_header_handle->redraws = 2; diff --git a/paint/sources/ui/ui_menu.c b/paint/sources/ui/ui_menu.c index 94da4ab9..25d997d0 100644 --- a/paint/sources/ui/ui_menu.c +++ b/paint/sources/ui/ui_menu.c @@ -37,12 +37,12 @@ void ui_menu_fit_to_screen() { void ui_menu_render() { i32 menu_w = ui_menu_commands != NULL ? math_floor(base_default_element_w * UI_SCALE() * 2.3) : math_floor(UI_ELEMENT_W() * 2.3); - i32 _FILL_BUTTON_BG = g_ui->ops->theme->FILL_BUTTON_BG; - g_ui->ops->theme->FILL_BUTTON_BG = false; - i32 _ELEMENT_OFFSET = g_ui->ops->theme->ELEMENT_OFFSET; - g_ui->ops->theme->ELEMENT_OFFSET = 0; - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; - g_ui->ops->theme->ELEMENT_H = g_config->touch_ui ? (28 + 2) : 28; + i32 _FILL_BUTTON_BG = g_theme->FILL_BUTTON_BG; + g_theme->FILL_BUTTON_BG = false; + i32 _ELEMENT_OFFSET = g_theme->ELEMENT_OFFSET; + g_theme->ELEMENT_OFFSET = 0; + i32 _ELEMENT_H = g_theme->ELEMENT_H; + g_theme->ELEMENT_H = g_config->touch_ui ? (28 + 2) : 28; if (ui_menu_nested) { ui_menu_show_first = true; @@ -68,9 +68,9 @@ void ui_menu_render() { (g_ui->changed || g_ui->input_released || g_ui->input_released_r || g_ui->is_escape_down); ui_menu_keep_open = false; - g_ui->ops->theme->FILL_BUTTON_BG = _FILL_BUTTON_BG; - g_ui->ops->theme->ELEMENT_OFFSET = _ELEMENT_OFFSET; - g_ui->ops->theme->ELEMENT_H = _ELEMENT_H; + g_theme->FILL_BUTTON_BG = _FILL_BUTTON_BG; + g_theme->ELEMENT_OFFSET = _ELEMENT_OFFSET; + g_theme->ELEMENT_H = _ELEMENT_H; ui_menu_end(); ui_end_region(); g_ui->input_enabled = true; @@ -111,7 +111,7 @@ void ui_menu_draw(void (*commands)(void), i32 x, i32 y) { void ui_menu_separator() { g_ui->_y++; - ui_fill(26, 0, g_ui->_w / (float)UI_SCALE() - 26, 1, g_ui->ops->theme->BUTTON_COL); + ui_fill(26, 0, g_ui->_w / (float)UI_SCALE() - 26, 1, g_theme->BUTTON_COL); } bool ui_menu_button(char *text, char *label, icon_t icon) { @@ -136,7 +136,7 @@ bool ui_menu_button(char *text, char *label, icon_t icon) { g_ui->_x = _x_left - 2 * UI_SCALE(); g_ui->_y = _y_top + 2 * UI_SCALE(); } - ui_sub_image(icons, base_darker(g_ui->ops->theme->LABEL_COL, 0x00222222), icon_h, rect->x / 2.0, rect->y / 2.0, rect->w / 2.0, rect->h / 2.0); + ui_sub_image(icons, base_darker(g_theme->LABEL_COL, 0x00222222), icon_h, rect->x / 2.0, rect->y / 2.0, rect->w / 2.0, rect->h / 2.0); g_ui->_x = _x_left; g_ui->_y = _y_bottom; } @@ -157,7 +157,7 @@ bool ui_icon_button(char *text, icon_t icon, ui_align_t align) { } char *tooltip = ""; - i32 textw = draw_string_width(g_ui->ops->font, g_ui->font_size, text); + i32 textw = draw_string_width(g_font, g_ui->font_size, text); f32 wmax = g_config->touch_ui ? 0.9 : 0.8; if (textw > _w * wmax) { tooltip = string_copy(text); @@ -192,8 +192,8 @@ bool ui_icon_button(char *text, icon_t icon, ui_align_t align) { } g_ui->image_scroll_align = false; - ui_sub_image(icons, g_ui->enabled ? ui_menu_color_sub(g_ui->ops->theme->LABEL_COL, 0x00333333) : 0xffffffff, icon_h, rect->x / 2.0, rect->y / 2.0, - rect->w / 2.0, rect->h / 2.0); + ui_sub_image(icons, g_ui->enabled ? ui_menu_color_sub(g_theme->LABEL_COL, 0x00333333) : 0xffffffff, icon_h, rect->x / 2.0, rect->y / 2.0, rect->w / 2.0, + rect->h / 2.0); g_ui->image_scroll_align = true; g_ui->_x = _x_right; @@ -218,15 +218,15 @@ bool ui_menu_sub_button(ui_handle_t *handle, char *text) { } void ui_menu_label(char *text, char *shortcut) { - i32 _y = g_ui->_y; - i32 _TEXT_COL = g_ui->ops->theme->TEXT_COL; - g_ui->ops->theme->TEXT_COL = g_ui->ops->theme->LABEL_COL; + i32 _y = g_ui->_y; + i32 _TEXT_COL = g_theme->TEXT_COL; + g_theme->TEXT_COL = g_theme->LABEL_COL; ui_text(text, UI_ALIGN_LEFT, 0x00000000); if (shortcut != NULL) { g_ui->_y = _y; ui_text(shortcut, UI_ALIGN_RIGHT, 0x00000000); } - g_ui->ops->theme->TEXT_COL = _TEXT_COL; + g_theme->TEXT_COL = _TEXT_COL; } void ui_menu_align() { @@ -244,7 +244,7 @@ void ui_menu_align() { void ui_menu_begin() { ui_draw_shadow(g_ui->_x, g_ui->_y, g_ui->_w, ui_menu_h); - draw_set_color(g_ui->ops->theme->SEPARATOR_COL); + draw_set_color(g_theme->SEPARATOR_COL); ui_draw_rect(true, g_ui->_x, g_ui->_y, g_ui->_w, ui_menu_h); draw_set_color(0xffffffff); } @@ -257,7 +257,7 @@ void ui_menu_sub_begin(i32 items) { g_ui->_x += g_ui->_w + 2; g_ui->_y -= UI_ELEMENT_H(); ui_draw_shadow(g_ui->_x, g_ui->_y, g_ui->_w, UI_ELEMENT_H() * items); - draw_set_color(g_ui->ops->theme->SEPARATOR_COL); + draw_set_color(g_theme->SEPARATOR_COL); ui_draw_rect(true, g_ui->_x, g_ui->_y, g_ui->_w, UI_ELEMENT_H() * items); draw_set_color(0xffffffff); } diff --git a/paint/sources/ui/ui_menubar.c b/paint/sources/ui/ui_menubar.c index ca9c25f1..3247ffaf 100644 --- a/paint/sources/ui/ui_menubar.c +++ b/paint/sources/ui/ui_menubar.c @@ -94,7 +94,7 @@ void ui_menubar_draw_tab_header() { if (ui_window(ui_menubar_hwnd, panel_x, 0, ww, ui_header_h, false)) { if (g_config->touch_ui) { - ui_fill(0, 0, g_ui->_window_w, g_ui->_window_h + 4, g_ui->ops->theme->SEPARATOR_COL); + ui_fill(0, 0, g_ui->_window_w, g_ui->_window_h + 4, g_theme->SEPARATOR_COL); } else { bool a = ui_tab(ui_menubar_tab, tr("3D View"), false, -1, false); @@ -899,19 +899,19 @@ void ui_menubar_render_ui() { } i32 size = math_floor(g_ui->_w / (float)UI_SCALE()); if (ui_menu_show && ui_menubar_category == MENUBAR_CATEGORY_VIEWPORT) { - ui_fill(0, -6, size, size - 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(0, -6, size, size - 4, g_theme->HIGHLIGHT_COL); } if (ui_menubar_icon_button(ICON_IMAGE)) { ui_menubar_show_menu(MENUBAR_CATEGORY_VIEWPORT); } if (ui_menu_show && ui_menubar_category == MENUBAR_CATEGORY_MODE) { - ui_fill(0, -6, size, size - 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(0, -6, size, size - 4, g_theme->HIGHLIGHT_COL); } if (ui_menubar_icon_button(ICON_SUN)) { ui_menubar_show_menu(MENUBAR_CATEGORY_MODE); } if (ui_menu_show && ui_menubar_category == MENUBAR_CATEGORY_CAMERA) { - ui_fill(0, -6, size, size - 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(0, -6, size, size - 4, g_theme->HIGHLIGHT_COL); } if (ui_menubar_icon_button(ICON_CAMERA)) { ui_menubar_show_menu(MENUBAR_CATEGORY_CAMERA); @@ -920,7 +920,7 @@ void ui_menubar_render_ui() { // ui_menubar_show_menu(MENUBAR_CATEGORY_WORKSPACE); // } if (ui_menu_show && ui_menubar_category == MENUBAR_CATEGORY_HELP) { - ui_fill(0, -6, size, size - 4, g_ui->ops->theme->HIGHLIGHT_COL); + ui_fill(0, -6, size, size - 4, g_theme->HIGHLIGHT_COL); } bool full = true; @@ -986,7 +986,7 @@ void ui_menubar_render_ui() { } bool ui_menubar_icon_button(i32 i) { - u32 col = g_ui->ops->theme->WINDOW_BG_COL; + u32 col = g_theme->WINDOW_BG_COL; bool light = col > 0xff666666; i32 icon_accent = light ? 0xff666666 : 0xffaaaaaa; gpu_texture_t *img = resource_get("icons.k"); diff --git a/paint/sources/ui/ui_nodes.c b/paint/sources/ui/ui_nodes.c index e6c67c96..53cf7a4d 100644 --- a/paint/sources/ui/ui_nodes.c +++ b/paint/sources/ui/ui_nodes.c @@ -87,11 +87,11 @@ void ui_nodes_node_search_menu() { ui_nodes_node_search_offset--; } } - bool enter = keyboard_down("enter"); - i32 count = 0; - i32 BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - bool FILL_BUTTON_BG = g_ui->ops->theme->FILL_BUTTON_BG; - g_ui->ops->theme->FILL_BUTTON_BG = true; + bool enter = keyboard_down("enter"); + i32 count = 0; + i32 BUTTON_COL = g_theme->BUTTON_COL; + bool FILL_BUTTON_BG = g_theme->FILL_BUTTON_BG; + g_theme->FILL_BUTTON_BG = true; node_list_t_array_t *node_list = ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL ? nodes_material_list : nodes_brush_list; @@ -100,7 +100,7 @@ void ui_nodes_node_search_menu() { for (i32 i = 0; i < list->length; ++i) { ui_node_t *n = list->buffer[i]; if (string_index_of(to_lower_case(tr(n->name)), search) >= 0) { - g_ui->ops->theme->BUTTON_COL = count == ui_nodes_node_search_offset ? g_ui->ops->theme->HIGHLIGHT_COL : g_ui->ops->theme->SEPARATOR_COL; + g_theme->BUTTON_COL = count == ui_nodes_node_search_offset ? g_theme->HIGHLIGHT_COL : g_theme->SEPARATOR_COL; if (ui_button(tr(n->name), UI_ALIGN_LEFT, "") || (enter && count == ui_nodes_node_search_offset)) { ui_nodes_push_undo(NULL); ui_nodes_t *nodes = ui_nodes_get_nodes(); @@ -138,8 +138,8 @@ void ui_nodes_node_search_menu() { g_ui->changed = true; search_handle->text = ""; } - g_ui->ops->theme->BUTTON_COL = BUTTON_COL; - g_ui->ops->theme->FILL_BUTTON_BG = FILL_BUTTON_BG; + g_theme->BUTTON_COL = BUTTON_COL; + g_theme->FILL_BUTTON_BG = FILL_BUTTON_BG; } void ui_nodes_node_search(i32 x, i32 y, void (*done)(void)) { @@ -505,9 +505,9 @@ gpu_texture_t *ui_nodes_draw_grid(f32 zoom) { h = 1; } gpu_texture_t *grid = gpu_create_render_target(w, h, GPU_TEXTURE_FORMAT_RGBA32); - draw_begin(grid, true, g_ui->ops->theme->SEPARATOR_COL); + draw_begin(grid, true, g_theme->SEPARATOR_COL); - i32 sep_col = g_ui->ops->theme->SEPARATOR_COL; + i32 sep_col = g_theme->SEPARATOR_COL; i32 line_primary = base_darker(sep_col, 0x00050505); if (line_primary < 0xff000000) { line_primary = sep_col + 0x00050505; @@ -555,7 +555,7 @@ void ui_nodes_draw_menubar() { ui_node_canvas_t *c = ui_nodes_get_canvas(true); i32 ew = math_floor(UI_ELEMENT_W() * 0.7); i32 top_y = ui_menu_top_y(); - draw_set_color(g_ui->ops->theme->WINDOW_BG_COL); + draw_set_color(g_theme->WINDOW_BG_COL); draw_filled_rect(0, top_y, ui_nodes_ww, UI_ELEMENT_H() + UI_ELEMENT_OFFSET() * 2); draw_set_color(0xffffffff); @@ -567,7 +567,7 @@ void ui_nodes_draw_menubar() { // Editable canvas name ui_handle_t *h = ui_handle(__ID__); h->text = string_copy(c->name); - g_ui->_w = math_floor(math_min(draw_string_width(g_ui->ops->font, g_ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE())); + g_ui->_w = math_floor(math_min(draw_string_width(g_font, g_ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE())); char *new_name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false); g_ui->_x += g_ui->_w + 3; g_ui->_y = 2 + start_y; @@ -608,11 +608,11 @@ void ui_nodes_draw_menubar() { c->name = string_copy(new_name); } } - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - bool _SHADOWS = g_ui->ops->theme->SHADOWS; - g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->WINDOW_BG_COL; - g_ui->ops->theme->SHADOWS = false; - string_array_t *cats = ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL ? nodes_material_categories : nodes_brush_categories; + i32 _BUTTON_COL = g_theme->BUTTON_COL; + bool _SHADOWS = g_theme->SHADOWS; + g_theme->BUTTON_COL = g_theme->WINDOW_BG_COL; + g_theme->SHADOWS = false; + string_array_t *cats = ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL ? nodes_material_categories : nodes_brush_categories; for (i32 i = 0; i < cats->length; ++i) { if ((ui_menubar_button(tr(cats->buffer[i]))) || (g_ui->is_hovered && ui_nodes_show_menu)) { ui_nodes_show_menu = true; @@ -650,9 +650,9 @@ void ui_nodes_draw_menubar() { ui_tooltip(string("%s (%s)", tr("Search for nodes"), any_map_get(g_keymap, "node_search"))); } g_ui->_x += g_ui->_w + 3; - g_ui->_y = 2 + start_y; - g_ui->ops->theme->BUTTON_COL = _BUTTON_COL; - g_ui->ops->theme->SHADOWS = _SHADOWS; + g_ui->_y = 2 + start_y; + g_theme->BUTTON_COL = _BUTTON_COL; + g_theme->SHADOWS = _SHADOWS; // Close node group if (ui_nodes_group_stack->length > 0 && ui_menubar_button(tr("Close"))) { array_pop(ui_nodes_group_stack); @@ -1050,13 +1050,13 @@ void ui_nodes_update(void *_) { i32 menuw = math_floor(ew * 2.3); draw_begin(NULL, false, 0); ui_begin_region(g_ui, math_floor(ui_nodes_popup_x), math_floor(py), menuw); - i32 _FILL_BUTTON_BG = g_ui->ops->theme->FILL_BUTTON_BG; - g_ui->ops->theme->FILL_BUTTON_BG = false; - i32 _ELEMENT_OFFSET = g_ui->ops->theme->ELEMENT_OFFSET; - g_ui->ops->theme->ELEMENT_OFFSET = 0; - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; - g_ui->ops->theme->ELEMENT_H = g_config->touch_ui ? (28 + 2) : 28; - ui_menu_h = category->length * UI_ELEMENT_H(); + i32 _FILL_BUTTON_BG = g_theme->FILL_BUTTON_BG; + g_theme->FILL_BUTTON_BG = false; + i32 _ELEMENT_OFFSET = g_theme->ELEMENT_OFFSET; + g_theme->ELEMENT_OFFSET = 0; + i32 _ELEMENT_H = g_theme->ELEMENT_H; + g_theme->ELEMENT_H = g_config->touch_ui ? (28 + 2) : 28; + ui_menu_h = category->length * UI_ELEMENT_H(); if (is_group_category) { ui_menu_h += g_project->_->material_groups->length * UI_ELEMENT_H(); } @@ -1116,10 +1116,10 @@ void ui_nodes_update(void *_) { } ui_nodes_hide_menu = g_ui->combo_selected_handle == NULL && !ui_nodes_show_menu_first && (g_ui->changed || g_ui->input_released || g_ui->input_released_r || g_ui->is_escape_down); - ui_nodes_show_menu_first = false; - g_ui->ops->theme->FILL_BUTTON_BG = _FILL_BUTTON_BG; - g_ui->ops->theme->ELEMENT_OFFSET = _ELEMENT_OFFSET; - g_ui->ops->theme->ELEMENT_H = _ELEMENT_H; + ui_nodes_show_menu_first = false; + g_theme->FILL_BUTTON_BG = _FILL_BUTTON_BG; + g_theme->ELEMENT_OFFSET = _ELEMENT_OFFSET; + g_theme->ELEMENT_H = _ELEMENT_H; ui_menu_end(); ui_end_region(); draw_end(); diff --git a/paint/sources/ui/ui_search.c b/paint/sources/ui/ui_search.c index d718462e..b78e33b4 100644 --- a/paint/sources/ui/ui_search.c +++ b/paint/sources/ui/ui_search.c @@ -29,13 +29,13 @@ void ui_base_operator_search_menu_draw() { } bool enter = keyboard_down("enter"); i32 count = 0; - i32 BUTTON_COL = g_ui->ops->theme->BUTTON_COL; + i32 BUTTON_COL = g_theme->BUTTON_COL; string_array_t *keys = map_keys(g_keymap); for (i32 i = 0; i < keys->length; ++i) { char *n = keys->buffer[i]; if (string_index_of(n, search) >= 0) { - g_ui->ops->theme->BUTTON_COL = count == ui_base_operator_search_offset ? g_ui->ops->theme->HIGHLIGHT_COL : g_ui->ops->theme->SEPARATOR_COL; + g_theme->BUTTON_COL = count == ui_base_operator_search_offset ? g_theme->HIGHLIGHT_COL : g_theme->SEPARATOR_COL; if (ui_button(n, UI_ALIGN_LEFT, any_map_get(g_keymap, n)) || (enter && count == ui_base_operator_search_offset)) { if (enter) { g_ui->changed = true; @@ -53,7 +53,7 @@ void ui_base_operator_search_menu_draw() { g_ui->changed = true; search_handle->text = ""; } - g_ui->ops->theme->BUTTON_COL = BUTTON_COL; + g_theme->BUTTON_COL = BUTTON_COL; } void ui_base_operator_search() { diff --git a/paint/sources/ui/ui_sidebar.c b/paint/sources/ui/ui_sidebar.c index ef49cfe4..c36ebf4e 100644 --- a/paint/sources/ui/ui_sidebar.c +++ b/paint/sources/ui/ui_sidebar.c @@ -8,23 +8,23 @@ void ui_sidebar_render_ui() { // Expand button if (g_config->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] == 0) { - i32 width = math_floor(draw_string_width(g_ui->ops->font, g_ui->font_size, "<") + 25 * UI_SCALE()); + i32 width = math_floor(draw_string_width(g_font, g_ui->font_size, "<") + 25 * UI_SCALE()); if (ui_window(ui_sidebar_hminimized, iron_window_width() - width, -1, width, math_floor(UI_ELEMENT_H() + 4 * UI_SCALE()), false)) { - ui_fill(0, 0, g_ui->_window_w, g_ui->_window_h + 1, g_ui->ops->theme->SEPARATOR_COL); - g_ui->_w = width; - i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - i32 _TEXT_COL = g_ui->ops->theme->TEXT_COL; - g_ui->ops->theme->BUTTON_H = g_ui->ops->theme->ELEMENT_H; - g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->SEPARATOR_COL; - g_ui->ops->theme->TEXT_COL = g_ui->ops->theme->HOVER_COL; + ui_fill(0, 0, g_ui->_window_w, g_ui->_window_h + 1, g_theme->SEPARATOR_COL); + g_ui->_w = width; + i32 _BUTTON_H = g_theme->BUTTON_H; + i32 _BUTTON_COL = g_theme->BUTTON_COL; + i32 _TEXT_COL = g_theme->TEXT_COL; + g_theme->BUTTON_H = g_theme->ELEMENT_H; + g_theme->BUTTON_COL = g_theme->SEPARATOR_COL; + g_theme->TEXT_COL = g_theme->HOVER_COL; if (ui_button("<", UI_ALIGN_CENTER, "")) { ui_sidebar_show(true); } - g_ui->ops->theme->BUTTON_H = _BUTTON_H; - g_ui->ops->theme->BUTTON_COL = _BUTTON_COL; - g_ui->ops->theme->TEXT_COL = _TEXT_COL; + g_theme->BUTTON_H = _BUTTON_H; + g_theme->BUTTON_COL = _BUTTON_COL; + g_theme->TEXT_COL = _TEXT_COL; } return; } @@ -34,9 +34,9 @@ void ui_sidebar_render_ui() { i32 expand_button_offset = g_config->touch_ui ? math_floor(UI_ELEMENT_H() + UI_ELEMENT_OFFSET()) : 0; ui_sidebar_tabx = iron_window_width() - g_config->layout->buffer[LAYOUT_SIZE_SIDEBAR_W]; - i32 _SCROLL_W = g_ui->ops->theme->SCROLL_W; + i32 _SCROLL_W = g_theme->SCROLL_W; if (mini) { - g_ui->ops->theme->SCROLL_W = g_ui->ops->theme->SCROLL_MINI_W; + g_theme->SCROLL_W = g_theme->SCROLL_MINI_W; } i32 sidebar_y = 0; @@ -46,7 +46,7 @@ void ui_sidebar_render_ui() { sidebar_y += UI_ELEMENT_H() + UI_ELEMENT_OFFSET(); ui_end(); draw_begin(NULL, false, 0); - draw_set_color(g_ui->ops->theme->PRESSED_COL); + draw_set_color(g_theme->PRESSED_COL); draw_filled_rect(ui_sidebar_tabx, 0, g_config->layout->buffer[LAYOUT_SIZE_SIDEBAR_W], sidebar_y); draw_end(); ui_begin(g_ui); @@ -79,24 +79,24 @@ void ui_sidebar_render_ui() { } ui_end_window(); - g_ui->ops->theme->SCROLL_W = _SCROLL_W; + g_theme->SCROLL_W = _SCROLL_W; // Collapse / expand button for mini sidebar if (g_config->touch_ui) { i32 width = g_config->layout->buffer[LAYOUT_SIZE_SIDEBAR_W]; i32 height = math_floor(UI_ELEMENT_H() + UI_ELEMENT_OFFSET()); if (ui_window(ui_handle(__ID__), iron_window_width() - width, iron_window_height() - height, width, height + 1, false)) { - g_ui->_w = width; - i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - g_ui->ops->theme->BUTTON_H = g_ui->ops->theme->ELEMENT_H; - g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->WINDOW_BG_COL; + g_ui->_w = width; + i32 _BUTTON_H = g_theme->BUTTON_H; + i32 _BUTTON_COL = g_theme->BUTTON_COL; + g_theme->BUTTON_H = g_theme->ELEMENT_H; + g_theme->BUTTON_COL = g_theme->WINDOW_BG_COL; if (ui_button(mini ? "<" : ">", UI_ALIGN_CENTER, "")) { g_config->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] = mini ? ui_sidebar_default_w_full : ui_sidebar_default_w_mini; g_config->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] = math_floor(g_config->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] * UI_SCALE()); } - g_ui->ops->theme->BUTTON_H = _BUTTON_H; - g_ui->ops->theme->BUTTON_COL = _BUTTON_COL; + g_theme->BUTTON_H = _BUTTON_H; + g_theme->BUTTON_COL = _BUTTON_COL; } } } diff --git a/paint/sources/ui/ui_statusbar.c b/paint/sources/ui/ui_statusbar.c index f5473aec..6f190e30 100644 --- a/paint/sources/ui/ui_statusbar.c +++ b/paint/sources/ui/ui_statusbar.c @@ -13,7 +13,7 @@ void ui_statusbar_render_ui() { i32 statush = g_config->layout->buffer[LAYOUT_SIZE_STATUS_H]; if (ui_window(ui_base_hwnds->buffer[TAB_AREA_STATUS], 0, iron_window_height() - statush, ui_statusbar_width(), statush, false)) { g_ui->_y += 2; - draw_set_color(g_ui->ops->theme->SEPARATOR_COL); + draw_set_color(g_theme->SEPARATOR_COL); draw_filled_rect(0, 0, 1, g_ui->_window_h); draw_filled_rect(g_ui->_window_w - 1, 0, 1, g_ui->_window_h); tab_draw_t_array_t *hwnd_draws = ui_base_hwnd_tabs->buffer[TAB_AREA_STATUS]; diff --git a/paint/sources/ui/ui_toolbar.c b/paint/sources/ui/ui_toolbar.c index dee07458..cb7df01c 100644 --- a/paint/sources/ui/ui_toolbar.c +++ b/paint/sources/ui/ui_toolbar.c @@ -41,7 +41,7 @@ void ui_toolbar_tool_properties_menu() { void ui_toolbar_draw_highlight() { i32 size = ui_toolbar_w(false) - 4; - draw_set_color(g_ui->ops->theme->HIGHLIGHT_COL); + draw_set_color(g_theme->HIGHLIGHT_COL); ui_draw_rect(true, g_ui->_x + -1, g_ui->_y + 2, size + 2, size + 2); } @@ -119,7 +119,7 @@ i32 ui_toolbar_x() { void ui_toolbar_draw_show_3d_view() { if (context_is_floating_toolbar()) { i32 toolbar_w = ui_toolbar_default_w * UI_SCALE() + 14 * UI_SCALE(); - i32 _WINDOW_BG_COL = g_ui->ops->theme->WINDOW_BG_COL; + i32 _WINDOW_BG_COL = g_theme->WINDOW_BG_COL; // ui.ops.theme.WINDOW_BG_COL = ui.ops.theme.SEPARATOR_COL; i32 y = ui_header_h + 8 * UI_SCALE(); @@ -128,27 +128,27 @@ void ui_toolbar_draw_show_3d_view() { } if (ui_window(ui_toolbar_handle, ui_toolbar_x(), y, toolbar_w, toolbar_w, false)) { - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; - i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - i32 _fontOffsetY = g_ui->font_offset_y; - g_ui->ops->theme->ELEMENT_H = math_floor(g_ui->ops->theme->ELEMENT_H * 1.5); - g_ui->ops->theme->BUTTON_H = g_ui->ops->theme->ELEMENT_H; - g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->WINDOW_BG_COL; - i32 font_height = draw_font_height(g_ui->ops->font, g_ui->font_size); - g_ui->font_offset_y = (UI_ELEMENT_H() - font_height) / 2.0; - i32 _w = g_ui->_w; - g_ui->_w = toolbar_w; + i32 _ELEMENT_H = g_theme->ELEMENT_H; + i32 _BUTTON_H = g_theme->BUTTON_H; + i32 _BUTTON_COL = g_theme->BUTTON_COL; + i32 _fontOffsetY = g_ui->font_offset_y; + g_theme->ELEMENT_H = math_floor(g_theme->ELEMENT_H * 1.5); + g_theme->BUTTON_H = g_theme->ELEMENT_H; + g_theme->BUTTON_COL = g_theme->WINDOW_BG_COL; + i32 font_height = draw_font_height(g_font, g_ui->font_size); + g_ui->font_offset_y = (UI_ELEMENT_H() - font_height) / 2.0; + i32 _w = g_ui->_w; + g_ui->_w = toolbar_w; if (ui_icon_button("", ICON_CUBE, UI_ALIGN_CENTER)) { ui_base_show_3d_view(); } - g_ui->_w = _w; - g_ui->ops->theme->ELEMENT_H = _ELEMENT_H; - g_ui->ops->theme->BUTTON_H = _BUTTON_H; - g_ui->ops->theme->BUTTON_COL = _BUTTON_COL; - g_ui->font_offset_y = _fontOffsetY; + g_ui->_w = _w; + g_theme->ELEMENT_H = _ELEMENT_H; + g_theme->BUTTON_H = _BUTTON_H; + g_theme->BUTTON_COL = _BUTTON_COL; + g_ui->font_offset_y = _fontOffsetY; } - g_ui->ops->theme->WINDOW_BG_COL = _WINDOW_BG_COL; + g_theme->WINDOW_BG_COL = _WINDOW_BG_COL; } } @@ -156,7 +156,7 @@ void ui_toolbar_render_ui() { i32 x = 0; i32 y = ui_header_h; i32 h = iron_window_height() - ui_header_h - g_config->layout->buffer[LAYOUT_SIZE_STATUS_H]; - i32 _WINDOW_BG_COL = g_ui->ops->theme->WINDOW_BG_COL; + i32 _WINDOW_BG_COL = g_theme->WINDOW_BG_COL; if (!base_view3d_show && !ui_view2d_show && !ui_nodes_show) { ui_toolbar_draw_show_3d_view(); @@ -174,8 +174,8 @@ void ui_toolbar_render_ui() { if (context_is_floating_toolbar()) { x += ui_toolbar_x(); y += ui_toolbar_x() + 3 * UI_SCALE(); - h = (ui_toolbar_tool_names->length + 1) * (ui_toolbar_w(false) + 2); - g_ui->ops->theme->WINDOW_BG_COL = g_ui->ops->theme->SEPARATOR_COL; + h = (ui_toolbar_tool_names->length + 1) * (ui_toolbar_w(false) + 2); + g_theme->WINDOW_BG_COL = g_theme->SEPARATOR_COL; if (!base_view3d_show && ui_view2d_show && !g_config->touch_ui) { y += ui_toolbar_w(false); } @@ -191,40 +191,40 @@ void ui_toolbar_render_ui() { g_ui->_y -= 4 * UI_SCALE(); g_ui->image_scroll_align = false; gpu_texture_t *img = resource_get("icons.k"); - u32 col = g_ui->ops->theme->WINDOW_BG_COL; + u32 col = g_theme->WINDOW_BG_COL; bool light = col > 0xff666666; i32 icon_accent = light ? 0xff666666 : -1; // Properties icon if (!context_is_floating_toolbar()) { rect_t *rect = resource_tile50(img, ICON_PROPERTIES); - if (ui_sub_image(img, light ? 0xff666666 : g_ui->ops->theme->BUTTON_COL, -1.0, rect->x, rect->y, rect->w, rect->h) == UI_STATE_RELEASED) { + if (ui_sub_image(img, light ? 0xff666666 : g_theme->BUTTON_COL, -1.0, rect->x, rect->y, rect->w, rect->h) == UI_STATE_RELEASED) { g_config->layout->buffer[LAYOUT_SIZE_HEADER] = 0; } } // Draw ">" button if header is hidden else { - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; - i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - i32 _fontOffsetY = g_ui->font_offset_y; - g_ui->ops->theme->ELEMENT_H = math_floor(g_ui->ops->theme->ELEMENT_H * 1.5); - g_ui->ops->theme->BUTTON_H = g_ui->ops->theme->ELEMENT_H; - g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->WINDOW_BG_COL; - i32 font_height = draw_font_height(g_ui->ops->font, g_ui->font_size); - g_ui->font_offset_y = (UI_ELEMENT_H() - font_height) / 2.0; - i32 _w = g_ui->_w; - g_ui->_w = ui_toolbar_w(false); + i32 _ELEMENT_H = g_theme->ELEMENT_H; + i32 _BUTTON_H = g_theme->BUTTON_H; + i32 _BUTTON_COL = g_theme->BUTTON_COL; + i32 _fontOffsetY = g_ui->font_offset_y; + g_theme->ELEMENT_H = math_floor(g_theme->ELEMENT_H * 1.5); + g_theme->BUTTON_H = g_theme->ELEMENT_H; + g_theme->BUTTON_COL = g_theme->WINDOW_BG_COL; + i32 font_height = draw_font_height(g_font, g_ui->font_size); + g_ui->font_offset_y = (UI_ELEMENT_H() - font_height) / 2.0; + i32 _w = g_ui->_w; + g_ui->_w = ui_toolbar_w(false); if (ui_button(">", UI_ALIGN_CENTER, "")) { ui_toolbar_tool_properties_menu(); } - g_ui->_w = _w; - g_ui->ops->theme->ELEMENT_H = _ELEMENT_H; - g_ui->ops->theme->BUTTON_H = _BUTTON_H; - g_ui->ops->theme->BUTTON_COL = _BUTTON_COL; - g_ui->font_offset_y = _fontOffsetY; + g_ui->_w = _w; + g_theme->ELEMENT_H = _ELEMENT_H; + g_theme->BUTTON_H = _BUTTON_H; + g_theme->BUTTON_COL = _BUTTON_COL; + g_ui->font_offset_y = _fontOffsetY; } if (g_ui->is_hovered) { ui_tooltip(tr("Toggle header")); @@ -239,14 +239,14 @@ void ui_toolbar_render_ui() { } if (context_is_floating_toolbar()) { - g_ui->ops->theme->WINDOW_BG_COL = _WINDOW_BG_COL; + g_theme->WINDOW_BG_COL = _WINDOW_BG_COL; } if (g_config->touch_ui) { // Hide scrollbar - i32 _SCROLL_W = g_ui->ops->theme->SCROLL_W; - g_ui->ops->theme->SCROLL_W = 0; + i32 _SCROLL_W = g_theme->SCROLL_W; + g_theme->SCROLL_W = 0; ui_end_window(); - g_ui->ops->theme->SCROLL_W = _SCROLL_W; + g_theme->SCROLL_W = _SCROLL_W; } } diff --git a/paint/sources/ui/ui_view2d.c b/paint/sources/ui/ui_view2d.c index 3772a9f4..c2753a02 100644 --- a/paint/sources/ui/ui_view2d.c +++ b/paint/sources/ui/ui_view2d.c @@ -341,7 +341,7 @@ void ui_view2d_update(void *_) { // let x: f32 = math_fmod(ui_view2d_pan_x, step) - step; // let y: f32 = math_fmod(ui_view2d_pan_y, step) - step; // draw_image(ui_view2d_grid, x, y); - draw_set_color(g_ui->ops->theme->SEPARATOR_COL + 0x00020202); + draw_set_color(g_theme->SEPARATOR_COL + 0x00020202); draw_filled_rect(0, 0, ui_view2d_ww, ui_view2d_wh); draw_set_color(0xffffffff); @@ -487,7 +487,7 @@ void ui_view2d_update(void *_) { // Menu i32 top_y = ui_menu_top_y(); i32 ew = math_floor(UI_ELEMENT_W()); - draw_set_color(g_ui->ops->theme->WINDOW_BG_COL); + draw_set_color(g_theme->WINDOW_BG_COL); draw_filled_rect(0, top_y, ui_view2d_ww, UI_ELEMENT_H() + UI_ELEMENT_OFFSET() * 2); draw_set_color(0xffffffff); @@ -500,7 +500,7 @@ void ui_view2d_update(void *_) { ui_handle_t *h = ui_handle(__ID__); char *text = ui_view2d_type == VIEW_2D_TYPE_NODE ? g_context->node_preview_name : h->text; - g_ui->_w = math_floor(math_min(draw_string_width(g_ui->ops->font, g_ui->font_size, text) + 15 * UI_SCALE(), 100 * UI_SCALE())); + g_ui->_w = math_floor(math_min(draw_string_width(g_font, g_ui->font_size, text) + 15 * UI_SCALE(), 100 * UI_SCALE())); if (ui_view2d_type == VIEW_2D_TYPE_ASSET) { asset_t *asset = g_context->texture;