#define __PICKER_CONFIG__
#include "structs.h"
-const float config_ui_scale = 1.0f;
+// Multiple units need to include config.h now
+
+Runtime_Info runtime =
+{
+ .framerate = 30,
+ .font_path = "/usr/share/fonts/TTF/iosevka-term-regular.ttf",
+ .font_size = 32,
+};
-Runtime_Info runtime;
Window_Layout config_layout = {
// Master window scale and dimensions
.window = (SDL_FRect){
.x = 0.0f,
- .y = 0.0f,
- .w = config_ui_scale*512.0f,
- .h = config_ui_scale*512.0f
+ .y = 0.0f,
+ .w = 512.0f,
+ .h = 512.0f
},
- // satisfying rel.[xy]*2 == .[wh] centers axis in parent container
+// satisfying rel.[xy]*2 == .[wh] centers axis in parent container
.hsl_square.rel = (SDL_FRect){.x = 0.05, .y = 0.05, .w = 0.50, .h = 0.50},
.hue_slider.rel = (SDL_FRect){.x = 0.70, .y = 0.05, .w = 0.08, .h = 0.50},
.final_sample.rel = (SDL_FRect){.x = 0.05, .y = 0.65, .w = 0.20, .h = 0.20},
.info_container.rel = (SDL_FRect){.x = 0.05, .y = 0.65, .w = 0.90, .h = 0.30},
- .info_boxes.rel = (SDL_FRect){.x = 0.25, .y = 0.00, .w = 0.75, .h = 1.00},
- .rgb_info.rel = (SDL_FRect){.x = 0.00, .y = 0.00, .w = 1.00, .h = 0.50},
- .red_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.00, .w = 0.30, .h = 1.00},
- .green_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.40, .w = 0.30, .h = 1.00},
- .blue_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.80, .w = 0.30, .h = 1.00},
- .hsl_info.rel = (SDL_FRect){.x = 0.50, .y = 0.00, .w = 1.00, .h = 0.50},
- .hue_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.00, .w = 0.30, .h = 1.00},
- .sat_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.40, .w = 0.30, .h = 1.00},
- .lum_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.80, .w = 0.30, .h = 1.00}
+ .info_boxes.rel = (SDL_FRect){.x = 0.25, .y = 0.00, .w = 0.75, .h = 1.00},
+ .rgb_info.rel = (SDL_FRect){.x = 0.00, .y = 0.00, .w = 1.00, .h = 0.50},
+ .red_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.00, .w = 0.30, .h = 1.00},
+ .green_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.40, .w = 0.30, .h = 1.00},
+ .blue_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.80, .w = 0.30, .h = 1.00},
+ .hsl_info.rel = (SDL_FRect){.x = 0.50, .y = 0.00, .w = 1.00, .h = 0.50},
+ .hue_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.00, .w = 0.30, .h = 1.00},
+ .sat_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.40, .w = 0.30, .h = 1.00},
+ .lum_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.80, .w = 0.30, .h = 1.00}
};
-// For now we need a full path, maybe OpenFont can do automatic lookup
-const char config_font_path[] = "/usr/share/fonts/TTF/iosevka-term-regular.ttf";
-const int config_font_size = 32;
-const int config_framerate = 30;
-
#endif //__PICKER_CONFIG__
int32_t refresh_layout(Runtime_Info* runtime)
{
NULL_CHECK(runtime);
+
+ int win_w, win_h;
+ // SDL_GetWindowSize(mgr.win, &win_w, &win_h);
+ SDL_GetRendererOutputSize(mgr.rend, &win_w, &win_h);
+ runtime->layout.window.w = win_w;
+ runtime->layout.window.h = win_h;
+
// this would be really cool to turn into some stack-based type of thing
render_container(&runtime->layout.window, &runtime->layout.hsl_square);
render_container(&runtime->layout.window, &runtime->layout.hue_slider);
exit(__LINE__);
}
+ // SDL_WINDOW_RESIZABLE forces terminal swallow and tiling doesn't like it
+ // Figure something out later
mgr.win = SDL_CreateWindow("Color Picker", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, runtime->layout.window.w, runtime->layout.window.h, 0);
if (mgr.win == NULL)
{
SDL_SetRenderDrawBlendMode(mgr.rend, SDL_BLENDMODE_BLEND);
+ TTF_Init();
+ runtime->font = TTF_OpenFont(runtime->font_path, runtime->font_size);
+ assert(runtime->font != NULL);
+
init_text_container(&runtime->layout.red_component, 64);
init_text_container(&runtime->layout.green_component, 64);
init_text_container(&runtime->layout.blue_component, 64);
free_text_container(&runtime->layout.sat_component);
free_text_container(&runtime->layout.lum_component);
+ TTF_CloseFont(runtime->font);
+ TTF_Quit();
SDL_DestroyRenderer(mgr.rend);
SDL_DestroyWindow(mgr.win);
SDL_Quit();