<commit_before>#include "Column.hpp"

namespace cstr
{
	Column::Column(sf::IntRect r, bool s)
		:	Container(r, s)
	{
	}
	
	Column::Column(sf::Vector2i size, bool s)
		:	Container(size, s)
	{
	}

	Column::~Column()
	{
	}
	
	void Column::update(sf::Event& event)
	{
		if(isScrollable())
		{
			if(event.type == sf::Event::MouseMoved)
			{
				if(rect.contains({event.mouseMove.x, event.mouseMove.y}))
					mouseOn = true;
				else
					mouseOn = false;
			}
			else if(mouseOn && event.type == sf::Event::MouseWheelMoved)
			{
				scroll(event.mouseWheel.delta);
			}
		}
		
		updateWidgets(event);
	}
	
	void Column::setPosition(sf::Vector2i pos)
	{
		rect.left = pos.x;
		rect.top = pos.y;
		
		for(auto& w : getWidgets())
		{
			w->setPosition({pos.x + (static_cast<int>(w->getGlobalBounds().left) - rect.left), pos.y + (static_cast<int>(w->getGlobalBounds().top) - rect.top)});
		}
	}
	
	void Column::reposition()
	{
		int totalHeight = 0;
		for(auto& widget : getWidgets())
			totalHeight += widget->getGlobalBounds().height;
		
		for(unsigned i = 0; i < getWidgets().size(); i++)
		{
			auto& w = getWidgets()[i];
			
			sf::IntRect previousRect = (w == getWidgets()[0]) ? sf::IntRect(0, 0, 0, 0) : static_cast<sf::IntRect>(getWidgets()[i - 1]->getGlobalBounds());
			
			if(!w->isContainer())
			{
				if(totalHeight > rect.height - 2 * getBorderSize())
				{
					w->setSize({static_cast<unsigned>(rect.width - 2 * getBorderSize()),
								static_cast<unsigned>(w->getGlobalBounds().height * (rect.height / totalHeight) - 2 * getBorderSize())});
				}
				else
				{
					w->setSize({static_cast<unsigned>(rect.width - 2 * getBorderSize()),
								static_cast<unsigned>(w->getGlobalBounds().height)});
				}
				
				w->setPosition({rect.left + getBorderSize() + rect.width / 2 - static_cast<int>(w->getGlobalBounds().width / 2),
								(w == getWidgets()[0] ? rect.top : previousRect.top) + getBorderSize() + previousRect.height});
			}
			else
			{
				if(w->getGlobalBounds().width - 2 * getBorderSize() > rect.width)
					w->setSize({static_cast<unsigned>(rect.width - 2 * getBorderSize()), static_cast<unsigned>(w->getGlobalBounds().height)});
				if(w->getGlobalBounds().height - 2 * getBorderSize() > rect.height)
					w->setSize({static_cast<unsigned>(w->getGlobalBounds().width), static_cast<unsigned>(rect.height - 2 * getBorderSize())});
				
				w->setPosition({rect.left + getBorderSize() + rect.width / 2 - static_cast<int>(w->getGlobalBounds().width / 2),<commit_msg>I had forgotten border size calculations!!<commit_after>#include "Column.hpp"

namespace cstr
{
	Column::Column(sf::IntRect r, bool s)
		:	Container(r, s)
	{
	}
	
	Column::Column(sf::Vector2i size, bool s)
		:	Container(size, s)
	{
	}

	Column::~Column()
	{
	}
	
	void Column::update(sf::Event& event)
	{
		if(isScrollable())
		{
			if(event.type == sf::Event::MouseMoved)
			{
				if(rect.contains({event.mouseMove.x, event.mouseMove.y}))
					mouseOn = true;
				else
					mouseOn = false;
			}
			else if(mouseOn && event.type == sf::Event::MouseWheelMoved)
			{
				scroll(event.mouseWheel.delta);
			}
		}
		
		updateWidgets(event);
	}
	
	void Column::setPosition(sf::Vector2i pos)
	{
		rect.left = pos.x;
		rect.top = pos.y;
		
		for(auto& w : getWidgets())
		{
			w->setPosition({pos.x + (static_cast<int>(w->getGlobalBounds().left) - rect.left), pos.y + (static_cast<int>(w->getGlobalBounds().top) - rect.top)});
		}
	}
	
	void Column::reposition()
	{
		int totalHeight = 0;
		for(auto& widget : getWidgets())
		{
			totalHeight += widget->getGlobalBounds().height;
		}
		
		for(unsigned i = 0; i < getWidgets().size(); i++)
		{
			auto& w = getWidgets()[i];
			
			sf::IntRect previousRect = (w == getWidgets()[0]) ? sf::IntRect(0, 0, 0, 0) : static_cast<sf::IntRect>(getWidgets()[i - 1]->getGlobalBounds());
			
			if(!w->isContainer())
			{
				if(totalHeight > rect.height - 2 * getBorderSize())
				{
					w->setSize({static_cast<unsigned>(rect.width - 2 * getBorderSize()),
								static_cast<unsigned>(w->getGlobalBounds().height * (rect.height - 2 * getBorderSize()) / totalHeight)});
				}
				else
				{
					w->setSize({static_cast<unsigned>(rect.width - 2 * getBorderSize()),
								static_cast<unsigned>(w->getGlobalBounds().height) - 2 * getBorderSize()});
				}
				
				w->setPosition({rect.left + getBorderSize() + rect.width / 2 - static_cast<int>(w->getGlobalBounds().width / 2),
								(w == getWidgets()[0] ? rect.top : previousRect.top) + getBorderSize() + previousRect.height});
			}
			else
			{
				if(w->getGlobalBounds().width - 2 * getBorderSize() > rect.width)
					w->setSize({static_cast<unsigned>(rect.width - 2 * getBorderSize()), static_cast<unsigned>(w->getGlobalBounds().height)});
				if(w->getGlobalBounds().height - 2 * getBorderSize() > rect.height)
					w->setSize({static_cast<unsigned>(w->getGlobalBounds().width), static_cast<unsigned>(rect.height - 2 * getBorderSize())});
				
				w->setPosition({rect.left + getBorderSize() + rect.width / 2 - static_cast<int>(w->getGlobalBounds().width / 2),
{'fraction_non_alphanumeric': 0.18845467169212457, 'fraction_numerical': 0.009323546915294585, 'mean_word_length': 3.596171376481313, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1658890', 'n_tokens_mistral': 2117, 'n_tokens_neox': 1760, 'n_words': 274}