| 1177 | return ret; |
| 1178 | } |
| 1179 | LfClickableItemState button_fixed_element_loc(void* text, float width, float height, const char* file, int32_t line, bool wide) { |
| 1180 | // Retrieving the property data of the button |
| 1181 | LfUIElementProps props = get_props_for(state.theme.button_props); |
| 1182 | float padding = props.padding; |
| 1183 | float margin_left = props.margin_left, margin_right = props.margin_right, |
| 1184 | margin_top = props.margin_top, margin_bottom = props.margin_bottom; |
| 1185 | |
| 1186 | LfFont font = state.font_stack ? *state.font_stack : state.theme.font; |
| 1187 | LfTextProps text_props; |
| 1188 | if(wide) |
| 1189 | text_props = text_render_simple_wide(state.pos_ptr, (const wchar_t*)text, font, LF_NO_COLOR, true); |
| 1190 | else |
| 1191 | text_props = text_render_simple(state.pos_ptr, (const char*)text, font, LF_NO_COLOR, true); |
| 1192 | |
| 1193 | LfColor color = props.color; |
| 1194 | LfColor text_color = lf_hovered(state.pos_ptr, (vec2s){text_props.width, text_props.height}) && props.hover_text_color.a != 0.0f ? props.hover_text_color : props.text_color; |
| 1195 | |
| 1196 | // If the button does not fit onto the current div, advance to the next line |
| 1197 | int32_t render_width = ((width == -1) ? text_props.width : width); |
| 1198 | int32_t render_height = ((height == -1) ? text_props.height : height); |
| 1199 | |
| 1200 | next_line_on_overflow( |
| 1201 | (vec2s){render_width + padding * 2.0f + margin_right + margin_left, |
| 1202 | render_height + padding * 2.0f + margin_bottom + margin_top}, |
| 1203 | state.div_props.border_width); |
| 1204 | |
| 1205 | // Advancing the position pointer by the margins |
| 1206 | state.pos_ptr.x += margin_left; |
| 1207 | state.pos_ptr.y += margin_top; |
| 1208 | |
| 1209 | // Rendering the button |
| 1210 | LfClickableItemState ret = button(file, line, state.pos_ptr, |
| 1211 | (vec2s){render_width + padding * 2.0f, render_height + padding * 2.0f}, props, |
| 1212 | color, props.border_width, false, true); |
| 1213 | |
| 1214 | // Rendering the text of the button |
| 1215 | |
| 1216 | lf_set_cull_end_x(state.pos_ptr.x + render_width + padding); |
| 1217 | if(wide) { |
| 1218 | text_render_simple_wide((vec2s) |
| 1219 | {state.pos_ptr.x + padding + ((width != -1) ? (width - text_props.width) / 2.0f : 0), |
| 1220 | state.pos_ptr.y + padding + ((height != -1) ? (height - text_props.height) / 2.0f : 0)}, (const wchar_t*)text, font, text_color, false); |
| 1221 | } else { |
| 1222 | text_render_simple((vec2s) |
| 1223 | {state.pos_ptr.x + padding + ((width != -1) ? (width - text_props.width) / 2.0f : 0), |
| 1224 | state.pos_ptr.y + padding + ((height != -1) ? (height - text_props.height) / 2.0f : 0)}, (const char*)text, font, text_color, false); |
| 1225 | } |
| 1226 | lf_unset_cull_end_x(); |
| 1227 | |
| 1228 | // Advancing the position pointer by the width of the button |
| 1229 | state.pos_ptr.x += render_width + margin_right + padding * 2.0f; |
| 1230 | state.pos_ptr.y -= margin_top; |
| 1231 | return ret; |
| 1232 | |
| 1233 | } |
| 1234 | LfClickableItemState checkbox_element_loc(void* text, bool* val, LfColor tick_color, LfColor tex_color, const char* file, int32_t line, bool wide) { |
| 1235 | // Retrieving the property values of the checkbox |
| 1236 | LfFont font = get_current_font(); |
no test coverage detected