Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Mar 2, 2025
1 parent 32bc073 commit c8a667b
Show file tree
Hide file tree
Showing 59 changed files with 371 additions and 509 deletions.
16 changes: 8 additions & 8 deletions armorforge/sources/tab_scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object:

// Highlight every other line
if (tab_scene_line_counter % 2 == 0) {
g2_set_color(ui.ops.theme.SEPARATOR_COL);
draw_set_color(ui.ops.theme.SEPARATOR_COL);
g2_fill_rect(0, ui._y, ui._window_w, ui_ELEMENT_H(ui));
g2_set_color(0xffffffff);
draw_set_color(0xffffffff);
}

// Highlight selected line
if (current_object == context_raw.selected_object) {
g2_set_color(0xff205d9c);
draw_set_color(0xff205d9c);
g2_fill_rect(0, ui._y, ui._window_w, ui_ELEMENT_H(ui));
g2_set_color(0xffffffff);
draw_set_color(0xffffffff);
}

if (current_object.children.length > 0) {
Expand All @@ -82,9 +82,9 @@ function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object:
ui._x += 18; // Sign offset

// Draw line that shows parent relations
g2_set_color(ui.ops.theme.BUTTON_COL);
draw_set_color(ui.ops.theme.BUTTON_COL);
g2_draw_line(ui._x - 10, ui._y + ui_ELEMENT_H(ui) / 2, ui._x, ui._y + ui_ELEMENT_H(ui) / 2);
g2_set_color(0xffffffff);
draw_set_color(0xffffffff);

ui_text(current_object.name);
ui._x -= 18;
Expand Down Expand Up @@ -121,9 +121,9 @@ function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object:
}

// Draw line that shows parent relations
g2_set_color(ui.ops.theme.BUTTON_COL);
draw_set_color(ui.ops.theme.BUTTON_COL);
g2_draw_line(ui._x + 14, current_y, ui._x + 14, ui._y - ui_ELEMENT_H(ui) / 2);
g2_set_color(0xffffffff);
draw_set_color(0xffffffff);
}
}

Expand Down
2 changes: 1 addition & 1 deletion armorpaint/sources/layers_ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t
if (l1masks.length > 1) {
layers_make_temp_mask_img();
g2_begin(pipes_temp_mask_image);
g2_clear(0x00000000);
g4_clear(0x00000000);
g2_end();
let l1: slot_layer_t = { texpaint: pipes_temp_mask_image };
for (let i: i32 = 0; i < l1masks.length; ++i) {
Expand Down
6 changes: 3 additions & 3 deletions armorpaint/sources/ui_header_ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ function ui_header_draw_tool_properties(ui: ui_t) {
let progress: f32 = render_path_raytrace_bake_current_sample / context_raw.bake_samples;
if (progress > 1.0) progress = 1.0;
// Progress bar
g2_set_color(ui.ops.theme.SEPARATOR_COL);
draw_set_color(ui.ops.theme.SEPARATOR_COL);
ui_draw_rect(true, ui._x + 1, ui._y, ui._w - 2, ui_ELEMENT_H(ui));
g2_set_color(ui.ops.theme.HIGHLIGHT_COL);
draw_set_color(ui.ops.theme.HIGHLIGHT_COL);
ui_draw_rect(true, ui._x + 1, ui._y, (ui._w - 2) * progress, ui_ELEMENT_H(ui));
g2_set_color(0xffffffff);
draw_set_color(0xffffffff);
ui_text(tr("Samples") + ": " + render_path_raytrace_bake_current_sample);
ui_text(tr("Rays/pixel") + ": " + render_path_raytrace_bake_rays_pix);
ui_text(tr("Rays/second") + ": " + render_path_raytrace_bake_rays_sec);
Expand Down
14 changes: 3 additions & 11 deletions base/sources/backends/android_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ void android_main(struct android_app *application) {
(*activity->vm)->DetachCurrentThread(activity->vm);
}

void kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame) {
void kinc_init(const char *name, int width, int height, struct kinc_window_options *win) {
kinc_mutex_init(&unicode_mutex);

kinc_window_options_t default_win;
Expand All @@ -1213,14 +1213,8 @@ void kinc_init(const char *name, int width, int height, struct kinc_window_optio
win->width = width;
win->height = height;

kinc_framebuffer_options_t default_frame;
if (frame == NULL) {
kinc_framebuffer_options_set_defaults(&default_frame);
frame = &default_frame;
}

kinc_g5_internal_init();
kinc_g4_internal_init_window(frame->depth_bits, true);
kinc_g4_internal_init_window(win->depth_bits, true);

kinc_internal_gamepad_trigger_connect(0);
}
Expand Down Expand Up @@ -1350,9 +1344,7 @@ void kinc_window_hide() {}

void kinc_window_set_title(const char *title) {}

void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {

}
void kinc_window_create(kinc_window_options_t *win) {}

void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {
resizeCallback = callback;
Expand Down
13 changes: 3 additions & 10 deletions base/sources/backends/ios_system.m
Original file line number Diff line number Diff line change
Expand Up @@ -614,19 +614,14 @@ void KoreUpdateKeyboard(void) {

void kinc_internal_shutdown(void) {}

void kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame) {
void kinc_init(const char *name, int width, int height, struct kinc_window_options *win) {
kinc_window_options_t defaultWin;
if (win == NULL) {
kinc_window_options_set_defaults(&defaultWin);
win = &defaultWin;
}
kinc_framebuffer_options_t defaultFrame;
if (frame == NULL) {
kinc_framebuffer_options_set_defaults(&defaultFrame);
frame = &defaultFrame;
}
kinc_g5_internal_init();
kinc_g4_internal_init_window(frame->depth_bits, true);
kinc_g4_internal_init_window(win->depth_bits, true);
}

void endGL(void);
Expand Down Expand Up @@ -732,9 +727,7 @@ void kinc_window_hide() {}

void kinc_window_set_title(const char *title) {}

void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {

}
void kinc_window_create(kinc_window_options_t *win) {}

void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {
resizeCallback = callback;
Expand Down
13 changes: 4 additions & 9 deletions base/sources/backends/linux_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void kinc_window_set_title(const char *_title) {
xlib.XFlush(x11_ctx.display);
}

void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
void kinc_window_create(kinc_window_options_t *win) {
struct kinc_x11_window *window = &x11_ctx.windows[0];
window->width = win->width;
window->height = win->height;
Expand Down Expand Up @@ -424,7 +424,7 @@ void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *
xlib.XSelectExtensionEvent(x11_ctx.display, window->window, &x11_ctx.eraser.motionClass, 1);
}

kinc_g4_internal_init_window(frame->depth_bits, frame->vertical_sync);
kinc_g4_internal_init_window(win->depth_bits, win->vsync);
}

static struct {
Expand Down Expand Up @@ -1434,7 +1434,7 @@ kinc_ticks_t kinc_timestamp(void) {
return (kinc_ticks_t)now.tv_sec * 1000000 + (kinc_ticks_t)now.tv_usec;
}

void kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) {
kinc_linux_initHIDGamepads();

gettimeofday(&start, NULL);
Expand All @@ -1450,18 +1450,13 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w
kinc_window_options_set_defaults(&defaultWin);
win = &defaultWin;
}
kinc_framebuffer_options_t defaultFrame;
if (frame == NULL) {
kinc_framebuffer_options_set_defaults(&defaultFrame);
frame = &defaultFrame;
}
win->width = width;
win->height = height;
if (win->title == NULL) {
win->title = name;
}

kinc_window_create(win, frame);
kinc_window_create(win);
}

void kinc_internal_shutdown() {
Expand Down
16 changes: 5 additions & 11 deletions base/sources/backends/macos_system.m
Original file line number Diff line number Diff line change
Expand Up @@ -1139,10 +1139,10 @@ static void createWindow(kinc_window_options_t *options) {
int width = options->width / [[NSScreen mainScreen] backingScaleFactor];
int height = options->height / [[NSScreen mainScreen] backingScaleFactor];
int styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable;
if ((options->window_features & KINC_WINDOW_FEATURE_RESIZEABLE) || (options->window_features & KINC_WINDOW_FEATURE_MAXIMIZABLE)) {
if ((options->features & KINC_WINDOW_FEATURE_RESIZEABLE) || (options->features & KINC_WINDOW_FEATURE_MAXIMIZABLE)) {
styleMask |= NSWindowStyleMaskResizable;
}
if (options->window_features & KINC_WINDOW_FEATURE_MINIMIZABLE) {
if (options->features & KINC_WINDOW_FEATURE_MINIMIZABLE) {
styleMask |= NSWindowStyleMaskMiniaturizable;
}

Expand Down Expand Up @@ -1205,7 +1205,7 @@ static void addMenubar(void) {
[NSApp setMainMenu:menubar];
}

void kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) {
@autoreleasepool {
myapp = [KincApplication sharedApplication];
[myapp finishLaunching];
Expand All @@ -1223,12 +1223,6 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w
win = &defaultWindowOptions;
}

kinc_framebuffer_options_t defaultFramebufferOptions;
if (frame == NULL) {
kinc_framebuffer_options_set_defaults(&defaultFramebufferOptions);
frame = &defaultFramebufferOptions;
}

win->width = width;
win->height = height;
if (win->title == NULL) {
Expand All @@ -1237,7 +1231,7 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w

createWindow(win);
kinc_g5_internal_init();
kinc_g4_internal_init_window(frame->depth_bits, true);
kinc_g4_internal_init_window(win->depth_bits, true);
}

int kinc_window_width() {
Expand Down Expand Up @@ -1374,7 +1368,7 @@ void kinc_window_hide() {}

void kinc_window_set_title(const char *title) {}

void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
void kinc_window_create(kinc_window_options_t *win) {
}

void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {
Expand Down
13 changes: 3 additions & 10 deletions base/sources/backends/wasm_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,20 @@ __attribute__((import_module("imports"), import_name("js_time"))) int js_time();
extern int kinc_internal_window_width;
extern int kinc_internal_window_height;

void kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) {
kinc_window_options_t defaultWin;
if (win == NULL) {
kinc_window_options_set_defaults(&defaultWin);
win = &defaultWin;
}
kinc_framebuffer_options_t defaultFrame;
if (frame == NULL) {
kinc_framebuffer_options_set_defaults(&defaultFrame);
frame = &defaultFrame;
}
win->width = width;
win->height = height;

kinc_internal_window_width = width;
kinc_internal_window_height = height;

kinc_g5_internal_init();
kinc_g4_internal_init_window(frame->depth_bits, true);
kinc_g4_internal_init_window(win->depth_bits, true);
}

bool kinc_internal_handle_messages() {
Expand Down Expand Up @@ -211,9 +206,7 @@ void kinc_window_hide() {}
// TODO: change browser title.
void kinc_window_set_title(const char *title) {}

void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {

}
void kinc_window_create(kinc_window_options_t *win) {}

void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {}

Expand Down
16 changes: 5 additions & 11 deletions base/sources/backends/windows_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ static void init_crash_handler() {
}
}

void kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) {
init_crash_handler();

// Pen functions are only in Windows 8 and later, so load them dynamically
Expand Down Expand Up @@ -2082,33 +2082,27 @@ void kinc_window_set_title(const char *title) {
SetWindowTextW(windows[0].handle, buffer);
}

void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
void kinc_window_create(kinc_window_options_t *win) {
kinc_window_options_t defaultWin;
kinc_framebuffer_options_t defaultFrame;

if (win == NULL) {
kinc_window_options_set_defaults(&defaultWin);
win = &defaultWin;
}

if (frame == NULL) {
kinc_framebuffer_options_set_defaults(&defaultFrame);
frame = &defaultFrame;
}

if (win->title == NULL) {
win->title = "";
}

wchar_t wbuffer[1024];
MultiByteToWideChar(CP_UTF8, 0, win->title, -1, wbuffer, 1024);

createWindow(wbuffer, win->x, win->y, win->width, win->height, frame->color_bits, frame->frequency, win->window_features, win->mode,
createWindow(wbuffer, win->x, win->y, win->width, win->height, win->color_bits, win->frequency, win->features, win->mode,
win->display_index);

bool vsync = frame->vertical_sync;
bool vsync = win->vsync;

kinc_g4_internal_init_window(frame->depth_bits, vsync);
kinc_g4_internal_init_window(win->depth_bits, vsync);

if (win->visible) {
kinc_window_show();
Expand Down
28 changes: 8 additions & 20 deletions base/sources/iron.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,30 +784,18 @@ i32 color_set_ab(i32 c, u8 i) {
return (i << 24) | (color_get_rb(c) << 16) | (color_get_gb(c) << 8) | color_get_bb(c);
}

void iron_init(string_t *title, i32 width, i32 height, bool vsync, i32 window_mode, i32 window_features, i32 x, i32 y, i32 frequency, bool use_depth) {
kinc_window_options_t win;
kinc_framebuffer_options_t frame;
win.title = title;
win.width = width;
win.height = height;
frame.vertical_sync = vsync;
win.mode = (kinc_window_mode_t)window_mode;
win.window_features = window_features;
win.x = x;
win.y = y;
frame.frequency = frequency;

win.display_index = -1;
win.visible = enable_window;
frame.color_bits = 32;
frame.depth_bits = use_depth ? 24 : 0;
kinc_init(title, win.width, win.height, &win, &frame);
void iron_init(kinc_window_options_t *ops) {
ops->display_index = -1;
ops->visible = enable_window;
ops->color_bits = 32;
ops->depth_bits = ops->use_depth ? 24 : 0;
kinc_init(ops->title, ops->width, ops->height, ops);
kinc_random_init((int)(kinc_time() * 1000));

#ifdef KINC_WINDOWS
// Maximized window has x < -1, prevent window centering done by kinc
if (win.x < -1 && win.y < -1) {
kinc_window_move(win.x, win.y);
if (ops->x < -1 && ops->y < -1) {
kinc_window_move(ops->x, ops->y);
}
#endif

Expand Down
16 changes: 2 additions & 14 deletions base/sources/iron_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ void draw_font_default_glyphs() {
draw_font_glyph_blocks[1] = 126;
}

void _draw_font_init(draw_font_t *font, void *blob, int font_index) {
void draw_font_init(draw_font_t *font, void *blob, int font_index) {
if (draw_font_glyphs == NULL) {
draw_font_default_glyphs();
}
Expand All @@ -961,13 +961,7 @@ void _draw_font_init(draw_font_t *font, void *blob, int font_index) {
}
}

draw_font_t *draw_font_init(buffer_t *blob, int font_index) {
draw_font_t *font = (draw_font_t *)malloc(sizeof(draw_font_t));
_draw_font_init(font, blob->buffer, font_index);
return font;
}

void _draw_font_13(draw_font_t *font, void *blob) {
void draw_font_13(draw_font_t *font, void *blob) {
if (draw_font_glyphs == NULL) {
draw_font_default_glyphs();
}
Expand Down Expand Up @@ -1004,12 +998,6 @@ void _draw_font_13(draw_font_t *font, void *blob) {
img->chars = baked;
}

draw_font_t *draw_font_13(buffer_t *blob) {
draw_font_t *font = (draw_font_t *)malloc(sizeof(draw_font_t));
_draw_font_13(font, blob->buffer);
return font;
}

bool draw_font_has_glyph(int glyph) {
for (int i = 0; i < draw_font_num_glyphs; ++i) {
if (draw_font_glyphs[i] == glyph) {
Expand Down
Loading

0 comments on commit c8a667b

Please sign in to comment.