Fix integer division & uninitialized alignment
This commit is contained in:
		@ -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;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user