Panel now holds data on how it should be rendered and render just uses that instead of calculating it.

This commit is contained in:
Zed A. Shaw 2024-11-18 12:07:44 -05:00
parent 1a3bbaedda
commit f79e7638c0
5 changed files with 27 additions and 17 deletions

View file

@ -216,18 +216,16 @@ void SFMLRender::render_text(const std::wstring &text, float start_x, float star
}
}
void SFMLRender::draw_text(Panel &panel, bool with_border) {
int border_px = with_border ? UI_PANEL_BORDER_PX : 0;
void SFMLRender::draw_text(Panel &panel) {
sf::RectangleShape backing(
sf::Vector2f($ui_bounds.width * panel.width + border_px,
$ui_bounds.height * panel.height + border_px));
sf::Vector2f($ui_bounds.width * panel.width + panel.border_px,
$ui_bounds.height * panel.height + panel.border_px));
backing.setFillColor(sf::Color(0, 0, 0));
backing.setFillColor(panel.default_bg);
if(with_border) {
backing.setOutlineColor(color(Value::MID));
backing.setOutlineThickness(border_px);
if(panel.has_border) {
backing.setOutlineColor(panel.border_color);
backing.setOutlineThickness(panel.border_px);
}
backing.setPosition(panel.x, panel.y);