Theme Preview Block UI Type
parent
9e3e7519d0
commit
9fac6cd801
|
@ -684,7 +684,6 @@ that will be displayed as a drop down bar durring an interactive command.) */
|
|||
STRUCT Query_Bar{
|
||||
/* DOC(This specifies the prompt portion of the drop down bar.) */
|
||||
String prompt;
|
||||
|
||||
/* DOC(This specifies the main string portion of the drop down bar.) */
|
||||
String string;
|
||||
};
|
||||
|
@ -696,8 +695,9 @@ STRUCT Event_Message{
|
|||
};
|
||||
|
||||
ENUM(int16_t, UI_Item_Type){
|
||||
UIType_Option,
|
||||
UIType_TextField,
|
||||
UIType_Option = 0,
|
||||
UIType_TextField = 1,
|
||||
UIType_ThemePreview = 2,
|
||||
};
|
||||
|
||||
ENUM(int8_t, UI_Activation_Level){
|
||||
|
@ -718,10 +718,18 @@ STRUCT UI_Item{
|
|||
UI_Coordinate_System coordinates;
|
||||
// 32-bits of padding to fill here
|
||||
union{
|
||||
String query;
|
||||
String status;
|
||||
struct{
|
||||
String string;
|
||||
String status;
|
||||
} option;
|
||||
struct{
|
||||
String query;
|
||||
String string;
|
||||
} text_field;
|
||||
struct{
|
||||
int32_t theme_index;
|
||||
} theme_preview;
|
||||
};
|
||||
String string;
|
||||
void *user_data;
|
||||
i32_Rect rectangle;
|
||||
};
|
||||
|
|
|
@ -269,8 +269,8 @@ lister_update_ui(Application_Links *app, Partition *scratch, View_Summary *view,
|
|||
item.type = UIType_Option;
|
||||
item.activation_level = UIActivation_None;
|
||||
item.coordinates = UICoordinates_Scrolled;
|
||||
item.string = node->string;
|
||||
item.status = node->status;
|
||||
item.option.string = node->string;
|
||||
item.option.status = node->status;
|
||||
item.user_data = node->user_data;
|
||||
item.rectangle = item_rect;
|
||||
|
||||
|
@ -327,8 +327,8 @@ lister_update_ui(Application_Links *app, Partition *scratch, View_Summary *view,
|
|||
item.type = UIType_TextField;
|
||||
item.activation_level = UIActivation_Active;
|
||||
item.coordinates = UICoordinates_ViewRelative;
|
||||
item.query = state->lister.query;
|
||||
item.string = state->lister.text_field;
|
||||
item.text_field.query = state->lister.query;
|
||||
item.text_field.string = state->lister.text_field;
|
||||
item.user_data = 0;
|
||||
item.rectangle = item_rect;
|
||||
ui_list_add_item(scratch, &list, item);
|
||||
|
|
|
@ -2281,8 +2281,19 @@ View_Set_UI(Application_Links *app, View_Summary *view, UI_Control *control){
|
|||
for (UI_Item *item = control->items, *one_past_last = control->items + control->count;
|
||||
item < one_past_last;
|
||||
item += 1){
|
||||
string_size += item->query.size;
|
||||
string_size += item->string.size;
|
||||
switch (item->type){
|
||||
case UIType_Option:
|
||||
{
|
||||
string_size += item->option.string.size;
|
||||
string_size += item->option.status.size;
|
||||
}break;
|
||||
|
||||
case UIType_TextField:
|
||||
{
|
||||
string_size += item->text_field.query.size;
|
||||
string_size += item->text_field.string.size;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
i32 all_items_size = sizeof(UI_Item)*control->count;
|
||||
|
@ -2297,9 +2308,20 @@ View_Set_UI(Application_Links *app, View_Summary *view, UI_Control *control){
|
|||
item < one_past_last;
|
||||
item += 1){
|
||||
String *fixup[2];
|
||||
fixup[0] = &item->query;
|
||||
fixup[1] = &item->string;
|
||||
for (i32 i = 0; i < ArrayCount(fixup); i += 1){
|
||||
i32 fixup_count = 0;
|
||||
switch (item->type){
|
||||
case UIType_Option:
|
||||
{
|
||||
fixup[0] = &item->option.string;
|
||||
fixup[1] = &item->option.status;
|
||||
}break;
|
||||
case UIType_TextField:
|
||||
{
|
||||
fixup[0] = &item->text_field.query;
|
||||
fixup[1] = &item->text_field.string;
|
||||
}break;
|
||||
}
|
||||
for (i32 i = 0; i < fixup_count; i += 1){
|
||||
String old = *fixup[i];
|
||||
char *new_str = push_array(&string_alloc, char, old.size);
|
||||
fixup[i]->str = new_str;
|
||||
|
|
14
4ed_math.h
14
4ed_math.h
|
@ -598,6 +598,16 @@ i32R(int32_t l, int32_t t, int32_t r, int32_t b){
|
|||
return(rect);
|
||||
}
|
||||
|
||||
inline i32_Rect
|
||||
i32R(f32_Rect r){
|
||||
i32_Rect rect;
|
||||
rect.x0 = (int32_t)r.x0;
|
||||
rect.y0 = (int32_t)r.y0;
|
||||
rect.x1 = (int32_t)r.x1;
|
||||
rect.y1 = (int32_t)r.y1;
|
||||
return(rect);
|
||||
}
|
||||
|
||||
inline f32_Rect
|
||||
f32R(float l, float t, float r, float b){
|
||||
f32_Rect rect;
|
||||
|
@ -624,12 +634,12 @@ rect_equal(i32_Rect r1, i32_Rect r2){
|
|||
|
||||
inline int32_t
|
||||
hit_check(int32_t x, int32_t y, int32_t x0, int32_t y0, int32_t x1, int32_t y1){
|
||||
return (x >= x0 && x < x1 && y >= y0 && y < y1);
|
||||
return(x >= x0 && x < x1 && y >= y0 && y < y1);
|
||||
}
|
||||
|
||||
inline int32_t
|
||||
hit_check(int32_t x, int32_t y, i32_Rect rect){
|
||||
return (hit_check(x, y, rect.x0, rect.y0, rect.x1, rect.y1));
|
||||
return(hit_check(x, y, rect.x0, rect.y0, rect.x1, rect.y1));
|
||||
}
|
||||
|
||||
inline i32_Rect
|
||||
|
|
|
@ -19,7 +19,7 @@ struct Style_Font{
|
|||
};
|
||||
|
||||
struct Style{
|
||||
char name_[24];
|
||||
char name_[32];
|
||||
String name;
|
||||
Style_Main_Data main;
|
||||
};
|
||||
|
|
|
@ -241,6 +241,7 @@ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Sc
|
|||
i32 line_height = view->transient.line_height;
|
||||
Style *style = &models->styles.styles[0];
|
||||
Face_ID font_id = file->settings.font_id;
|
||||
Font_Pointers font = system->font.get_pointers_by_id(font_id);
|
||||
|
||||
if (!view->transient.hide_file_bar){
|
||||
i32_Rect top_bar_rect = {0};
|
||||
|
@ -318,8 +319,8 @@ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Sc
|
|||
draw_margin(target, item_rect, inner, margin_color);
|
||||
i32 x = (i32)inner.x0 + 3;
|
||||
i32 y = (i32)inner.y0 + line_height/2 - 1;
|
||||
x = ceil32(draw_string(system, target, font_id, item->string, x, y, text_color));
|
||||
draw_string(system, target, font_id, item->status, x, y, pop_color);
|
||||
x = ceil32(draw_string(system, target, font_id, item->option.string, x, y, text_color));
|
||||
draw_string(system, target, font_id, item->option.status, x, y, pop_color);
|
||||
}break;
|
||||
|
||||
case UIType_TextField:
|
||||
|
@ -330,8 +331,47 @@ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Sc
|
|||
draw_rectangle(target, item_rect, back_color);
|
||||
i32 x = (i32)item_rect.x0;
|
||||
i32 y = (i32)item_rect.y0 + 2;
|
||||
x = ceil32(draw_string(system, target, font_id, item->query, x, y, text2_color));
|
||||
draw_string(system, target, font_id, item->string, x, y, text1_color);
|
||||
x = ceil32(draw_string(system, target, font_id, item->text_field.query, x, y, text2_color));
|
||||
draw_string(system, target, font_id, item->text_field.string, x, y, text1_color);
|
||||
}break;
|
||||
|
||||
case UIType_ThemePreview:
|
||||
{
|
||||
Style *preview_style = &models->styles.styles[item->theme_preview.theme_index];
|
||||
u32 back = preview_style->main.back_color;
|
||||
u32 margin_color = style_get_margin_color(item->activation_level, preview_style);
|
||||
u32 text_color = preview_style->main.default_color;
|
||||
u32 keyword_color = preview_style->main.keyword_color;
|
||||
u32 int_constant_color = preview_style->main.int_constant_color;
|
||||
u32 comment_color = preview_style->main.comment_color;
|
||||
f32_Rect inner = get_inner_rect(item_rect, 3);
|
||||
draw_rectangle(target, inner, back);
|
||||
draw_margin(target, item_rect, inner, margin_color);
|
||||
i32 start_y = (i32)inner.y0;
|
||||
i32 start_x = (i32)inner.x0;
|
||||
i32 end_y = (i32)inner.y1;
|
||||
i32 y = start_y;
|
||||
i32 x = start_x;
|
||||
x = ceil32(draw_string(system, target, font_id, preview_style->name.str, x, y, text_color));
|
||||
|
||||
i32 height = font.metrics->height;
|
||||
x = start_x;
|
||||
y += height;
|
||||
if (y + height <= end_y){
|
||||
x = ceil32(draw_string(system, target, font_id, "if", x, y, keyword_color));
|
||||
x = ceil32(draw_string(system, target, font_id, "(x < ", x, y, text_color));
|
||||
x = ceil32(draw_string(system, target, font_id, "0", x, y, int_constant_color));
|
||||
x = ceil32(draw_string(system, target, font_id, ") { x = ", x, y, text_color));
|
||||
x = ceil32(draw_string(system, target, font_id, "0", x, y, int_constant_color));
|
||||
x = ceil32(draw_string(system, target, font_id, "; } ", x, y, text_color));
|
||||
x = ceil32(draw_string(system, target, font_id, "// comment", x, y, comment_color));
|
||||
|
||||
x = start_x;
|
||||
y += height;
|
||||
if (y + height <= end_y){
|
||||
draw_string(system, target, font_id, "[] () {}; * -> +-/ <>= ! && || % ^", x, y, text_color);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue