Beispiel #1
0
void PinchTool::mouseMove(const TPointD &pos,
						  const TMouseEvent &event)
{
	if (m_active)
		return;

	if (!m_draw)
		m_draw = true;

	ContextStatus *status = &m_status;
	m_curr = pos;

	const int pixelRange = 3;
	if (abs(m_lastMouseEvent.m_pos.x - event.m_pos.x) < pixelRange &&
		abs(m_lastMouseEvent.m_pos.y - event.m_pos.y) < pixelRange &&
		m_lastMouseEvent.getModifiersMask() == event.getModifiersMask())
		return;

	m_lastMouseEvent = event;
	double w = 0;
	TStroke *stroke = getClosestStroke(pos, w);
	if (stroke) {
		// set parameters from sliders
		updateInterfaceStatus(event);

		// update information about current stroke
		updateStrokeStatus(stroke, w);

		// retrieve the currect m_deformation and
		// prepare to design and modify
		if (m_deformation)
			m_deformation->check(status);

		m_selector.setStroke(stroke);
		m_selector.mouseMove(m_curr);
	} else {
		m_status.stroke2change_ = 0;
		m_selector.setStroke(0);
		return;
	}

	m_prev = m_curr;
	m_cursorEnabled = moveCursor(pos);

	if (m_cursorEnabled)
		invalidate();

	//  TNotifier::instance()->notify(TToolChange());
}
void FullColorBrushTool::mouseMove(const TPointD &pos, const TMouseEvent &e)
{
	struct Locals {
		FullColorBrushTool *m_this;

		void setValue(TIntPairProperty &prop, const TIntPairProperty::Value &value)
		{
			prop.setValue(value);

			m_this->onPropertyChanged(prop.getName());
			TTool::getApplication()->getCurrentTool()->notifyToolChanged();
		}

		void addMinMax(TIntPairProperty &prop, double add)
		{
			const TIntPairProperty::Range &range = prop.getRange();

			TIntPairProperty::Value value = prop.getValue();
			value.second = tcrop<double>(value.second + add, range.first, range.second);
			value.first = tcrop<double>(value.first + add, range.first, range.second);

			setValue(prop, value);
		}

	} locals = {this};

	switch (e.getModifiersMask()) {
	/*-- Altキー+マウス移動で、ブラシサイズ(Min/Maxとも)を変える(CtrlやShiftでは誤操作の恐れがある) --*/
	case TMouseEvent::ALT_KEY: {
		// User wants to alter the minimum brush size
		const TPointD &diff = pos - m_mousePos;
		double add = (fabs(diff.x) > fabs(diff.y)) ? diff.x : diff.y;

		locals.addMinMax(m_thickness, int(add));
	}

	DEFAULT:
		m_brushPos = pos;
	}

	m_mousePos = pos;
	invalidate();
}