MCPcopy Create free account
hub / github.com/cococry/leif / _lf_image_button_fixed_loc

Function _lf_image_button_fixed_loc

leif.c:2485–2520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2483}
2484
2485LfClickableItemState _lf_image_button_fixed_loc(LfTexture img, float width, float height, const char* file, int32_t line) {
2486 // Retrieving the property data of the button
2487 LfUIElementProps props = get_props_for(state.theme.button_props);
2488 float padding = props.padding;
2489 float margin_left = props.margin_left, margin_right = props.margin_right,
2490 margin_top = props.margin_top, margin_bottom = props.margin_bottom;
2491
2492 LfColor color = props.color;
2493 LfColor text_color = state.theme.button_props.text_color;
2494 LfFont font = get_current_font();
2495
2496 int32_t render_width = ((width == -1) ? img.width : width);
2497 int32_t render_height = ((height == -1) ? img.height : height);
2498
2499 // If the button does not fit onto the current div, advance to the next line
2500 next_line_on_overflow(
2501 (vec2s){render_width + padding * 2.0f,
2502 render_height + padding * 2.0f},
2503 state.div_props.border_width);
2504
2505 // Advancing the position pointer by the margins
2506 state.pos_ptr.x += margin_left;
2507 state.pos_ptr.y += margin_top;
2508
2509 // Rendering the button
2510 LfClickableItemState ret = button(file, line, state.pos_ptr, (vec2s){render_width + padding * 2, render_height + padding * 2},
2511 props, color, props.border_width, true, true);
2512 LfColor imageColor = LF_WHITE;
2513 lf_image_render((vec2s){state.pos_ptr.x + padding + (render_width - img.width) / 2.0f, state.pos_ptr.y + padding}, imageColor, img, LF_NO_COLOR, 0, props.corner_radius);
2514
2515 // Advancing the position pointer by the width of the button
2516 state.pos_ptr.x += render_width + margin_right + padding * 2.0f;
2517 state.pos_ptr.y -= margin_top;
2518
2519 return ret;
2520}
2521
2522LfClickableItemState _lf_button_fixed_loc(const char* text, float width, float height, const char* file, int32_t line) {
2523 return button_fixed_element_loc((void*)text, width, height, file, line, false);

Callers

nothing calls this directly

Calls 5

get_props_forFunction · 0.85
get_current_fontFunction · 0.85
next_line_on_overflowFunction · 0.85
buttonFunction · 0.85
lf_image_renderFunction · 0.85

Tested by

no test coverage detected