void lcTimelineWidget::CustomMenuRequested(QPoint Pos)
{
	QMenu* Menu = new QMenu(this);

	QTreeWidgetItem* TreeItem = itemAt(Pos);

	lcObject* FocusObject = lcGetActiveModel()->GetFocusObject();

	if (FocusObject && FocusObject->IsPiece())
	{
		lcPiece* Piece = (lcPiece*)FocusObject;

		if (Piece->mPieceInfo->IsModel())
		{
			Menu->addAction(gMainWindow->mActions[LC_MODEL_EDIT_FOCUS]);
			Menu->addSeparator();
		}
	}

	// look for step headings
	if (TreeItem && TreeItem->data(0, Qt::UserRole).isNull())
	{
		{
			QAction* Action = new QAction(tr("Move selection here"), this);
			Action->setStatusTip(tr("Move the selected parts into this step"));
			Action->setData(qVariantFromValue((void *) TreeItem));
			Action->setEnabled(selectedItems().count() != 0);
			connect(Action, SIGNAL(triggered()), this, SLOT(MoveSelectionTo()));
			Menu->addAction(Action);
		}
		{
			QAction* Action = new QAction(tr("Set as current step"), this);
			Action->setStatusTip(tr("View the model at this point in the timeline"));
			Action->setData(qVariantFromValue((void *) TreeItem));
			connect(Action, SIGNAL(triggered()), this, SLOT(UpdateCurrentStep()));
			Menu->addAction(Action);
		}

		Menu->addSeparator();
	}

	QAction* InsertStepAction = Menu->addAction(gMainWindow->mActions[LC_VIEW_TIME_INSERT]->text(), this, SLOT(InsertStep()));
	InsertStepAction->setStatusTip(gMainWindow->mActions[LC_VIEW_TIME_INSERT]->statusTip());
	QAction* RemoveStepAction = Menu->addAction(gMainWindow->mActions[LC_VIEW_TIME_DELETE]->text(), this, SLOT(RemoveStep()));
	RemoveStepAction->setStatusTip(gMainWindow->mActions[LC_VIEW_TIME_DELETE]->statusTip());
	Menu->addSeparator();

	Menu->addAction(gMainWindow->mActions[LC_PIECE_HIDE_SELECTED]);
	Menu->addAction(gMainWindow->mActions[LC_PIECE_HIDE_UNSELECTED]);
	Menu->addAction(gMainWindow->mActions[LC_PIECE_UNHIDE_SELECTED]);
	Menu->addAction(gMainWindow->mActions[LC_PIECE_UNHIDE_ALL]);

	Menu->popup(viewport()->mapToGlobal(Pos));
}
Exemple #2
0
void
TMagnify::MouseDown(BPoint where)
{
	BMessage *currentMsg = Window()->CurrentMessage();
	if (currentMsg->what == B_MOUSE_DOWN) {
		uint32 buttons = 0;
		currentMsg->FindInt32("buttons", (int32 *)&buttons);

		uint32 modifiers = 0;
		currentMsg->FindInt32("modifiers", (int32 *)&modifiers);

		if ((buttons & B_SECONDARY_MOUSE_BUTTON) || (modifiers & B_CONTROL_KEY)) {
			// secondary button was clicked or control key was down, show menu and return

			BPopUpMenu *menu = new BPopUpMenu(B_TRANSLATE("Info"));
			menu->SetFont(be_plain_font);
			BuildInfoMenu(menu);

			BMenuItem *selected = menu->Go(ConvertToScreen(where));
			if (selected)
				Window()->PostMessage(selected->Message()->what);
			delete menu;
			return;
		}

		// add a mousedown looper here

		int32 pixelSize = PixelSize();
		float x = where.x / pixelSize;
		float y = where.y / pixelSize;

		MoveSelectionTo(x, y);

		// draw the frozen image
		// update the info region

		fNeedToUpdate = true;
		Invalidate();
	}
}