augroup END
" start up a faux-IDE view
-command! Ide call s:ide()
-function! s:ide()
- execute("sp")
- execute("\<C-w\>J")
- execute("resize 10")
- execute("term")
- execute("NERDTreeToggle")
-endfunction
+execute("sp")
+execute("resize 10")
+execute("term")
+execute("NERDTreeToggle")
let $src=prj_base.'/source'
let $bin=prj_base.'/bin'
// 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},
+ .final_sample.rel = (SDL_FRect){.x = 0.05, .y = 0.60, .w = 0.20, .h = 0.20},
+ .info_container.rel = (SDL_FRect){.x = 0.05, .y = 0.60, .w = 0.90, .h = 0.40},
.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},
.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}
+ .lum_component.body.rel = (SDL_FRect){.x = 0.00, .y = 0.80, .w = 0.30, .h = 1.00},
+ .palette.rel = (SDL_FRect){.x = 0.00, .y = 0.60, .w = 1.00, .h = 0.30}
};
#endif //__PICKER_CONFIG__
SDL_Color blue = {0, 0, 255, 255};
SDL_Color black = {0, 0, 0, 255};
SDL_Color white = {255, 255, 255, 255};
+HSL_Color hsl_white = {0, 0, 100};
SDL_Color magenta = {255, 0, 255, 255};
sdl_group mgr;
render_container(&runtime->layout.window, &runtime->layout.info_container);
render_container(&runtime->layout.window, &runtime->layout.final_sample);
render_container(&runtime->layout.info_container.real, &runtime->layout.info_boxes);
+ render_container(&runtime->layout.info_container.real, &runtime->layout.palette);
render_container(&runtime->layout.info_boxes.real, &runtime->layout.rgb_info);
render_container(&runtime->layout.rgb_info.real, &runtime->layout.red_component.body);
render_container(&runtime->layout.rgb_info.real, &runtime->layout.green_component.body);
init_text_container(&runtime->layout.sat_component, 64);
init_text_container(&runtime->layout.lum_component, 64);
+ for (int p = 0; p < PALETTE_SIZE; p++)
+ {
+ runtime->layout.palette_color[p] = hsl_white;
+ }
+
refresh_layout(runtime);
return 0;
return 0;
}
-// Rename this eventually
-// It's actually HSL
+int32_t render_palette(Runtime_Info* runtime, SDL_FRect* container)
+{
+ for (int p = 0; p < PALETTE_SIZE; p++)
+ {
+ SDL_Color item_color = hsl_to_rgb(runtime->layout.palette_color[p]);
+ SDL_FRect item = {
+ .x = container->x + (p * ((float)container->w / (float)PALETTE_SIZE)), .y = container->y,
+ .w = ((float)container->w / PALETTE_SIZE) * 0.90, .h = container->h};
+
+ SDL_SetRenderDrawColor(mgr.rend, unroll_sdl_color(item_color));
+ if (p == runtime->active_palette)
+ {
+ SDL_SetRenderDrawColor(mgr.rend, unroll_sdl_color(item_color));
+ item.h *= 1.2;
+ }
+ SDL_RenderFillRectF(mgr.rend, &item);
+ }
+
+ return 0;
+}
+
int32_t render_hsl_square(Runtime_Info* runtime, SDL_FRect* container)
{
NULL_CHECK(runtime);
render_vertical_hue_spectrum(runtime, &layout->hue_slider.real);
render_hsl_square(runtime, &layout->hsl_square.real);
render_info_boxes(runtime, &layout->info_boxes.real);
+ render_palette(runtime, &layout->palette.real);
return 0;
}
}
if (mgr.event.type == SDL_KEYUP)
{
+ int p = runtime->active_palette;
switch(mgr.event.key.keysym.sym)
{
case SDLK_q:
case SDLK_LSHIFT:
move_speed = 1;
break;
+
+ case SDLK_0:
+ case SDLK_1:
+ case SDLK_2:
+ case SDLK_3:
+ case SDLK_4:
+ case SDLK_5:
+ case SDLK_6:
+ case SDLK_7:
+ case SDLK_8:
+ case SDLK_9:
+ {
+ int new_palette = mgr.event.key.keysym.sym - 48 - 1;
+ if (new_palette < 0)
+ new_palette = PALETTE_SIZE-1;
+
+ if (new_palette <= PALETTE_SIZE)
+ {
+ runtime->active_palette = new_palette;
+ runtime->active_hsl = runtime->layout.palette_color[new_palette];
+ runtime->active_rgb = hsl_to_rgb(runtime->active_hsl);
+ }
+ } break;
+
+ case SDLK_RETURN:
+ case SDLK_KP_ENTER:
+ runtime->layout.palette_color[p] = runtime->active_hsl;
+ break;
}
+
}
}
#define Relative_Rect SDL_FRect
#include <stdint.h>
+#define PALETTE_SIZE 10
+
// A placeable rect, with relative components to its parent,
// and its finalized real placement rectangle
typedef struct
{
// Tabbing these to visually indicate layout
SDL_FRect window;
- Layout_Rect hsl_square; // big clicky draggy square
- Layout_Rect hue_slider; // HSV slider bar
- Layout_Rect info_container;
- Layout_Rect final_sample; // small square showing full selected color
- Layout_Rect info_boxes;
- Layout_Rect rgb_info;
- Text_Container red_component;
- Text_Container green_component;
- Text_Container blue_component;
- Layout_Rect hsl_info;
- Text_Container hue_component;
- Text_Container sat_component;
- Text_Container lum_component;
-
+ Layout_Rect hsl_square; // big clicky draggy square
+ Layout_Rect hue_slider; // HSV slider bar
+ Layout_Rect info_container;
+ Layout_Rect palette;
+ Layout_Rect final_sample; // small square showing full selected color
+ Layout_Rect info_boxes;
+ Layout_Rect rgb_info;
+ Text_Container red_component;
+ Text_Container green_component;
+ Text_Container blue_component;
+ Layout_Rect hsl_info;
+ Text_Container hue_component;
+ Text_Container sat_component;
+ Text_Container lum_component;
+
+ Layout_Rect palette_item[PALETTE_SIZE];
+ HSL_Color palette_color[PALETTE_SIZE];
} Window_Layout;
typedef struct
SDL_Point mouse_click_pos;
int mouse_click;
+ int active_palette;
+
} Runtime_Info;
#endif // STRUCTS__
## To Do
-- Mode-based keybinds
- UI library
> Move UI stuff into a standalone library some day, because it's kinda cool
+- Color export
+ > Send active color somewhere like the clipboard. X usually uses xclip, so it'll need pipes.
## Doing
## Done
-- Color export
- Config header
- Cleanup
* [x] Text rendering
* [x] Layout rendering
* [x] Old gameframe cruft needs to go
+- Mouse support
+ > Add some simple mouse support for hue spectrum and S/L box
+- Palette
+ > Add a palette for saving and recalling colors