<commit_before>#include "Panel.h"

#include <cmath>

#include "Graphics.h"

#include "Touch.h"




BEGIN_NAMESPACE_CA_DRAWING


Panel::Panel()
	: size(1, 1)
{

}


Panel::~Panel()
{

}

//###########################################################################

void Panel::update(const Transform& parentTransform, const Point& cursor)
{
	// úȯ ȯ ħ
	Transform combinedTransform = parentTransform;
	combinedTransform.addTransform(transform);


	// Ŀ ġ ȯ
	Point iLocalCursor = static_cast<Point>(combinedTransform.inverseTransformPoint(static_cast<PointF>(cursor)));


	//  
	for (auto& updatable : m_updatables)
	{
		updatable.lock()->update(combinedTransform, cursor);
	}
}

//###########################################################################

void Panel::onDraw(Graphics& g, const Transform& parentTransform)
{
	// úȯ ȯ ħ
	Transform combinedTransform = parentTransform;
	combinedTransform.addTransform(transform);


	beginDraw(combinedTransform);


	//  ׸
	for (auto& drawable : m_drawables)
	{
		drawable.lock()->draw(g, combinedTransform);
	}


	endDraw();
}

//###########################################################################

void Panel::update(Window& win)
{
	// Ŀ ġ ȯ
	PointF cursor = System::Touch::getInstance()->getPositionF(win);
	Point iLocalCursor = static_cast<Point>(cursor);//static_cast<Point>(transform.inverseTransformPoint(cursor));


	//  
	for (auto& updatable : m_updatables)
	{
		updatable.lock()->update(transform, iLocalCursor);
	}
}


void Panel::draw(Graphics& g)
{
	beginDraw(transform);


	//  ׸
	for (auto& drawable : m_drawables)
	{
		drawable.lock()->draw(g, transform);
	}


	endDraw();
}

//###########################################################################

bool Panel::addDrawable(std::weak_ptr<Drawable> drawable)
{
	// ߺ Ȯ
	auto target = drawable.lock();

	for (const auto& item : m_drawables)
	{
		if (target == item.lock())
		{
			// ߺ
			return false;
		}
	}
<commit_msg>Fix a way to use weak_ptr.<commit_after>#include "Panel.h"

#include <cmath>

#include "Graphics.h"

#include "Touch.h"




BEGIN_NAMESPACE_CA_DRAWING


Panel::Panel()
	: size(1, 1)
{

}


Panel::~Panel()
{

}

//###########################################################################

void Panel::update(const Transform& parentTransform, const Point& cursor)
{
	// úȯ ȯ ħ
	Transform combinedTransform = parentTransform;
	combinedTransform.addTransform(transform);


	// Ŀ ġ ȯ
	Point iLocalCursor = static_cast<Point>(combinedTransform.inverseTransformPoint(static_cast<PointF>(cursor)));


	//  
	for (auto& updatable : m_updatables)
	{
		auto ptr = updatable.lock();
		if (ptr)
		{
			ptr->update(combinedTransform, cursor);
		}
	}
}

//###########################################################################

void Panel::onDraw(Graphics& g, const Transform& parentTransform)
{
	// úȯ ȯ ħ
	Transform combinedTransform = parentTransform;
	combinedTransform.addTransform(transform);


	beginDraw(combinedTransform);


	//  ׸
	for (auto& drawable : m_drawables)
	{
		auto ptr = drawable.lock();
		if (ptr)
		{
			ptr->draw(g, combinedTransform);
		}
	}


	endDraw();
}

//###########################################################################

void Panel::update(Window& win)
{
	// Ŀ ġ ȯ
	PointF cursor = System::Touch::getInstance()->getPositionF(win);
	Point iLocalCursor = static_cast<Point>(cursor);


	//  
	for (auto& updatable : m_updatables)
	{
		auto ptr = updatable.lock();
		if (ptr)
		{
			ptr->update(transform, iLocalCursor);
		}
	}
}


void Panel::draw(Graphics& g)
{
	beginDraw(transform);


	//  ׸
	for (auto& drawable : m_drawables)
	{
		auto ptr = drawable.lock();
		if (ptr)
		{
			ptr->draw(g, transform);
		}
	}


	endDraw();
}

//###########################################################################

bool Panel::addDrawable(std::weak_ptr<Drawable> drawable)
{
	// ߺ Ȯ
	auto target = drawable.lock();

	for (const auto& item : m_drawables)
	{
		if (target == item.lock())
		{
			// ߺ
			return false;
		}
	}

{'fraction_non_alphanumeric': 0.28010012515644556, 'fraction_numerical': 0.0010012515644555694, 'mean_word_length': 4.724928366762177, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 24, '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': '5791652', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1314, 'n_words': 245}