default_ui_render_caller - decomposition
parent
068defec5f
commit
a315461286
|
@ -665,6 +665,10 @@ get_process_state(Application_Links *app, Buffer_ID buffer_id){
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
|
@ -795,55 +795,78 @@ get_margin_color(i32 level){
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
default_ui_render_caller(Application_Links *app, View_ID view_id){
|
default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_f32, Face_ID face_id){
|
||||||
UI_Data *ui_data = 0;
|
UI_Data *ui_data = 0;
|
||||||
Arena *ui_arena = 0;
|
Arena *ui_arena = 0;
|
||||||
if (view_get_ui_data(app, view_id, ViewGetUIFlag_KeepDataAsIs, &ui_data, &ui_arena)){
|
if (view_get_ui_data(app, view_id, ViewGetUIFlag_KeepDataAsIs, &ui_data, &ui_arena)){
|
||||||
View_Summary view = {};
|
GUI_Scroll_Vars ui_scroll = {};
|
||||||
if (get_view_summary(app, view_id, AccessAll, &view)){
|
view_get_scroll_vars(app, view_id, &ui_scroll);
|
||||||
Rect_f32 rect_f32 = f32R(view.render_region);
|
|
||||||
GUI_Scroll_Vars ui_scroll = view.scroll_vars;
|
for (UI_Item *item = ui_data->list.first;
|
||||||
|
item != 0;
|
||||||
|
item = item->next){
|
||||||
|
Rect_i32 item_rect_i32 = item->rect_outer;
|
||||||
|
Rect_f32 item_rect = f32R(item_rect_i32);
|
||||||
|
|
||||||
for (UI_Item *item = ui_data->list.first;
|
switch (item->coordinates){
|
||||||
item != 0;
|
case UICoordinates_ViewSpace:
|
||||||
item = item->next){
|
{
|
||||||
Rect_i32 item_rect_i32 = item->rect_outer;
|
item_rect.p0 -= ui_scroll.scroll_p;
|
||||||
Rect_f32 item_rect = f32R(item_rect_i32);
|
item_rect.p1 -= ui_scroll.scroll_p;
|
||||||
|
}break;
|
||||||
|
case UICoordinates_PanelSpace:
|
||||||
|
{}break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rect_overlap(item_rect, rect_f32)){
|
||||||
|
Rect_f32 inner_rect = get_inner_rect(item_rect, (f32)item->inner_margin);
|
||||||
|
|
||||||
switch (item->coordinates){
|
Face_Metrics metrics = {};
|
||||||
case UICoordinates_ViewSpace:
|
get_face_metrics(app, face_id, &metrics);
|
||||||
{
|
f32 line_height = metrics.line_height;
|
||||||
item_rect.p0 -= ui_scroll.scroll_p;
|
f32 info_height = (f32)item->line_count*line_height;
|
||||||
item_rect.p1 -= ui_scroll.scroll_p;
|
|
||||||
}break;
|
draw_rectangle(app, inner_rect, Stag_Back);
|
||||||
case UICoordinates_PanelSpace:
|
Vec2 p = V2(inner_rect.x0 + 3.f, (f32)(round32((inner_rect.y0 + inner_rect.y1 - info_height)*0.5f)));
|
||||||
{}break;
|
for (i32 i = 0; i < item->line_count; i += 1){
|
||||||
|
draw_fancy_string(app, face_id, item->lines[i].first, p, Stag_Default, 0, 0, V2(1.f, 0));
|
||||||
|
p.y += line_height;
|
||||||
}
|
}
|
||||||
|
if (item->inner_margin > 0){
|
||||||
if (rect_overlap(item_rect, rect_f32)){
|
draw_margin(app, item_rect, inner_rect, get_margin_color(item->activation_level));
|
||||||
Rect_f32 inner_rect = get_inner_rect(item_rect, (f32)item->inner_margin);
|
|
||||||
|
|
||||||
Face_ID font_id = 0;
|
|
||||||
get_face_id(app, view.buffer_id, &font_id);
|
|
||||||
|
|
||||||
// TODO(allen): get font_id line height
|
|
||||||
f32 line_height = view.line_height;
|
|
||||||
f32 info_height = (f32)item->line_count*line_height;
|
|
||||||
|
|
||||||
draw_rectangle(app, inner_rect, Stag_Back);
|
|
||||||
Vec2 p = V2(inner_rect.x0 + 3.f, (f32)(round32((inner_rect.y0 + inner_rect.y1 - info_height)*0.5f)));
|
|
||||||
for (i32 i = 0; i < item->line_count; i += 1){
|
|
||||||
draw_fancy_string(app, font_id, item->lines[i].first, p, Stag_Default, 0, 0, V2(1.f, 0));
|
|
||||||
p.y += view.line_height;
|
|
||||||
}
|
|
||||||
if (item->inner_margin > 0){
|
|
||||||
draw_margin(app, item_rect, inner_rect, get_margin_color(item->activation_level));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void
|
||||||
|
default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_f32){
|
||||||
|
Buffer_ID buffer_id = 0;
|
||||||
|
view_get_buffer(app, view_id, AccessAll, &buffer_id);
|
||||||
|
Face_ID face_id = 0;
|
||||||
|
get_face_id(app, buffer_id, &face_id);
|
||||||
|
default_ui_render_caller(app, view_id, rect_f32, face_id);
|
||||||
|
}
|
||||||
|
static void
|
||||||
|
default_ui_render_caller(Application_Links *app, View_ID view_id, Face_ID face_id){
|
||||||
|
View_Summary view = {};
|
||||||
|
if (get_view_summary(app, view_id, AccessAll, &view)){
|
||||||
|
Rect_f32 rect_f32 = f32R(view.render_region);
|
||||||
|
default_ui_render_caller(app, view_id, rect_f32, face_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void
|
||||||
|
default_ui_render_caller(Application_Links *app, View_ID view_id){
|
||||||
|
View_Summary view = {};
|
||||||
|
if (get_view_summary(app, view_id, AccessAll, &view)){
|
||||||
|
Rect_f32 rect_f32 = f32R(view.render_region);
|
||||||
|
Buffer_ID buffer_id = 0;
|
||||||
|
view_get_buffer(app, view_id, AccessAll, &buffer_id);
|
||||||
|
Face_ID face_id = 0;
|
||||||
|
get_face_id(app, buffer_id, &face_id);
|
||||||
|
default_ui_render_caller(app, view_id, rect_f32, face_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
default_render_view(Application_Links *app, Frame_Info frame_info, View_ID view_id, b32 is_active){
|
default_render_view(Application_Links *app, Frame_Info frame_info, View_ID view_id, b32 is_active){
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Mr. 4th Dimention - Allen Webster
|
||||||
|
*
|
||||||
|
* 31.03.2019
|
||||||
|
*
|
||||||
|
* Implementation of the API functions.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TOP
|
||||||
|
|
||||||
|
#if !defined(FRED_TEXT_LAYOUT_H)
|
||||||
|
#define FRED_TEXT_LAYOUT_H
|
||||||
|
|
||||||
|
struct Text_Layout{
|
||||||
|
// NOTE(allen): This is not a _real_ text layout yet.
|
||||||
|
// The eventual destiny of this type is that it will store the fairly
|
||||||
|
// costly to generate results of the text layout engine.
|
||||||
|
// For now, since the engine cannot be easily consolidated,
|
||||||
|
// this just stores the parameters that should be handed to any
|
||||||
|
// system that attempts to query the layout for hit testing.
|
||||||
|
Buffer_ID buffer_id;
|
||||||
|
i32 line;
|
||||||
|
Vec2 pixel_shift;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// BOTTOM
|
||||||
|
|
Loading…
Reference in New Issue