Fix integer division & uninitialized alignment
This commit is contained in:
parent
3934e4777f
commit
f3b722deed
@ -8,6 +8,8 @@
|
||||
|
||||
enum class Alignment { LEFT, RIGHT, CENTER };
|
||||
struct PositionInfo {
|
||||
PositionInfo();
|
||||
|
||||
int x;
|
||||
int y;
|
||||
Alignment align;
|
||||
|
@ -7,13 +7,15 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
PositionInfo::PositionInfo() : x{0}, y{0}, align{Alignment::LEFT} {}
|
||||
|
||||
Widget::Widget(SDL_Renderer* renderer) : renderer{renderer}, rect{0, 0, 0, 0} {}
|
||||
|
||||
Widget::~Widget() {}
|
||||
|
||||
void Widget::set_width(int width, bool preserve_aspect_ratio) {
|
||||
if (preserve_aspect_ratio) {
|
||||
float scale = width / rect.w;
|
||||
float scale = ((float)width) / rect.w;
|
||||
rect.h = round(rect.h * scale);
|
||||
}
|
||||
rect.w = width;
|
||||
|
Loading…
x
Reference in New Issue
Block a user