From: randy Date: Sat, 23 Sep 2023 16:27:15 +0000 (-0500) Subject: Removed some silly old abstraction macros X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=f40e56078c20b6e733de6c075443050f49e3d3e6;p=picker Removed some silly old abstraction macros --- diff --git a/project.vim b/project.vim index 9960a5c..8ec80d4 100644 --- a/project.vim +++ b/project.vim @@ -1,5 +1,5 @@ let prj_base = expand('%:p:h') -let build = prj_base . '/bin/picker' +let build = './bin/picker' let run_build = "!" . build . " -nop" nmap \m :wa \| :make! picker \| execute run_build @@ -24,5 +24,4 @@ function! s:ide() endfunction let $src=prj_base.'/source' -let $sdl=$src.'/source/sdl' let $bin=prj_base.'/bin' diff --git a/source/main.c b/source/main.c index ecb2093..b63e25e 100644 --- a/source/main.c +++ b/source/main.c @@ -17,22 +17,22 @@ int init() signal(SIGTERM, killterm_handler); float scale = 1.0f; - runtime.layout.window = (Rect){.x = 0.0f, .y = 0.0f, .w = scale*512.0f, .h = scale*512.0f}; + runtime.layout.window = (SDL_FRect){.x = 0.0f, .y = 0.0f, .w = scale*512.0f, .h = scale*512.0f}; // satisfying rel.[xy]*2 == .[wh] centers axis in parent container - runtime.layout.rgb_square.rel = (Rect){.x = 0.05, .y = 0.05, .w = 0.5, .h = 0.5}; - runtime.layout.hue_slider.rel = (Rect){.x = 0.70, .y = 0.05, .w = .08, .h = 0.5}; - runtime.layout.final_sample.rel = (Rect){.x = 0.05, .y = .65, .w = 0.20, .h = 0.20}; - runtime.layout.info_container.rel = (Rect){.x = 0.05, .y = .65, .w = .9, .h = .30}; - runtime.layout.info_boxes.rel = (Rect){.x = .25, .y = 0.00, .w = 0.75, .h = 1.00}; - runtime.layout.rgb_info.rel = (Rect){.x = 0.00, .y = 0.00, .w = 1.00, .h = 0.50}; - runtime.layout.red.rel = (Rect){.x = 0.00, .y = 0.00, .w = 0.30, .h = 1.00}; - runtime.layout.green.rel = (Rect){.x = 0.35, .y = 0.00, .w = 0.30, .h = 1.00}; - runtime.layout.blue.rel = (Rect){.x = 0.70, .y = 0.00, .w = 0.30, .h = 1.00}; - runtime.layout.hsl_info.rel = (Rect){.x = 0.00, .y = 0.50, .w = 1.00, .h = 0.50}; - runtime.layout.hue.rel = (Rect){.x = 0.00, .y = 0.00, .w = 0.30, .h = 1.00}; - runtime.layout.saturation.rel = (Rect){.x = 0.35, .y = 0.00, .w = 0.30, .h = 1.00}; - runtime.layout.luminence.rel = (Rect){.x = 0.70, .y = 0.00, .w = 0.30, .h = 1.00}; + runtime.layout.rgb_square.rel = (SDL_FRect){.x = 0.05, .y = 0.05, .w = 0.5, .h = 0.5}; + runtime.layout.hue_slider.rel = (SDL_FRect){.x = 0.70, .y = 0.05, .w = .08, .h = 0.5}; + runtime.layout.final_sample.rel = (SDL_FRect){.x = 0.05, .y = .65, .w = 0.20, .h = 0.20}; + runtime.layout.info_container.rel = (SDL_FRect){.x = 0.05, .y = .65, .w = .9, .h = .30}; + runtime.layout.info_boxes.rel = (SDL_FRect){.x = .25, .y = 0.00, .w = 0.75, .h = 1.00}; + runtime.layout.rgb_info.rel = (SDL_FRect){.x = 0.00, .y = 0.00, .w = 1.00, .h = 0.50}; + runtime.layout.red.rel = (SDL_FRect){.x = 0.00, .y = 0.00, .w = 0.30, .h = 1.00}; + runtime.layout.green.rel = (SDL_FRect){.x = 0.35, .y = 0.00, .w = 0.30, .h = 1.00}; + runtime.layout.blue.rel = (SDL_FRect){.x = 0.70, .y = 0.00, .w = 0.30, .h = 1.00}; + runtime.layout.hsl_info.rel = (SDL_FRect){.x = 0.00, .y = 0.50, .w = 1.00, .h = 0.50}; + runtime.layout.hue.rel = (SDL_FRect){.x = 0.00, .y = 0.00, .w = 0.30, .h = 1.00}; + runtime.layout.saturation.rel = (SDL_FRect){.x = 0.35, .y = 0.00, .w = 0.30, .h = 1.00}; + runtime.layout.luminence.rel = (SDL_FRect){.x = 0.70, .y = 0.00, .w = 0.30, .h = 1.00}; runtime.active_hsl = (HSL_Color){.h = 0, .s = 100, .l = 50}; runtime.active_rgb = hsl_to_rgb(runtime.active_hsl); diff --git a/source/rendering.c b/source/rendering.c index ac75174..a5dc989 100644 --- a/source/rendering.c +++ b/source/rendering.c @@ -13,14 +13,11 @@ SDL_Color white = {255, 255, 255, 255}; SDL_Color magenta = {255, 0, 255, 255}; sdl_group mgr; -const int keypress_delta = 4; int32_t init_renderer(runtime_info* runtime) { - //load_config(argv[1], gs); - SDL_SetMainReady(); - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER)) + if (SDL_Init(SDL_INIT_VIDEO)) { fprintf(stderr, "SDL initialization failed\n"); exit(__LINE__); @@ -208,7 +205,7 @@ int32_t render_vertical_hue_spectrum(runtime_info* runtime, SDL_FRect* container int32_t render_container(runtime_info* runtime, SDL_FRect* parent, Layout_Rect* child, SDL_Color color) { SDL_SetRenderDrawColor(mgr.rend, unroll_sdl_color(color)); - child->real = fr_marruntimen_adjust(*parent, child->rel); + child->real = fr_margin_adjust(*parent, child->rel); return 0; } @@ -307,7 +304,7 @@ SDL_FRect fr_mult(const SDL_FRect left, const SDL_FRect right) } // Math out placement for a relative rect onto a concrete parent -SDL_FRect fr_marruntimen_adjust(const SDL_FRect parent, const Relative_Rect child) +SDL_FRect fr_margin_adjust(const SDL_FRect parent, const Relative_Rect child) { return (SDL_FRect){ diff --git a/source/rendering.h b/source/rendering.h index 8394993..64ebe1c 100644 --- a/source/rendering.h +++ b/source/rendering.h @@ -21,7 +21,7 @@ int32_t render_container(runtime_info* runtime, SDL_FRect* parent, Layout_Rect* SDL_FRect fr_add(const SDL_FRect left, const SDL_FRect right); SDL_FRect fr_subtract(const SDL_FRect left, const SDL_FRect right); SDL_FRect fr_mult(const SDL_FRect left, const SDL_FRect right); -SDL_FRect fr_marruntimen_adjust(const SDL_FRect parent, const Relative_Rect child); +SDL_FRect fr_margin_adjust(const SDL_FRect parent, const Relative_Rect child); SDL_Color hsl_to_rgb (const HSL_Color hsl); SDL_Color wikipedia_hsl_to_rgb (const HSL_Color hsl); #endif // SDL_Utils__ diff --git a/source/structs.h b/source/structs.h index dc476cf..ab712b2 100644 --- a/source/structs.h +++ b/source/structs.h @@ -3,11 +3,7 @@ #include #include -#define Point SDL_Point -#define FPoint SDL_FPoint -#define Rect SDL_FRect #define Relative_Rect SDL_FRect -#define Color SDL_Color #include @@ -16,7 +12,7 @@ typedef struct { Relative_Rect rel; - Rect real; + SDL_FRect real; // bool // center in parent axis (even spacing on both sides?) @@ -40,7 +36,7 @@ typedef struct typedef struct { - FPoint position; + SDL_FPoint position; uint32_t radius; } Circle; @@ -48,7 +44,7 @@ typedef struct typedef struct { // Tabbing these to visually indicate layout - Rect window; + SDL_FRect window; Layout_Rect rgb_square; // big clicky draggy square Layout_Rect hue_slider; // HSV slider bar Layout_Rect info_container; @@ -79,7 +75,7 @@ typedef struct typedef struct { - Color active_rgb; + SDL_Color active_rgb; HSL_Color active_hsl; Window_Layout layout;