コード例 #1
0
ファイル: InputSequence.cpp プロジェクト: xournalpp/xournalpp
/**
 * Mouse / Pen up / touch end
 */
void InputSequence::actionEnd(guint32 time)
{
	XOJ_CHECK_TYPE(InputSequence);

	if (!inputRunning)
	{
		return;
	}

	this->eventTime = time;

	// Mouse button not pressed anymore
	this->button = 0;

	current_view = NULL;

	GtkXournal* xournal = inputHandler->getXournal();
	XournalppCursor* cursor = xournal->view->getCursor();
	ToolHandler* h = inputHandler->getToolHandler();

	if (xournal->view->getControl()->getWindow()->isGestureActive())
	{
		stopInput();
		return;
	}

	cursor->setMouseDown(false);

	inScrolling = false;

	EditSelection* sel = xournal->view->getSelection();
	if (sel)
	{
		sel->mouseUp();
	}

	if (currentInputPage)
	{
		PositionInputData pos = getInputDataRelativeToCurrentPage(currentInputPage);
		currentInputPage->onButtonReleaseEvent(pos);
		currentInputPage = NULL;
	}

	EditSelection* tmpSelection = xournal->selection;
	xournal->selection = NULL;

	h->restoreLastConfig();

	// we need this workaround so it's possible to select something with the middle button
	if (tmpSelection)
	{
		xournal->view->setSelection(tmpSelection);
	}

	stopInput();
}
コード例 #2
0
ファイル: XournalWidget.cpp プロジェクト: scottt/xournalpp
gboolean gtk_xournal_button_release_event(GtkWidget* widget,
                                          GdkEventButton* event)
{
#ifdef INPUT_DEBUG
	gboolean isCore = (event->device == gdk_device_get_core_pointer());
	INPUTDBG("ButtonRelease (%s) (x,y)=(%.2f,%.2f), button %d, modifier %x, isCore %i",
	         gdk_device_get_name(event->device), event->x, event->y,
	         event->button, event->state, isCore);
#endif
	XInputUtils::fixXInputCoords((GdkEvent*) event, widget);

	if (event->button > 3)   // scroll wheel events
	{
		return true;
	}

	current_view = NULL;

	GtkXournal* xournal = GTK_XOURNAL(widget);

	Cursor* cursor = xournal->view->getCursor();
	ToolHandler* h = xournal->view->getControl()->getToolHandler();
	cursor->setMouseDown(false);

	xournal->inScrolling = false;

	EditSelection* sel = xournal->view->getSelection();
	if (sel)
	{
		sel->mouseUp();
	}

	bool res = false;
	if (xournal->currentInputPage)
	{
		xournal->currentInputPage->translateEvent((GdkEvent*) event, xournal->x,
		                                          xournal->y);
		res = xournal->currentInputPage->onButtonReleaseEvent(widget, event);
		xournal->currentInputPage = NULL;
	}

	EditSelection* tmpSelection = xournal->selection;
	xournal->selection = NULL;

	h->restoreLastConfig();

	// we need this workaround so it's possible to select something with the middle button
	if (tmpSelection)
	{
		xournal->view->setSelection(tmpSelection);
	}

	return res;
}
コード例 #3
0
ファイル: InputSequence.cpp プロジェクト: xournalpp/xournalpp
/**
 * Change the tool according to the device and button
 * @return true to ignore event
 */
bool InputSequence::changeTool()
{
	XOJ_CHECK_TYPE(InputSequence);

	Settings* settings = inputHandler->getSettings();
	ButtonConfig* cfgTouch = settings->getTouchButtonConfig();
	ToolHandler* h = inputHandler->getToolHandler();
	GtkXournal* xournal = inputHandler->getXournal();

	ButtonConfig* cfg = NULL;
	if (gdk_device_get_source(device) == GDK_SOURCE_PEN)
	{
		penDevice = true;
		if (button == 2)
		{
			cfg = settings->getStylusButton1Config();
		}
		else if (button == 3)
		{
			cfg = settings->getStylusButton2Config();
		}
	}
	else if (button == 2 /* Middle Button */ && !xournal->selection)
	{
		cfg = settings->getMiddleButtonConfig();
	}
	else if (button == 3 /* Right Button */ && !xournal->selection)
	{
		cfg = settings->getRightButtonConfig();
	}
	else if (gdk_device_get_source(device) == GDK_SOURCE_ERASER)
	{
		penDevice = true;
		cfg = settings->getEraserButtonConfig();
	}
	else if (cfgTouch->device == gdk_device_get_name(device))
	{
		cfg = cfgTouch;

		// If an action is defined we do it, even if it's a drawing action...
		if (cfg->getDisableDrawing() && cfg->getAction() == TOOL_NONE)
		{
			ToolType tool = h->getToolType();
			if (tool == TOOL_PEN || tool == TOOL_ERASER || tool == TOOL_HILIGHTER)
			{
				g_message("ignore touchscreen for drawing!\n");
				return true;
			}
		}
	}

	if (cfg && cfg->getAction() != TOOL_NONE)
	{
		h->copyCurrentConfig();
		cfg->acceptActions(h);
	}
	else
	{
		h->restoreLastConfig();
	}

	return false;
}