<commit_before>#include "MoveSpriteCenterState.h"

#include <ee/Sprite.h>
#include <ee/FileHelper.h>

#include <easycomplex.h>

#include <sprite2/S2_Sprite.h>

namespace eui
{
namespace window
{

MoveSpriteCenterState::MoveSpriteCenterState(ecomplex::Sprite* spr,
											 const sm::vec2& first_pos)
	: m_spr(spr)
	, m_dirty(false)
{
	m_first_pos = m_last_pos = first_pos;
}

MoveSpriteCenterState::~MoveSpriteCenterState()
{
}

void MoveSpriteCenterState::OnMousePress(const sm::vec2& pos)
{
	m_first_pos = m_last_pos = pos;
}

void MoveSpriteCenterState::OnMouseRelease(const sm::vec2& pos)
{
	m_last_pos.MakeInvalid();
	// todo edit history

	if (m_dirty && m_spr) {
// 		ecomplex::Symbol& complex = const_cast<ecomplex::Symbol&>(m_spr->GetSymbol());
// 		complex.InitBounding();
//		m_spr->UpdateBounding();
	}

	m_dirty = false;
}

bool MoveSpriteCenterState::OnMouseDrag(const sm::vec2& pos)
{
	if (!m_spr || !m_last_pos.IsValid()) {
		return false;
	}

	sm::vec2 offset = m_last_pos - pos;
	m_last_pos = pos;

	m_dirty = true;

	const ecomplex::Symbol* sym = dynamic_cast<const ecomplex::Symbol*>(m_spr->GetSymbol());
	const std::vector<s2::Sprite*>& children = sym->GetChildren();
	for (int i = 0, n = children.size(); i < n; ++i) {
		children[i]->Translate(offset);
	}

	ecomplex::FileStorer::Store(sym->GetFilepath(), sym, ee::FileHelper::GetFileDir(sym->GetFilepath()));

	return true;
}

}
}<commit_msg>[FIXED] move eui wnd cross point<commit_after>#include "MoveSpriteCenterState.h"

#include <ee/Sprite.h>
#include <ee/FileHelper.h>

#include <easycomplex.h>

#include <sprite2/S2_Sprite.h>

namespace eui
{
namespace window
{

MoveSpriteCenterState::MoveSpriteCenterState(ecomplex::Sprite* spr,
											 const sm::vec2& first_pos)
	: m_spr(spr)
	, m_dirty(false)
{
	m_first_pos = m_last_pos = first_pos;
}

MoveSpriteCenterState::~MoveSpriteCenterState()
{
}

void MoveSpriteCenterState::OnMousePress(const sm::vec2& pos)
{
	m_first_pos = m_last_pos = pos;
}

void MoveSpriteCenterState::OnMouseRelease(const sm::vec2& pos)
{
	m_last_pos.MakeInvalid();
	// todo edit history

	if (m_dirty && m_spr) {
		m_spr->UpdateBounding();
	}

	m_dirty = false;
}

bool MoveSpriteCenterState::OnMouseDrag(const sm::vec2& pos)
{
	if (!m_spr || !m_last_pos.IsValid()) {
		return false;
	}

	sm::vec2 offset = m_last_pos - pos;
	m_last_pos = pos;

	m_dirty = true;

	const ecomplex::Symbol* sym = dynamic_cast<const ecomplex::Symbol*>(m_spr->GetSymbol());
	const std::vector<s2::Sprite*>& children = sym->GetChildren();
	for (int i = 0, n = children.size(); i < n; ++i) {
		children[i]->Translate(-offset);
	}

	ecomplex::FileStorer::Store(sym->GetFilepath(), sym, ee::FileHelper::GetFileDir(sym->GetFilepath()));

	return true;
}

}
}
{'fraction_non_alphanumeric': 0.1601605253557096, 'fraction_numerical': 0.006566946369937978, 'mean_word_length': 5.436619718309859, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 29, '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': '1364434', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1062, 'n_words': 183}