This commit is contained in:
luboslenco
2025-03-10 22:13:30 +01:00
parent 9bb68734e9
commit 22f4ce584b
15 changed files with 565 additions and 571 deletions
+4 -4
View File
@@ -248,8 +248,8 @@ function box_preferences_show() {
// Theme fields
let hlist: ui_handle_t = ui_handle(__ID__);
let u32_theme: u32_ptr = base_theme;
for (let i: i32 = 0; i < ui_theme_keys.length; ++i) {
let key: string = ui_theme_keys[i];
for (let i: i32 = 0; i < ui_theme_keys_count; ++i) {
let key: string = ARRAY_ACCESS(ui_theme_keys, i);
let h: ui_handle_t = ui_nest(hlist, i);
let val: u32 = DEREFERENCE(u32_theme + i);
let is_hex: bool = ends_with(key, "_COL");
@@ -908,8 +908,8 @@ function box_preferences_set_scale() {
function box_preferences_theme_to_json(theme: ui_theme_t): string {
json_encode_begin();
let u32_theme: u32_ptr = theme;
for (let i: i32 = 0; i < ui_theme_keys.length; ++i) {
let key: string = ui_theme_keys[i];
for (let i: i32 = 0; i < ui_theme_keys_count; ++i) {
let key: string = ARRAY_ACCESS(ui_theme_keys, i);
let val: u32 = DEREFERENCE(u32_theme + i);
json_encode_i32(key, val);
}
+421
View File
@@ -727,3 +727,424 @@ enum shader_type_t {
FRAGMENT,
VERTEX,
}
declare let ui_nodes_enum_texts: (s: string)=>string[];
declare let ui_touch_scroll: bool;
declare let ui_touch_hold : bool;
declare let ui_touch_tooltip: bool;
declare let ui_always_redraw_window: bool;
declare let ui_on_border_hover: any;
declare let ui_on_text_hover: any;
declare let ui_on_deselect_text: any;
declare let ui_on_tab_drop: any;
declare let ui_nodes_on_link_drag: any;
declare let ui_nodes_on_socket_released: any;
declare let ui_nodes_on_canvas_released: any;
declare let ui_nodes_on_canvas_control: any;
declare let ui_text_area_line_numbers: bool;
declare let ui_text_area_scroll_past_end: bool;
declare let ui_text_area_coloring: any;
declare let ui_nodes_socket_released: bool;
declare let ui_is_cut: bool;
declare let ui_is_copy: bool;
declare let ui_is_paste: bool;
declare let ui_nodes_exclude_remove: string[];
declare let ui_clipboard: string;
declare let ui_nodes_grid_snap: bool;
declare function ui_nest(handle: ui_handle_t, pos: i32): ui_handle_t;
declare function ui_theme_default(theme: ui_theme_t): void;
declare function ui_tab(handle: ui_handle_t, text: string, vertical: bool = false, color: i32 = -1): bool;
declare function ui_combo(handle: ui_handle_t, texts: string[], label: string = "", show_label: bool = false, align: ui_align_t = ui_align_t.LEFT, search_bar: bool = true): i32;
declare function ui_slider(handle: ui_handle_t, text: string, from: f32 = 0.0, to: f32 = 1.0, filled: bool = false, precision: f32 = 100.0, display_value: bool = true, align: ui_align_t = ui_align_t.RIGHT, text_edit: bool = true): f32;
declare function ui_button(text: string, align: ui_align_t = ui_align_t.CENTER, label: string = ""): bool;
declare function ui_text(text: string, align: ui_align_t = ui_align_t.LEFT, bg: i32 = 0x00000000): ui_state_t;
declare function ui_text_input(handle: ui_handle_t, label: string = "", align: ui_align_t = ui_align_t.LEFT, editable: bool = true, live_update: bool = false): string;
declare function ui_check(handle: ui_handle_t, text: string, label: string = ""): bool;
declare function ui_color_wheel(handle: ui_handle_t, alpha: bool = false, w: f32 = -1.0, h: f32 = -1.0, color_preview: bool = true, picker: ()=>void = null, data: any = null): color_t;
declare function ui_hovered_tab_name(): string;
declare function ui_radio(handle: ui_handle_t, position: i32, text: string, label: string = ""): bool;
declare function ui_start_text_edit(handle: ui_handle_t, align: ui_align_t = ui_align_t.LEFT): void;
declare function ui_tooltip(s: string): void;
declare function ui_tooltip_image(tex: any, max_width: i32 = 0): void;
declare function ui_separator(h: i32 = 4, fill: bool = true): void;
declare function ui_text_area(handle: ui_handle_t, align: ui_align_t = ui_align_t.LEFT, editable: bool = true, label: string = "", word_wrap: bool = false): string;
declare function _ui_window(handle: ui_handle_t, x: i32, y: i32, w: i32, h: i32, drag: bool = false): bool;
declare function ui_begin(ui: ui_t): void;
declare function _ui_end(last: bool = true): void;
declare function ui_end_window(bind_global_g: bool = true): void;
declare function ui_end_region(last: bool = true): void;
declare function ui_float_input(handle: ui_handle_t, label: string = "", align: ui_align_t = ui_align_t.LEFT, precision: f32 = 1000.0): f32;
declare function ui_get_current(): ui_t;
declare function ui_remove_node(n: ui_node_t, canvas: ui_node_canvas_t): void;
declare function ui_next_link_id(links: ui_node_link_t[]): i32;
declare function ui_set_hovered_tab_name(s: string): void;
declare function ui_begin_sticky(): void;
declare function ui_end_sticky(): void;
declare function ui_row(r: f32[]): void;
declare function ui_row2(): void;
declare function ui_row3(): void;
declare function ui_row4(): void;
declare function ui_row5(): void;
declare function ui_row6(): void;
declare function ui_row7(): void;
declare function ui_handle_create(): ui_handle_t;
declare function ui_fill(x: i32, y: i32, w: i32, h: i32, color: i32): void;
declare function ui_rect(x: i32, y: i32, w: i32, h: i32, color: i32, strength: f32): void;
declare function ui_draw_shadow(x: i32, y: i32, w: i32, h: i32): void;
declare function ui_draw_rect(filled: bool, x: i32, y: i32, w: i32, h: i32): void;
declare function ui_draw_round_bottom(x: i32, y: i32, w: i32): void;
declare function ui_begin_menu(): void;
declare function ui_end_menu(): void;
declare function _ui_menu_button(s: string): bool;
declare function ui_begin_region(ui: ui_t, x: i32, y: i32, w: i32): void;
declare function ui_end_region(last: bool): void;
declare function ui_inline_radio(handle: ui_handle_t, texts: string[], align: i32): int;
declare function ui_end_input(): void;
declare function ui_panel(handle: ui_handle_t, text: string, is_tree: bool, filled: bool): bool;
declare function ui_nodes_rgba_popup(nhandle: ui_handle_t, val: f32_ptr, x: i32, y: i32): void;
declare function ui_get_link(links: ui_node_link_t[], id: i32): ui_node_link_t;
declare function ui_get_node(nodes: ui_node_t[], id: i32): ui_node_t;
declare function ui_input_in_rect(x: f32, y: f32, w: f32, h: f32): bool;
declare function ui_get_socket_id(nodes: ui_node_t[]): i32;
declare function ui_draw_string(text: string, x_offset: f32, y_offset: f32, align: i32, truncation: bool): void;
declare function ui_next_node_id(nodes: ui_node_t[]): i32;
declare function ui_node_canvas(nodes: ui_nodes_t, canvas: ui_node_canvas_t): void;
declare type iron_gpu_texture_t = {
width: i32;
height: i32;
};
declare type ui_theme_t = any;
declare type ui_t = {
ops: ui_options_t;
is_hovered: bool;
is_typing: bool;
is_escape_down: bool;
is_delete_down: bool;
is_return_down: bool;
is_ctrl_down: bool;
is_released: bool;
is_key_pressed: bool;
is_scrolling: bool;
key_code: i32;
input_started: bool;
input_started_r: bool;
input_released: bool;
input_released_r: bool;
input_x: i32;
input_y: i32;
input_started_x: i32;
input_started_y: i32;
input_enabled: bool;
input_down_r: bool;
input_dx: i32;
input_dy: i32;
input_wheel_delta: i32;
_x: i32;
_y: i32;
_w: i32;
_window_w: i32;
_window_h: i32;
_window_x: i32;
_window_y: i32;
scroll_enabled: bool;
input_down: bool;
font_size: i32;
image_scroll_align: bool;
changed: bool;
font_offset_y: f32;
enabled: bool;
scissor: bool;
text_selected_handle: ui_handle_t;
submit_text_handle: ui_handle_t;
combo_selected_handle: ui_handle_t;
current_ratio: i32;
image_invert_y: bool;
elements_baked: bool;
window_border_right: i32;
window_border_top: i32;
window_border_bottom: i32;
};
declare type ui_handle_t = {
selected: bool;
position: i32;
color: u32;
value: f32;
text: string;
// iron_gpu_texture_t texture;
redraws: i32;
scroll_offset: f32;
scroll_enabled: bool;
layout: i32;
last_max_x: f32;
last_max_y: f32;
drag_enabled: bool;
drag_x: i32;
drag_y: i32;
changed: bool;
init: bool;
children: ui_handle_t[];
};
declare type ui_options_t = {
font?: draw_font_t;
theme?: ui_theme_t;
scale_factor?: f32;
color_wheel?: iron_gpu_texture_t;
black_white_gradient?: iron_gpu_texture_t;
};
declare type ui_coloring_t = {
color?: u32;
start?: string[];
end?: string;
separated?: bool;
};
declare type ui_text_coloring_t = {
colorings?: ui_coloring_t[];
default_color?: u32;
};
declare type ui_canvas_control_t = {
pan_x?: f32;
pan_y?: f32;
zoom?: f32;
controls_down?: bool;
};
declare type ui_node_canvas_t = {
name?: string;
nodes?: ui_node_t[];
links?: ui_node_link_t[];
};
declare type ui_node_t = {
id?: i32;
name?: string;
type?: string;
x?: f32;
y?: f32;
color?: u32;
inputs?: ui_node_socket_t[];
outputs?: ui_node_socket_t[];
buttons?: ui_node_button_t[];
width?: f32;
};
declare type ui_node_socket_t = {
id?: i32;
node_id?: i32;
name?: string;
type?: string;
color?: u32;
default_value?: f32_array_t;
min?: f32;
max?: f32;
precision?: f32;
display?: i32;
};
declare type ui_node_link_t = {
id?: i32;
from_id?: i32;
from_socket?: i32;
to_id?: i32;
to_socket?: i32;
};
declare type ui_node_button_t = {
name?: string;
type?: string;
output?: i32;
default_value?: f32_array_t;
data?: u8_array_t;
min?: f32;
max?: f32;
precision?: f32;
height?: f32;
};
declare type ui_nodes_t = {
color_picker_callback?: (col: color_t)=>void;
nodes_selected_id?: i32[];
_input_started?: bool;
nodes_drag?: bool;
pan_x?: f32;
pan_y?: f32;
zoom?: f32;
link_drag_id?: i32;
};
enum ui_layout_t {
VERTICAL,
HORIZONTAL,
}
enum ui_align_t {
LEFT,
CENTER,
RIGHT,
}
enum ui_state_t {
IDLE,
STARTED,
DOWN,
RELEASED,
HOVERED,
}
let ui_children: map_t<string, ui_handle_t> = map_create();
let ui_nodes_custom_buttons: map_t<string, (i: i32)=>void> = map_create();
declare function UI_OUTPUTS_H(sockets_count: i32, length: i32 = -1): f32;
declare function ui_tooltip_image(image: iron_gpu_texture_t, max_width: i32 = 0);
function ui_SCALE(ui: ui_t): f32 {
let current: ui_t = ui_get_current();
ui_set_current(ui);
let f: f32 = UI_SCALE();
ui_set_current(current);
return f;
}
function ui_ELEMENT_OFFSET(ui: ui_t): f32 {
let current: ui_t = ui_get_current();
ui_set_current(ui);
let f: f32 = UI_ELEMENT_OFFSET();
ui_set_current(current);
return f;
}
function ui_ELEMENT_W(ui: ui_t): f32 {
let current: ui_t = ui_get_current();
ui_set_current(ui);
let f: f32 = UI_ELEMENT_W();
ui_set_current(current);
return f;
}
function ui_ELEMENT_H(ui: ui_t): f32 {
let current: ui_t = ui_get_current();
ui_set_current(ui);
let f: f32 = UI_ELEMENT_H();
ui_set_current(current);
return f;
}
function ui_MENUBAR_H(ui: ui_t): f32 {
let button_offset_y: f32 = (ui.ops.theme.ELEMENT_H * ui_SCALE(ui) - ui.ops.theme.BUTTON_H * ui_SCALE(ui)) / 2;
return ui.ops.theme.BUTTON_H * ui_SCALE(ui) * 1.1 + 2 + button_offset_y;
}
function ui_nodes_INPUT_Y(canvas: ui_node_canvas_t, sockets: ui_node_socket_t[], pos: i32): f32 {
return UI_INPUT_Y(canvas, sockets.buffer, sockets.length, pos);
}
function _ui_image(image: iron_gpu_texture_t, tint: i32 = 0xffffffff, h: f32 = -1.0, sx: i32 = 0, sy: i32 = 0, sw: i32 = 0, sh: i32 = 0): ui_state_t {
return ui_sub_image(image, tint, h, sx, sy, sw, sh);
}
function ui_window(handle: ui_handle_t, x: i32, y: i32, w: i32, h: i32, drag: bool = false): bool {
_draw_current = ADDRESS(handle.texture);
_draw_in_use = true;
return _ui_window(handle, x, y, w, h, drag);
}
function ui_end(last: bool = true) {
_draw_current = null;
_draw_in_use = false;
_ui_end(last);
}
function _ui_set_scale(ui: ui_t, factor: f32) {
let current: ui_t = ui_get_current();
ui_set_current(ui);
ui_set_scale(factor);
ui_set_current(current);
}
function _ui_end_element(element_size: f32 = -1.0) {
if (element_size < 0) {
ui_end_element();
}
else {
ui_end_element_of_size(element_size);
}
}
function _ui_end_input(ui: ui_t) {
let current: ui_t = ui_get_current();
ui_set_current(ui);
ui_end_input();
ui_set_current(current);
}
function ui_handle(s: string): ui_handle_t {
let h: ui_handle_t = map_get(ui_children, s);
if (h == null) {
h = ui_handle_create();
map_set(ui_children, s, h);
return h;
}
h.init = false;
return h;
}
function ui_create(ops: ui_options_t): ui_t {
let raw: ui_t = {};
ui_init(raw, ops);
return raw;
}
function ui_theme_create(): ui_theme_t {
let raw: ui_theme_t = {};
ui_theme_default(raw);
return raw;
}
function nodes_on_custom_button(node_id: i32, button_name: string) {
let f: (i: i32) => void = map_get(ui_nodes_custom_buttons, button_name);
f(node_id);
}
function ui_nodes_create(): ui_nodes_t {
let raw: ui_nodes_t = {};
ui_nodes_init(raw);
ui_nodes_exclude_remove = [
"OUTPUT_MATERIAL_PBR",
"GROUP_OUTPUT",
"GROUP_INPUT",
"BrushOutputNode"
];
ui_nodes_on_custom_button = nodes_on_custom_button;
return raw;
}
function ui_get_socket(nodes: ui_node_t[], id: i32): ui_node_socket_t {
for (let i: i32 = 0; i < nodes.length; ++i) {
let n: ui_node_t = nodes[i];
for (let j: i32 = 0; j < n.inputs.length; ++j) {
let s: ui_node_socket_t = n.inputs[j];
if (s.id == id) {
return s;
}
}
for (let j: i32 = 0; j < n.outputs.length; ++j) {
let s: ui_node_socket_t = n.outputs[j];
if (s.id == id) {
return s;
}
}
}
return null;
}
function ui_set_font(raw: ui_t, font: draw_font_t) {
draw_font_init(font); // Make sure font is ready
raw.ops.font = font;
}
-528
View File
@@ -1,528 +0,0 @@
let ui_children: map_t<string, ui_handle_t> = map_create();
// let ui_tr: (id: string, vars: map_t<string, string>)=>string;
let _ui_row2: f32[] = [1.0 / 2.0, 1.0 / 2.0];
let _ui_row3: f32[] = [1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0];
let _ui_row4: f32[] = [1.0 / 4.0, 1.0 / 4.0, 1.0 / 4.0, 1.0 / 4.0];
let _ui_row5: f32[] = [1.0 / 5.0, 1.0 / 5.0, 1.0 / 5.0, 1.0 / 5.0, 1.0 / 5.0];
let _ui_row6: f32[] = [1.0 / 6.0, 1.0 / 6.0, 1.0 / 6.0, 1.0 / 6.0, 1.0 / 6.0, 1.0 / 6.0];
let _ui_row7: f32[] = [1.0 / 7.0, 1.0 / 7.0, 1.0 / 7.0, 1.0 / 7.0, 1.0 / 7.0, 1.0 / 7.0, 1.0 / 7.0];
function ui_row2() {
ui_row(_ui_row2);
}
function ui_row3() {
ui_row(_ui_row3);
}
function ui_row4() {
ui_row(_ui_row4);
}
function ui_row5() {
ui_row(_ui_row5);
}
function ui_row6() {
ui_row(_ui_row6);
}
function ui_row7() {
ui_row(_ui_row7);
}
function ui_SCALE(ui: ui_t): f32 {
let current: ui_t = ui_get_current();
ui_set_current(ui);
let f: f32 = UI_SCALE();
ui_set_current(current);
return f;
}
function ui_ELEMENT_OFFSET(ui: ui_t): f32 {
let current: ui_t = ui_get_current();
ui_set_current(ui);
let f: f32 = UI_ELEMENT_OFFSET();
ui_set_current(current);
return f;
}
function ui_ELEMENT_W(ui: ui_t): f32 {
let current: ui_t = ui_get_current();
ui_set_current(ui);
let f: f32 = UI_ELEMENT_W();
ui_set_current(current);
return f;
}
function ui_ELEMENT_H(ui: ui_t): f32 {
let current: ui_t = ui_get_current();
ui_set_current(ui);
let f: f32 = UI_ELEMENT_H();
ui_set_current(current);
return f;
}
function ui_MENUBAR_H(ui: ui_t): f32 {
let button_offset_y: f32 = (ui.ops.theme.ELEMENT_H * ui_SCALE(ui) - ui.ops.theme.BUTTON_H * ui_SCALE(ui)) / 2;
return ui.ops.theme.BUTTON_H * ui_SCALE(ui) * 1.1 + 2 + button_offset_y;
}
function ui_nodes_LINE_H(): f32 {
return UI_LINE_H();
}
function ui_nodes_SCALE(): f32 {
return UI_NODES_SCALE();
}
function ui_nodes_p(f: f32): f32 {
return ui_p(f);
}
function ui_nodes_NODE_X(node: ui_node_t): f32 {
return UI_NODE_X(node);
}
function ui_nodes_NODE_Y(node: ui_node_t): f32 {
return UI_NODE_Y(node);
}
function ui_nodes_NODE_W(node: ui_node_t): f32 {
return UI_NODE_W(node);
}
function ui_nodes_NODE_H(canvas: ui_node_canvas_t, node: ui_node_t): f32 {
return UI_NODE_H(canvas, node);
}
function ui_nodes_OUTPUT_Y(sockets_count: i32, pos: i32): f32 {
return UI_OUTPUT_Y(sockets_count, pos);
}
function ui_nodes_INPUT_Y(canvas: ui_node_canvas_t, sockets: ui_node_socket_t[], pos: i32): f32 {
return UI_INPUT_Y(canvas, sockets.buffer, sockets.length, pos);
}
function ui_nodes_OUTPUTS_H(sockets_count: i32, length: i32 = -1): f32 {
return UI_OUTPUTS_H(sockets_count, length);
}
function ui_nodes_BUTTONS_H(node: ui_node_t): f32 {
return UI_BUTTONS_H(node);
}
function ui_nodes_PAN_X(): f32 {
return UI_NODES_PAN_X();
}
function ui_nodes_PAN_Y(): f32 {
return UI_NODES_PAN_Y();
}
function _ui_image(image: iron_gpu_texture_t, tint: i32 = 0xffffffff, h: f32 = -1.0, sx: i32 = 0, sy: i32 = 0, sw: i32 = 0, sh: i32 = 0): ui_state_t {
return ui_sub_image(image, tint, h, sx, sy, sw, sh);
}
function _ui_tooltip_image(image: iron_gpu_texture_t, max_width: i32 = 0) {
return ui_tooltip_image(image, max_width);
}
function ui_window(handle: ui_handle_t, x: i32, y: i32, w: i32, h: i32, drag: bool = false): bool {
_draw_current = ADDRESS(handle.texture);
_draw_in_use = true;
return _ui_window(handle, x, y, w, h, drag);
}
function ui_end(last: bool = true) {
_draw_current = null;
_draw_in_use = false;
_ui_end(last);
}
function _ui_set_scale(ui: ui_t, factor: f32) {
let current: ui_t = ui_get_current();
ui_set_current(ui);
ui_set_scale(factor);
ui_set_current(current);
}
function _ui_end_element(element_size: f32 = -1.0) {
if (element_size < 0) {
ui_end_element();
}
else {
ui_end_element_of_size(element_size);
}
}
function _ui_end_input(ui: ui_t) {
let current: ui_t = ui_get_current();
ui_set_current(ui);
ui_end_input();
ui_set_current(current);
}
function ui_handle(s: string): ui_handle_t {
let h: ui_handle_t = map_get(ui_children, s);
if (h == null) {
h = ui_handle_create();
map_set(ui_children, s, h);
return h;
}
h.init = false;
return h;
}
function ui_create(ops: ui_options_t): ui_t {
let raw: ui_t = {};
ui_init(raw, ops);
return raw;
}
function ui_theme_create(): ui_theme_t {
let raw: ui_theme_t = {};
ui_theme_default(raw);
return raw;
}
let ui_nodes_custom_buttons: map_t<string, (i: i32)=>void> = map_create();
function nodes_on_custom_button(node_id: i32, button_name: string) {
let f: (i: i32) => void = map_get(ui_nodes_custom_buttons, button_name);
f(node_id);
}
function ui_nodes_create(): ui_nodes_t {
let raw: ui_nodes_t = {};
ui_nodes_init(raw);
ui_nodes_exclude_remove = [
"OUTPUT_MATERIAL_PBR",
"GROUP_OUTPUT",
"GROUP_INPUT",
"BrushOutputNode"
];
ui_nodes_on_custom_button = nodes_on_custom_button;
return raw;
}
function ui_get_socket(nodes: ui_node_t[], id: i32): ui_node_socket_t {
for (let i: i32 = 0; i < nodes.length; ++i) {
let n: ui_node_t = nodes[i];
for (let j: i32 = 0; j < n.inputs.length; ++j) {
let s: ui_node_socket_t = n.inputs[j];
if (s.id == id) {
return s;
}
}
for (let j: i32 = 0; j < n.outputs.length; ++j) {
let s: ui_node_socket_t = n.outputs[j];
if (s.id == id) {
return s;
}
}
}
return null;
}
function ui_set_font(raw: ui_t, font: draw_font_t) {
draw_font_init(font); // Make sure font is ready
raw.ops.font = font;
}
declare let ui_nodes_enum_texts: (s: string)=>string[];
declare let ui_touch_scroll: bool;
declare let ui_touch_hold : bool;
declare let ui_touch_tooltip: bool;
declare let ui_always_redraw_window: bool;
declare let ui_on_border_hover: any;
declare let ui_on_text_hover: any;
declare let ui_on_deselect_text: any;
declare let ui_on_tab_drop: any;
declare let ui_nodes_on_link_drag: any;
declare let ui_nodes_on_socket_released: any;
declare let ui_nodes_on_canvas_released: any;
declare let ui_nodes_on_canvas_control: any;
declare let ui_text_area_line_numbers: bool;
declare let ui_text_area_scroll_past_end: bool;
declare let ui_text_area_coloring: any;
declare let ui_nodes_socket_released: bool;
declare let ui_is_cut: bool;
declare let ui_is_copy: bool;
declare let ui_is_paste: bool;
declare let ui_nodes_exclude_remove: string[];
declare let ui_clipboard: string;
declare let ui_nodes_grid_snap: bool;
declare function ui_nest(handle: ui_handle_t, pos: i32): ui_handle_t;
declare function ui_theme_default(theme: ui_theme_t): void;
declare function ui_tab(handle: ui_handle_t, text: string, vertical: bool = false, color: i32 = -1): bool;
declare function ui_combo(handle: ui_handle_t, texts: string[], label: string = "", show_label: bool = false, align: ui_align_t = ui_align_t.LEFT, search_bar: bool = true): i32;
declare function ui_slider(handle: ui_handle_t, text: string, from: f32 = 0.0, to: f32 = 1.0, filled: bool = false, precision: f32 = 100.0, display_value: bool = true, align: ui_align_t = ui_align_t.RIGHT, text_edit: bool = true): f32;
declare function ui_button(text: string, align: ui_align_t = ui_align_t.CENTER, label: string = ""): bool;
declare function ui_text(text: string, align: ui_align_t = ui_align_t.LEFT, bg: i32 = 0x00000000): ui_state_t;
declare function ui_text_input(handle: ui_handle_t, label: string = "", align: ui_align_t = ui_align_t.LEFT, editable: bool = true, live_update: bool = false): string;
declare function ui_check(handle: ui_handle_t, text: string, label: string = ""): bool;
declare function ui_color_wheel(handle: ui_handle_t, alpha: bool = false, w: f32 = -1.0, h: f32 = -1.0, color_preview: bool = true, picker: ()=>void = null, data: any = null): color_t;
declare function ui_hovered_tab_name(): string;
declare function ui_radio(handle: ui_handle_t, position: i32, text: string, label: string = ""): bool;
declare function ui_start_text_edit(handle: ui_handle_t, align: ui_align_t = ui_align_t.LEFT): void;
declare function ui_tooltip(s: string): void;
declare function ui_tooltip_image(tex: any, max_width: i32 = 0): void;
declare function ui_separator(h: i32 = 4, fill: bool = true): void;
declare function ui_text_area(handle: ui_handle_t, align: ui_align_t = ui_align_t.LEFT, editable: bool = true, label: string = "", word_wrap: bool = false): string;
declare function _ui_window(handle: ui_handle_t, x: i32, y: i32, w: i32, h: i32, drag: bool = false): bool;
declare function ui_begin(ui: ui_t): void;
declare function _ui_end(last: bool = true): void;
declare function ui_end_window(bind_global_g: bool = true): void;
declare function ui_end_region(last: bool = true): void;
declare function ui_float_input(handle: ui_handle_t, label: string = "", align: ui_align_t = ui_align_t.LEFT, precision: f32 = 1000.0): f32;
declare function ui_get_current(): ui_t;
declare function ui_remove_node(n: ui_node_t, canvas: ui_node_canvas_t): void;
declare function ui_next_link_id(links: ui_node_link_t[]): i32;
declare function ui_set_hovered_tab_name(s: string): void;
declare function ui_begin_sticky(): void;
declare function ui_end_sticky(): void;
declare function ui_row(r: f32[]): void;
declare function ui_handle_create(): ui_handle_t;
declare function ui_fill(x: i32, y: i32, w: i32, h: i32, color: i32): void;
declare function ui_rect(x: i32, y: i32, w: i32, h: i32, color: i32, strength: f32): void;
declare function ui_draw_shadow(x: i32, y: i32, w: i32, h: i32): void;
declare function ui_draw_rect(filled: bool, x: i32, y: i32, w: i32, h: i32): void;
declare function ui_draw_round_bottom(x: i32, y: i32, w: i32): void;
declare function ui_begin_menu(): void;
declare function ui_end_menu(): void;
declare function _ui_menu_button(s: string): bool;
declare function ui_begin_region(ui: ui_t, x: i32, y: i32, w: i32): void;
declare function ui_end_region(last: bool): void;
declare function ui_inline_radio(handle: ui_handle_t, texts: string[], align: i32): int;
declare function ui_end_input(): void;
declare function ui_panel(handle: ui_handle_t, text: string, is_tree: bool, filled: bool): bool;
declare function ui_nodes_rgba_popup(nhandle: ui_handle_t, val: f32_ptr, x: i32, y: i32): void;
declare function ui_get_link(links: ui_node_link_t[], id: i32): ui_node_link_t;
declare function ui_get_node(nodes: ui_node_t[], id: i32): ui_node_t;
declare function ui_input_in_rect(x: f32, y: f32, w: f32, h: f32): bool;
declare function ui_get_socket_id(nodes: ui_node_t[]): i32;
declare function ui_draw_string(text: string, x_offset: f32, y_offset: f32, align: i32, truncation: bool): void;
declare function ui_next_node_id(nodes: ui_node_t[]): i32;
declare function ui_node_canvas(nodes: ui_nodes_t, canvas: ui_node_canvas_t): void;
declare type iron_gpu_texture_t = {
width: i32;
height: i32;
};
declare type ui_theme_t = any;
declare type ui_t = {
ops: ui_options_t;
is_hovered: bool;
is_typing: bool;
is_escape_down: bool;
is_delete_down: bool;
is_return_down: bool;
is_ctrl_down: bool;
is_released: bool;
is_key_pressed: bool;
is_scrolling: bool;
key_code: i32;
input_started: bool;
input_started_r: bool;
input_released: bool;
input_released_r: bool;
input_x: i32;
input_y: i32;
input_started_x: i32;
input_started_y: i32;
input_enabled: bool;
input_down_r: bool;
input_dx: i32;
input_dy: i32;
input_wheel_delta: i32;
_x: i32;
_y: i32;
_w: i32;
_window_w: i32;
_window_h: i32;
_window_x: i32;
_window_y: i32;
scroll_enabled: bool;
input_down: bool;
font_size: i32;
image_scroll_align: bool;
changed: bool;
font_offset_y: f32;
enabled: bool;
scissor: bool;
text_selected_handle: ui_handle_t;
submit_text_handle: ui_handle_t;
combo_selected_handle: ui_handle_t;
current_ratio: i32;
image_invert_y: bool;
elements_baked: bool;
window_border_right: i32;
window_border_top: i32;
window_border_bottom: i32;
};
declare type ui_handle_t = {
selected: bool;
position: i32;
color: u32;
value: f32;
text: string;
// iron_gpu_texture_t texture;
redraws: i32;
scroll_offset: f32;
scroll_enabled: bool;
layout: i32;
last_max_x: f32;
last_max_y: f32;
drag_enabled: bool;
drag_x: i32;
drag_y: i32;
changed: bool;
init: bool;
children: ui_handle_t[];
};
declare type ui_options_t = {
font?: draw_font_t;
theme?: ui_theme_t;
scale_factor?: f32;
color_wheel?: iron_gpu_texture_t;
black_white_gradient?: iron_gpu_texture_t;
};
declare type ui_coloring_t = {
color?: u32;
start?: string[];
end?: string;
separated?: bool;
};
declare type ui_text_coloring_t = {
colorings?: ui_coloring_t[];
default_color?: u32;
};
declare type ui_canvas_control_t = {
pan_x?: f32;
pan_y?: f32;
zoom?: f32;
controls_down?: bool;
};
declare type ui_node_canvas_t = {
name?: string;
nodes?: ui_node_t[];
links?: ui_node_link_t[];
};
declare type ui_node_t = {
id?: i32;
name?: string;
type?: string;
x?: f32;
y?: f32;
color?: u32;
inputs?: ui_node_socket_t[];
outputs?: ui_node_socket_t[];
buttons?: ui_node_button_t[];
width?: f32;
};
declare type ui_node_socket_t = {
id?: i32;
node_id?: i32;
name?: string;
type?: string;
color?: u32;
default_value?: f32_array_t;
min?: f32;
max?: f32;
precision?: f32;
display?: i32;
};
declare type ui_node_link_t = {
id?: i32;
from_id?: i32;
from_socket?: i32;
to_id?: i32;
to_socket?: i32;
};
declare type ui_node_button_t = {
name?: string;
type?: string;
output?: i32;
default_value?: f32_array_t;
data?: u8_array_t;
min?: f32;
max?: f32;
precision?: f32;
height?: f32;
};
declare type ui_nodes_t = {
color_picker_callback?: (col: color_t)=>void;
nodes_selected_id?: i32[];
_input_started?: bool;
nodes_drag?: bool;
pan_x?: f32;
pan_y?: f32;
zoom?: f32;
link_drag_id?: i32;
};
enum ui_layout_t {
VERTICAL,
HORIZONTAL,
}
enum ui_align_t {
LEFT,
CENTER,
RIGHT,
}
enum ui_state_t {
IDLE,
STARTED,
DOWN,
RELEASED,
HOVERED,
}
let ui_theme_keys: string[] = [
"WINDOW_BG_COL",
"HOVER_COL",
"ACCENT_COL",
"BUTTON_COL",
"PRESSED_COL",
"TEXT_COL",
"LABEL_COL",
"SEPARATOR_COL",
"HIGHLIGHT_COL",
"FONT_SIZE",
"ELEMENT_W",
"ELEMENT_H",
"ELEMENT_OFFSET",
"ARROW_SIZE",
"BUTTON_H",
"CHECK_SIZE",
"CHECK_SELECT_SIZE",
"SCROLL_W",
"SCROLL_MINI_W",
"TEXT_OFFSET",
"TAB_W",
"FILL_WINDOW_BG",
"FILL_BUTTON_BG",
"LINK_STYLE",
"FULL_TABS",
"ROUND_CORNERS",
"SHADOWS",
"VIEWPORT_COL"
];
+6 -6
View File
@@ -3999,7 +3999,7 @@ function nodes_material_vector_curves_button(node_id: i32) {
// Preview
let axis: i32 = ui_nest(ui_nest(nhandle, 0), 1).position;
let val: f32[] = but.default_value;
ui._y += ui_nodes_LINE_H() * 5;
ui._y += UI_LINE_H() * 5;
let num: i32 = val[96 + axis];
@@ -4064,13 +4064,13 @@ function nodes_material_color_ramp_button(node_id: i32) {
// Preview
let vals: f32[] = but.default_value; // [r, g, b, a, pos, r, g, b, a, pos, ..]
let sw: f32 = ui._w / ui_nodes_SCALE();
let sw: f32 = ui._w / UI_NODES_SCALE();
for (let i: i32 = 0; i < vals.length / 5; ++i) {
let pos: f32 = vals[i * 5 + 4];
let col: i32 = color_from_floats(vals[i * 5 + 0], vals[i * 5 + 1], vals[i * 5 + 2], 1.0);
ui_fill(pos * sw, 0, (1.0 - pos) * sw, ui_nodes_LINE_H() - 2 * ui_nodes_SCALE(), col);
ui_fill(pos * sw, 0, (1.0 - pos) * sw, UI_LINE_H() - 2 * UI_NODES_SCALE(), col);
}
ui._y += ui_nodes_LINE_H();
ui._y += UI_LINE_H();
// Edit
let ihandle: ui_handle_t = ui_nest(ui_nest(nhandle, 0), 2);
let row: f32[] = [1 / 4, 1 / 4, 2 / 4];
@@ -4117,8 +4117,8 @@ function nodes_material_color_ramp_button(node_id: i32) {
let chandle: ui_handle_t = ui_nest(ui_nest(nhandle, 0), 4);
chandle.color = color_from_floats(vals[i * 5 + 0], vals[i * 5 + 1], vals[i * 5 + 2], 1.0);
if (ui_text("", ui_align_t.RIGHT, chandle.color) == ui_state_t.STARTED) {
let rx: f32 = nx + ui._w - ui_nodes_p(37);
let ry: f32 = ny - ui_nodes_p(5);
let rx: f32 = nx + ui._w - ui_p(37);
let ry: f32 = ny - ui_p(5);
nodes._input_started = ui.input_started = false;
ui_nodes_rgba_popup(chandle, vals.buffer + i * 5, math_floor(rx), math_floor(ry + ui_ELEMENT_H(ui)));
}
+1 -1
View File
@@ -133,7 +133,7 @@ function tab_brushes_draw(htab: ui_handle_t) {
});
}
else {
_ui_tooltip_image(img_full);
ui_tooltip_image(img_full);
ui_tooltip(project_brushes[i].canvas.name);
}
}
+1 -1
View File
@@ -129,7 +129,7 @@ function tab_fonts_draw(htab: ui_handle_t) {
});
}
else {
_ui_tooltip_image(img);
ui_tooltip_image(img);
ui_tooltip(project_fonts[i].name);
}
}
+2 -2
View File
@@ -581,10 +581,10 @@ function tab_layers_handle_layer_icon_state(l: slot_layer_t, i: i32, state: ui_s
if (ui.is_hovered && texpaint_preview != null) {
if (slot_layer_is_mask(l)) {
tab_layers_make_mask_preview_rgba32(l);
_ui_tooltip_image(context_raw.mask_preview_rgba32);
ui_tooltip_image(context_raw.mask_preview_rgba32);
}
else {
_ui_tooltip_image(texpaint_preview);
ui_tooltip_image(texpaint_preview);
}
if (i < 9) {
let i1: i32 = (i + 1);
+1 -1
View File
@@ -259,7 +259,7 @@ function tab_materials_draw_slots(mini: bool) {
});
}
if (ui.is_hovered) {
_ui_tooltip_image(img_full);
ui_tooltip_image(img_full);
if (i < 9) {
let i1: i32 = i + 1;
ui_tooltip(project_materials[i].canvas.name + " - (" + map_get(config_keymap, "select_material") + " " + i1 + ")");
+1 -1
View File
@@ -117,7 +117,7 @@ function tab_textures_draw(htab: ui_handle_t) {
let is_packed: bool = project_raw.packed_assets != null && project_packed_asset_exists(project_raw.packed_assets, asset.file);
if (ui.is_hovered) {
_ui_tooltip_image(img, 256);
ui_tooltip_image(img, 256);
if (is_packed) {
ui_tooltip(asset.name + " " + tr("(packed)"));
}
+2 -2
View File
@@ -243,7 +243,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool =
}
state = _ui_image(icon, 0xffffffff, w * ui_SCALE(ui));
if (ui.is_hovered) {
_ui_tooltip_image(icon);
ui_tooltip_image(icon);
ui_tooltip(f);
}
generic = false;
@@ -296,7 +296,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool =
}
state = _ui_image(icon, 0xffffffff, w * ui_SCALE(ui));
if (ui.is_hovered) {
_ui_tooltip_image(icon);
ui_tooltip_image(icon);
ui_tooltip(f);
}
generic = false;
+15 -11
View File
@@ -88,15 +88,15 @@ function ui_viewnodes_on_link_drag(link_drag_id: i32, is_new_link: bool) {
let link_drag: ui_node_link_t = ui_get_link(links, link_drag_id);
let nodes: ui_node_t[] = ui_nodes_get_canvas(true).nodes;
let node: ui_node_t = ui_get_node(nodes, link_drag.from_id > -1 ? link_drag.from_id : link_drag.to_id);
let link_x: i32 = ui_nodes_ui._window_x + ui_nodes_NODE_X(node);
let link_y: i32 = ui_nodes_ui._window_y + ui_nodes_NODE_Y(node);
let link_x: i32 = ui_nodes_ui._window_x + UI_NODE_X(node);
let link_y: i32 = ui_nodes_ui._window_y + UI_NODE_Y(node);
if (link_drag.from_id > -1) {
link_x += ui_nodes_NODE_W(node);
link_y += ui_nodes_OUTPUT_Y(node.outputs.length, link_drag.from_socket);
link_x += UI_NODE_W(node);
link_y += UI_OUTPUT_Y(node.outputs.length, link_drag.from_socket);
}
else {
link_y += ui_nodes_INPUT_Y(ui_nodes_get_canvas(true), node.inputs, link_drag.to_socket) +
ui_nodes_OUTPUTS_H(node.outputs.length) + ui_nodes_BUTTONS_H(node);
UI_OUTPUTS_H(node.outputs.length) + UI_BUTTONS_H(node);
}
if (math_abs(mouse_x - link_x) > 5 || math_abs(mouse_y - link_y) > 5) { // Link length
@@ -286,7 +286,11 @@ function ui_viewnodes_on_canvas_released() {
let selected: ui_node_t = null;
for (let i: i32 = 0; i < canvas.nodes.length; ++i) {
let node: ui_node_t = canvas.nodes[i];
if (ui_input_in_rect(ui_nodes_ui._window_x + ui_nodes_NODE_X(node), ui_nodes_ui._window_y + ui_nodes_NODE_Y(node), ui_nodes_NODE_W(node), ui_nodes_NODE_H(canvas, node))) {
if (ui_input_in_rect(
ui_nodes_ui._window_x + UI_NODE_X(node),
ui_nodes_ui._window_y + UI_NODE_Y(node),
UI_NODE_W(node),
UI_NODE_H(canvas, node))) {
selected = node;
break;
}
@@ -381,7 +385,7 @@ function ui_viewnodes_on_canvas_released() {
let canvas: ui_node_canvas_t = ui_nodes_get_canvas(true);
for (let i: i32 = 0; i < canvas.nodes.length; ++i) {
let node: ui_node_t = canvas.nodes[i];
if (ui_input_in_rect(ui_nodes_ui._window_x + ui_nodes_NODE_X(node), ui_nodes_ui._window_y + ui_nodes_NODE_Y(node), ui_nodes_NODE_W(node), ui_nodes_NODE_H(canvas, node))) {
if (ui_input_in_rect(ui_nodes_ui._window_x + UI_NODE_X(node), ui_nodes_ui._window_y + UI_NODE_Y(node), UI_NODE_W(node), UI_NODE_H(canvas, node))) {
if (nodes.nodes_selected_id.length > 0 && node.id == nodes.nodes_selected_id[0]) {
ui_view2d_hwnd.redraws = 2;
if (time_time() - context_raw.select_time < 0.25) ui_base_show_2d_view(view_2d_type_t.NODE);
@@ -708,11 +712,11 @@ function ui_nodes_node_search(x: i32 = -1, y: i32 = -1, done: ()=>void = null) {
}
function ui_nodes_get_node_x(): i32 {
return math_floor((mouse_x - ui_nodes_wx - ui_nodes_PAN_X()) / ui_nodes_SCALE());
return math_floor((mouse_x - ui_nodes_wx - UI_NODES_PAN_X()) / UI_NODES_SCALE());
}
function ui_nodes_get_node_y(): i32 {
return math_floor((mouse_y - ui_nodes_wy - ui_nodes_PAN_Y()) / ui_nodes_SCALE());
return math_floor((mouse_y - ui_nodes_wy - UI_NODES_PAN_Y()) / UI_NODES_SCALE());
}
function ui_nodes_draw_grid(zoom: f32): iron_gpu_texture_t {
@@ -948,8 +952,8 @@ function ui_nodes_render() {
// Grid
draw_set_color(0xffffffff);
let step: f32 = ui_nodes_grid_cell_w * nodes.zoom;
let x: f32 = math_fmod(ui_nodes_PAN_X(), step) - step;
let y: f32 = math_fmod(ui_nodes_PAN_Y(), step) - step;
let x: f32 = math_fmod(UI_NODES_PAN_X(), step) - step;
let y: f32 = math_fmod(UI_NODES_PAN_Y(), step) - step;
draw_image(ui_nodes_grid, x, y);
// Undo