| 1135 | } |
| 1136 | |
| 1137 | LfClickableItemState button_element_loc(void* text, const char* file, int32_t line, bool wide) { |
| 1138 | // Retrieving the property data of the button |
| 1139 | LfUIElementProps props = get_props_for(state.theme.button_props); |
| 1140 | float padding = props.padding; |
| 1141 | float margin_left = props.margin_left, margin_right = props.margin_right, |
| 1142 | margin_top = props.margin_top, margin_bottom = props.margin_bottom; |
| 1143 | |
| 1144 | // Advancing the position pointer by the margins |
| 1145 | state.pos_ptr.x += margin_left; |
| 1146 | state.pos_ptr.y += margin_top; |
| 1147 | LfFont font = get_current_font(); |
| 1148 | |
| 1149 | LfTextProps text_props; |
| 1150 | if(wide) |
| 1151 | text_props = text_render_simple_wide(state.pos_ptr, (const wchar_t*)text, font, LF_NO_COLOR, true); |
| 1152 | else |
| 1153 | text_props = text_render_simple(state.pos_ptr, (const char*)text, font, LF_NO_COLOR, true); |
| 1154 | |
| 1155 | LfColor color = props.color; |
| 1156 | 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; |
| 1157 | |
| 1158 | // If the button does not fit onto the current div, advance to the next line |
| 1159 | next_line_on_overflow( |
| 1160 | (vec2s){text_props.width + padding * 2.0f + margin_right + margin_left, |
| 1161 | text_props.height + padding * 2.0f + margin_bottom + margin_top}, state.div_props.border_width); |
| 1162 | |
| 1163 | |
| 1164 | // Rendering the button |
| 1165 | LfClickableItemState ret = button(file, line, state.pos_ptr, (vec2s){text_props.width + padding * 2, text_props.height + padding * 2}, |
| 1166 | props, color, props.border_width, true, true); |
| 1167 | // Rendering the text of the button |
| 1168 | if(wide) |
| 1169 | text_render_simple_wide((vec2s){state.pos_ptr.x + padding, state.pos_ptr.y + padding}, (const wchar_t*)text, font, text_color, false); |
| 1170 | else |
| 1171 | text_render_simple((vec2s){state.pos_ptr.x + padding, state.pos_ptr.y + padding}, (const char*)text, font, text_color, false); |
| 1172 | |
| 1173 | // Advancing the position pointer by the width of the button |
| 1174 | state.pos_ptr.x += text_props.width + margin_right + padding * 2.0f; |
| 1175 | state.pos_ptr.y -= margin_top; |
| 1176 | |
| 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); |
no test coverage detected