Ejemplo n.º 1
0
void Canvas::OnMouse(wxMouseEvent& evt)
{
	// Capture on button-down, so we can respond even when the mouse
	// moves off the window
	if (!m_MouseCaptured && evt.ButtonDown())
	{
		m_MouseCaptured = true;
		CaptureMouse();
	}
	// Un-capture when all buttons are up
	else if (m_MouseCaptured && evt.ButtonUp() &&
		! (evt.ButtonIsDown(wxMOUSE_BTN_LEFT) || evt.ButtonIsDown(wxMOUSE_BTN_MIDDLE) || evt.ButtonIsDown(wxMOUSE_BTN_RIGHT))
		)
	{
		m_MouseCaptured = false;
		ReleaseMouse();
	}

	// Set focus when clicking
	if (evt.ButtonDown())
		SetFocus();

	// Reject motion events if the mouse has not actually moved
	if (evt.Moving() || evt.Dragging())
	{
		if (m_LastMousePos == evt.GetPosition())
			return;
		m_LastMousePos = evt.GetPosition();
	}

	HandleMouseEvent(evt);
}
Ejemplo n.º 2
0
 void StyledTextBox::OnMouseMoved(wxMouseEvent& mouseEvent) {
     if (mouseEvent.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
         EnsureSelectionStarted();
         SetSelectionEnd(FindCursorIndexFromPoint(mouseEvent.GetX()));
         pimpl->cursorPosition = pimpl->selectionEndIndex;
         Refresh();
     }
 }
Ejemplo n.º 3
0
void MiniStyledTextCtrl::OnMouseMove(wxMouseEvent& event)
{
    if(event.ButtonIsDown(wxMOUSE_BTN_LEFT))
    {
        int line = GetLineFromPosition(event.GetPosition());
        MiniStyledTextCtrlLineClickedEvent evt(MiniStyledTextCtrlCommandEvent, GetId());
        evt.SetLine(line);
        wxPostEvent(this, evt);
    }
}
Ejemplo n.º 4
0
void CtrlRegisterList::mouseEvent(wxMouseEvent& evt)
{
	if (evt.GetEventType() == wxEVT_RIGHT_UP)
	{
		int y = evt.GetPosition().y;

		if (y >= rowHeight)
		{
			int row = (y-rowHeight)/rowHeight;
			if (row != currentRows[category] && row < cpu->getRegisterCount(category))
				setCurrentRow(row);
		}
		
		PopupMenu(&menu,evt.GetPosition());
		return;
	}

	if (evt.ButtonIsDown(wxMOUSE_BTN_LEFT) || evt.ButtonIsDown(wxMOUSE_BTN_RIGHT))
	{
		int x = evt.GetPosition().x;
		int y = evt.GetPosition().y;

		if (y < rowHeight)
		{
			int piece = GetSize().x/cpu->getRegisterCategoryCount();
			int cat = x/piece;

			if (cat != category)
			{
				category = cat;
				Refresh();
			}
		} else {
			int row = (y-rowHeight)/rowHeight;
			if (row != currentRows[category] && row < cpu->getRegisterCount(category))
				setCurrentRow(row);
		}

		SetFocus();
		SetFocusFromKbd();
	}
}
Ejemplo n.º 5
0
void wxVideoTerminal::OnMouseMove(wxMouseEvent &evt)
{
	if (evt.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
		m_ptEndSelect.x = evt.GetPosition().x/m_font_size.GetWidth() ;
		m_ptEndSelect.y = evt.GetPosition().y/m_font_size.GetHeight() +m_scrollpos_row;
		
		m_isSelecting = true;
		m_redraw_bitmap = true;
		Refresh(false);
	}
}
Ejemplo n.º 6
0
void VideoSlider::OnMouse(wxMouseEvent &event) {
	int x = event.GetX();

	if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
		// If the slider didn't already have focus, don't seek if the user
		// clicked very close to the current location as they were probably
		// just trying to focus the slider
		if (wxWindow::FindFocus() != this && abs(x - GetXAtValue(val)) < 4) {
			SetFocus();
			return;
		}

		// Shift click to snap to keyframe
		if (event.m_shiftDown) {
			int clickedFrame = GetValueAtX(x);
			std::vector<int>::const_iterator pos = lower_bound(keyframes.begin(), keyframes.end(), clickedFrame);
			if (pos == keyframes.end())
				--pos;
			else if (pos + 1 != keyframes.end() && clickedFrame - *pos > (*pos + 1) - clickedFrame)
				++pos;

			if (*pos == val) return;
			SetValue(*pos);
		}

		// Normal click
		else {
			int go = GetValueAtX(x);
			if (go == val) return;
			SetValue(go);
		}

		if (c->videoController->IsPlaying()) {
			c->videoController->Stop();
			c->videoController->JumpToFrame(val);
			c->videoController->Play();
		}
		else
			c->videoController->JumpToFrame(val);
		SetFocus();
		return;
	}

	if (event.ButtonDown(wxMOUSE_BTN_RIGHT) || event.ButtonDown(wxMOUSE_BTN_MIDDLE)) {
		SetFocus();
	}

	else if (!c->videoController->IsPlaying())
		event.Skip();
}
void TerrainTilesPanel::OnMouse(wxMouseEvent& event, const ion::Vector2i& mouseDelta)
{
	ViewPanel::OnMouse(event, mouseDelta);

	const int tileWidth = m_project.GetPlatformConfig().tileWidth;
	const int tileHeight = m_project.GetPlatformConfig().tileHeight;

	//Camera pan Y (if canvas is taller than panel)
	if((m_canvasSize.y * tileHeight) > (m_panelSize.y / m_cameraZoom))
	{
		float panDeltaY = 0.0f;

		if(event.Dragging() && event.ButtonIsDown(wxMOUSE_BTN_MIDDLE))
		{
			panDeltaY = mouseDelta.y;
		}
		else if(event.GetWheelRotation() != 0)
		{
			panDeltaY = (float)event.GetWheelRotation();
		}

		if(panDeltaY != 0.0f)
		{
			ion::Vector3 cameraPos = m_camera.GetPosition();
			cameraPos.y += panDeltaY * m_cameraPanSpeed / m_cameraZoom;

			//Clamp to size
			float halfCanvas = (m_canvasSize.y * (tileHeight / 2.0f));
			float minY = -halfCanvas;
			float maxY = halfCanvas - ((float)m_panelSize.y / m_cameraZoom);

			if(cameraPos.y > maxY)
				cameraPos.y = maxY;
			else if(cameraPos.y < minY)
				cameraPos.y = minY;

			m_camera.SetPosition(cameraPos);

			Refresh();
		}
	}
}
Ejemplo n.º 8
0
void AButton::OnMouseEvent(wxMouseEvent & event)
{
    wxSize clientSize = GetClientSize();
    AButtonState prevState = GetState();

    if (event.Entering())
        mCursorIsInWindow = true;
    else if (event.Leaving())
        mCursorIsInWindow = false;
    else
        mCursorIsInWindow =
            (event.m_x >= 0 && event.m_y >= 0 &&
             event.m_x < clientSize.x && event.m_y < clientSize.y);

    if (HasAlternateImages() && !mButtonIsDown)
        mAlternate = event.ShiftDown();

    if (mEnabled && event.IsButton()) {
        if (event.ButtonIsDown(wxMOUSE_BTN_ANY)) {
            mIsClicking = true;
            CaptureMouse();
        }
        else if (mIsClicking) {
            mIsClicking = false;

            if (HasCapture())
                ReleaseMouse();

            if (mCursorIsInWindow && (mToggle || !mButtonIsDown)) {
                if (mToggle)
                    mButtonIsDown = !mButtonIsDown;
                else
                    mButtonIsDown = true;

                mWasShiftDown = event.ShiftDown();
                mWasControlDown = event.ControlDown();

                Click();
            }
        }
    }

    // Only redraw and change tooltips if the state has changed.
    AButtonState newState = GetState();

    if (newState != prevState) {
        Refresh(false);

        if (mCursorIsInWindow) {
#if wxUSE_TOOLTIPS // Not available in wxX11
            // Display the tooltip in the status bar
            wxToolTip * pTip = this->GetToolTip();
            if( pTip ) {
                wxString tipText = pTip->GetTip();
                if (!mEnabled)
                    tipText += _(" (disabled)");
                GetActiveProject()->TP_DisplayStatusMessage(tipText);
            }
#endif
        }
        else {
            GetActiveProject()->TP_DisplayStatusMessage(wxT(""));
        }
    }
}
Ejemplo n.º 9
0
void AButton::OnMouseEvent(wxMouseEvent & event)
{
   wxSize clientSize = GetClientSize();
   AButtonState prevState = GetState();

   if (event.Entering()) {
      // Bug 1201:  On Mac, unsetting and re-setting the tooltip may be needed
      // to make it pop up when we want it.
      auto text = GetToolTipText();
      UnsetToolTip();
      SetToolTip(text);
      mCursorIsInWindow = true;
   }
   else if (event.Leaving())
      mCursorIsInWindow = false;
   else
      mCursorIsInWindow =
         (event.m_x >= 0 && event.m_y >= 0 &&
          event.m_x < clientSize.x && event.m_y < clientSize.y);

   if (mEnabled && event.IsButton()) {
      if (event.ButtonIsDown(wxMOUSE_BTN_ANY)) {
         mIsClicking = true;
         if (event.ButtonDClick())
            mIsDoubleClicked = true;
         if( !HasCapture() )
            CaptureMouse();
      }
      else if (mIsClicking) {
         mIsClicking = false;

         if (HasCapture())
            ReleaseMouse();

         if (mCursorIsInWindow && (mToggle || !mButtonIsDown)) {
            if (mToggle)
               mButtonIsDown = !mButtonIsDown;
            else
               mButtonIsDown = true;

            mWasShiftDown = event.ShiftDown();
            mWasControlDown = event.ControlDown();

            Click();
         }
      }
   }

   // Only redraw and change tooltips if the state has changed.
   AButtonState newState = GetState();

   if (newState != prevState) {
      Refresh(false);

      if (mCursorIsInWindow)
         UpdateStatus();
      else {
         GetActiveProject()->TP_DisplayStatusMessage(wxT(""));
      }
   }
   else
      event.Skip();
}
Ejemplo n.º 10
0
void CtrlRegisterList::mouseEvent(wxMouseEvent& evt)
{
	int xOffset, yOffset;
	((wxScrolledWindow*) this)->GetViewStart(&xOffset, &yOffset);

	wxClientDC dc(this);
	wxPoint pos = evt.GetPosition();
	int x = dc.DeviceToLogicalX(pos.x) + xOffset;
	int y = dc.DeviceToLogicalY(pos.y) + yOffset * rowHeight;

	if (evt.GetEventType() == wxEVT_RIGHT_UP)
	{
		if (y >= rowHeight)
		{
			int row = (y-rowHeight)/rowHeight;
			if (row != currentRows[category] && row < cpu->getRegisterCount(category))
				setCurrentRow(row);
		}

		wxMenu menu;
		int bits = cpu->getRegisterSize(category);

		menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY32,		L"Display 32 bit");
		menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY64,		L"Display 64 bit");
		menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY128,	L"Display 128 bit");
		menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY128STRINGS,	L"Display 128 bit + Resolve string pointers");
		menu.AppendSeparator();

		if (bits >= 64)
		{
			menu.Append(ID_REGISTERLIST_CHANGELOWER,	L"Change lower 64 bit");
			menu.Append(ID_REGISTERLIST_CHANGEUPPER,	L"Change upper 64 bit");
		} else {
			menu.Append(ID_REGISTERLIST_CHANGEVALUE,	L"Change value");
		}

		menu.AppendSeparator();
		menu.Append(ID_REGISTERLIST_GOTOINMEMORYVIEW, L"Follow in Memory view");
		menu.Append(ID_REGISTERLIST_GOTOINDISASM, L"Follow in Disasm");

		switch (maxBits)
		{
		case 128:
			if (resolvePointerStrings)
				menu.Check(ID_REGISTERLIST_DISPLAY128STRINGS, true);
			else
				menu.Check(ID_REGISTERLIST_DISPLAY128,true);
			break;
		case 64:
			menu.Check(ID_REGISTERLIST_DISPLAY64,true);
			break;
		case 32:
			menu.Check(ID_REGISTERLIST_DISPLAY32,true);
			break;
		}

		menu.Bind(wxEVT_MENU, &CtrlRegisterList::onPopupClick, this);
		PopupMenu(&menu,evt.GetPosition());
		return;
	}

	if (evt.ButtonIsDown(wxMOUSE_BTN_LEFT) || evt.ButtonIsDown(wxMOUSE_BTN_RIGHT))
	{
		if (y < rowHeight)
		{
			int piece = GetSize().x/cpu->getRegisterCategoryCount();
			int cat = std::min<int>(x/piece,cpu->getRegisterCategoryCount()-1);

			if (cat != category)
			{
				category = cat;
				Refresh();
			}
		} else {
			int row = (y-rowHeight)/rowHeight;
			if (row != currentRows[category] && row < cpu->getRegisterCount(category))
				setCurrentRow(row);
		}

		SetFocus();
		SetFocusFromKbd();
	}
}
void 
GlCanvas::OnMouseMove (wxMouseEvent& event)
{

	static bool first = true; // Can't be here!

	if (!event.ButtonIsDown (wxMOUSE_BTN_LEFT)) {
		return;
	}

	if (!m_tracking)
		return;

	_setCamera();
	if (0 == m_pCamera) {
		return;
	}
	
	vec4 camView = m_pCamera->getPropfv(Camera::NORMALIZED_VIEW_VEC);
	vec4 camPosition = m_pCamera->getPropfv(Camera::POSITION);

	if (true == m_tracking) {
		m_OldCamView.set(camView.x, camView.y, camView.z);
	}

	newX = event.GetX();
	newY = event.GetY();

	float m_ScaleFactor = 1.0f / 100.0f;

	m_Alpha = m_AlphaAux - (float)(newX - OldX) * m_ScaleFactor;
	m_Beta = m_BetaAux + (float)(OldY - newY) * m_ScaleFactor;
/*	if (m_Beta > 1.5f) 
		m_Beta = 1.5f;
	else if (m_Beta < -1.5f)
		m_Beta = -1.5f;
*/
	curitiba::event_::CameraOrientation c(m_Alpha, m_Beta);
	curitiba::event_::IEventData *e= curitiba::event_::EventFactory::create("Camera Orientation");
	e->setData(&c);
	EVENTMANAGER->notifyEvent("CAMERA_ORIENTATION", "MainCanvas", "", e);
	delete e;

	/*
	camView.x = cos(m_Beta) * sin(m_Alpha);
	camView.z = cos(m_Beta) * cos(m_Alpha);
	camView.y = sin(m_Beta);
	*/

	camV.x = cos(m_Beta) * sin(m_Alpha);;
	camV.y = sin(m_Beta);
	camV.z = cos(m_Beta) * cos(m_Alpha);

	if (!(true == m_tracking)) {
//		m_OldCamView.set (camView.x, camView.y, camView.z);
		m_tracking = true;
	}
	DlgCameras::Instance()->updateInfo(m_pCamera->getName());

	event.Skip ();
}
Ejemplo n.º 12
0
////////////////
// Mouse events
void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
	// Window size
	int w,h;
	GetClientSize(&w,&h);

	// Modifiers
	bool shift = event.m_shiftDown;
	bool alt = event.m_altDown;
	bool ctrl = event.m_controlDown;

	// Row that mouse is over
	bool click = event.ButtonDown(wxMOUSE_BTN_LEFT);
	bool dclick = event.LeftDClick();
	int row = event.GetY()/lineHeight + yPos - 1;
	if (holding && !click) {
		row = MID(0,row,GetRows()-1);
	}
	bool validRow = row >= 0 && row < GetRows();
	if (!validRow) row = -1;

	// Get focus
	if (event.ButtonDown()) {
		if (Options.AsBool(_T("Grid Allow Focus"))) {
			SetFocus();
		}
	}

	// Click type
	if (click && !holding && validRow) {
		holding = true;
		CaptureMouse();
	}
	if (!event.ButtonIsDown(wxMOUSE_BTN_LEFT) && holding) {
		holding = false;
		ReleaseMouse();
	}

	// Scroll to keep visible
	if (holding) {
		// Find direction
		int minVis = yPos+1;
		int maxVis = yPos+h/lineHeight-3;
		int delta = 0;
		if (row < minVis) delta = -1;
		if (row > maxVis) delta = +1;

		// Scroll
		ScrollTo(yPos+delta*3);
	}

	// Click
	if ((click || holding || dclick) && validRow) {
		// Disable extending
		extendRow = -1;

		// Toggle selected
		if (click && ctrl && !shift && !alt) {
			SelectRow(row,true,!IsInSelection(row,0));
			parentFrame->UpdateToolbar();
			return;
		}

		// Normal click
		if ((click || dclick) && !shift && !ctrl && !alt) {
			if (editBox->linen != row) editBox->SetToLine(row);
			if (dclick) video->JumpToFrame(VFR_Output.GetFrameAtTime(GetDialogue(row)->Start.GetMS(),true));
			SelectRow(row,false);
			parentFrame->UpdateToolbar();
			lastRow = row;
			return;
		}

		// Keep selection
		if (click && !shift && !ctrl && alt) {
			editBox->SetToLine(row);
			return;
		}

		// Block select
		if ((click && shift && !ctrl && !alt) || (holding && !ctrl && !alt && !shift)) {
			if (lastRow != -1) {
				// Set boundaries
				int i1 = row;
				int i2 = lastRow;
				if (i1 > i2) {
					int aux = i1;
					i1 = i2;
					i2 = aux;
				}

				// Toggle each
				bool notFirst = false;
				for (int i=i1;i<=i2;i++) {
					SelectRow(i,notFirst,true);
					notFirst = true;
				}
				parentFrame->UpdateToolbar();
			}
			return;
		}

		return;
	}

	// Popup
	if (event.ButtonDown(wxMOUSE_BTN_RIGHT)) {
		OnPopupMenu();
	}

	// Mouse wheel
	if (event.GetWheelRotation() != 0) {
		int step = 3 * event.GetWheelRotation() / event.GetWheelDelta();
		ScrollTo(yPos - step);
		return;
	}

	event.Skip();
}
Ejemplo n.º 13
0
void CollisionTypePanel::OnMouse(wxMouseEvent& event)
{
	if(m_project)
	{
		//Get mouse position in map space
		wxClientDC clientDc(this);
		wxPoint mouseCanvasPosWx = event.GetLogicalPosition(clientDc);
		ion::Vector2 mousePosMapSpace(mouseCanvasPosWx.x, mouseCanvasPosWx.y);

		//Get panel size
		wxSize panelSize = GetClientSize();

		const int maxCollisionTypesPerLayer = 16;

		float x = (m_orientation == eVertical) ? mousePosMapSpace.y : mousePosMapSpace.x;
		float y = (m_orientation == eVertical) ? mousePosMapSpace.x : mousePosMapSpace.y;
		float rectSize = (m_orientation == eVertical) ? (panelSize.y / maxCollisionTypesPerLayer) : (panelSize.x / maxCollisionTypesPerLayer);

		//Get current selection
		unsigned int collisionTypeIndex = (unsigned int)floor(x / rectSize);
		unsigned int collisionLayerId = (unsigned int)floor(y / rectSize);

		//TODO: Multiple layers
		const int numCollisionLayers = 1;

		int iconX = (m_orientation == eVertical) ? collisionTypeIndex : collisionLayerId;
		int iconY = (m_orientation == eVertical) ? collisionLayerId : collisionTypeIndex;
		wxRect rect(iconX * rectSize, iconY * rectSize, rectSize, rectSize);

		u32 collisionBit = 1 << collisionTypeIndex;

		if(collisionLayerId < numCollisionLayers && collisionTypeIndex < maxCollisionTypesPerLayer)
		{
			CollisionType* collisionType = m_project->GetCollisionType(collisionBit);

			if(event.LeftDClick())
			{
				//Create new
				if(!collisionType)
				{
					collisionType = m_project->AddCollisionType(collisionBit);
				}

				//Set default image
				wxImage image(qmark_16_16_xpm);

				//Open image file
				wxFileDialog dialogue(this, _("Open Image file"), "", "", "BMP files (*.bmp)|*.bmp", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
				if(dialogue.ShowModal() == wxID_OK)
				{
					if(image.LoadFile(dialogue.GetPath()))
					{
						if(image.GetWidth() != sIconWidth || image.GetHeight() != sIconHeight)
						{
							wxMessageBox("Image must be 16x16", "Error", wxOK | wxICON_ERROR);
						}
					}
				}

				//Set icon data
				const int bytesPerPixel = 3;
				int imageSize = sIconWidth * sIconHeight * bytesPerPixel;
				collisionType->iconData.resize(imageSize);
				unsigned char* imageData = image.GetData();
				ion::memory::MemCopy(&collisionType->iconData[0], imageData, imageSize);

				//Create bitmap for rendering
				if(m_icons.size() < collisionTypeIndex + 1)
					m_icons.resize(collisionTypeIndex + 1);
				m_icons[collisionTypeIndex] = wxBitmap(image, wxBITMAP_SCREEN_DEPTH);

				//Recreate collision types texture
				m_mainWindow->RefreshCollisionTypes();

				//Invalidate collision types
				m_project->InvalidateCollisionTypes(true);

				//Refresh this panel
				Refresh();

				//Refresh collision tile editor panel
				m_mainWindow->RefreshPanel(MainWindow::ePanelTerrainTileEditor);
			}

			if(collisionTypeIndex < m_project->GetCollisionTypeCount())
			{
				if(CollisionType* collisionType = m_project->GetCollisionType(1 << collisionTypeIndex))
				{
					if(!m_tooltip.get())
					{
						//m_tooltip = new wxTipWindow(this, "Test Tooltip", 100, NULL, &rect);
						//m_tooltip->Show();
					}

					if(event.ButtonIsDown(wxMOUSE_BTN_LEFT))
					{
						//Set current collision type
						m_project->SetPaintCollisionType(collisionType);
					}
				}
			}
		}
	}

	event.Skip();
}
Ejemplo n.º 14
0
void 
GLCanvas::OnMouseMove (wxMouseEvent& event) {

	if (m_pEngine->mouseMotion(event.GetX(), event.GetY()))
		return;

	static bool first = true; // Can't be here!

	if (event.ButtonIsDown (wxMOUSE_BTN_LEFT)) {
		if (!m_tracking)
			return;

		_setCamera();
		if (0 == m_pCamera) {
			return;
		}
	
		vec4 camView = m_pCamera->getPropf4(Camera::VIEW_VEC);
		vec4 camPosition = m_pCamera->getPropf4(Camera::POSITION);
		vec4 camRight = m_pCamera->getPropf4(Camera::NORMALIZED_RIGHT_VEC);
		vec4 camUp = m_pCamera->getPropf4(Camera::NORMALIZED_UP_VEC);

		newX = event.GetX();
		newY = event.GetY();

		float m_ScaleFactor = 1.0f / 100.0f;

		m_Alpha = m_AlphaAux - (float)(newX - m_OldX) * m_ScaleFactor;
		m_Beta = m_BetaAux + (float)(m_OldY - newY) * m_ScaleFactor;

		//nau::event_::CameraOrientation c(m_Alpha, m_Beta);
		//nau::event_::IEventData *e= nau::event_::EventFactory::create("Camera Orientation");
		//e->setData(&c);
		//EVENTMANAGER->notifyEvent("CAMERA_ORIENTATION", "MainCanvas", "", e);
		//delete e;
		//vec4 camView;

		if (m_Beta > M_PI * 0.48)
			m_Beta = (float)M_PI * 0.48f;
		else if (m_Beta < -M_PI * 0.48)
			m_Beta =  -(float)M_PI * 0.48f;
		camView.x = cos(m_Beta) * sin(m_Alpha);;
		camView.y = sin(m_Beta);
		camView.z = cos(m_Beta) * cos(m_Alpha);
		camView.w = 0;
//		vec4 up = camRight.cross(camView);
		m_pCamera->setCamera(vec3(camPosition.x, camPosition.y, camPosition.z),
							vec3(camView.x, camView.y, camView.z),
							vec3(0,1,0));

		DlgCameras::Instance()->updateInfo(m_pCamera->getName());

		event.Skip ();
	}
	else if (event.ButtonIsDown(wxMOUSE_BTN_RIGHT)) {
		if (!m_tracking)
			return;

		_setCamera();
		if (0 == m_pCamera) {
			return;
		}
		newX = event.GetX();
		newY = event.GetY();

		float m_ScaleFactor = 1.0f / 100.0f;

		m_Alpha = m_AlphaAux + (float)(newX - m_OldX) * m_ScaleFactor;
		m_Beta = m_BetaAux - (float)(m_OldY - newY) * m_ScaleFactor;

		//nau::event_::CameraOrientation c(m_Alpha, m_Beta);
		//nau::event_::IEventData *e= nau::event_::EventFactory::create("Camera Orientation");
		//e->setData(&c);
		//EVENTMANAGER->notifyEvent("CAMERA_ORIENTATION", "MainCanvas", "", e);
		//delete e;
		//vec4 camView;

		vec4 dir;
		if (m_Beta > M_PI * 0.48)
			m_Beta = (float)M_PI * 0.48f;
		else if (m_Beta < -M_PI * 0.48)
			m_Beta = -(float)M_PI * 0.48f;
		dir.x = cos(m_Beta) * sin(m_Alpha);;
		dir.y = sin(m_Beta);
		dir.z = cos(m_Beta) * cos(m_Alpha);
		dir.scale(-m_Radius);
		vec4 camPos = m_Center;
		camPos += dir;
		//		vec4 up = camRight.cross(camView);
		m_pCamera->setCamera(vec3(camPos.x, camPos.y, camPos.z),
			vec3(m_Center.x - camPos.x, m_Center.y - camPos.y, m_Center.z - camPos.z),
			vec3(0, 1, 0));

		DlgCameras::Instance()->updateInfo(m_pCamera->getName());

		event.Skip();

	}

}
Ejemplo n.º 15
0
////////////////
// Mouse events
void VideoSlider::OnMouse(wxMouseEvent &event) {
	// Coordinates
	int x = event.GetX();
	int y = event.GetY();
	bool shift = event.m_shiftDown;

	// Left click
	if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
		// Check if it's OK to drag
		bool canDrag = wxWindow::FindFocus() == this;
		if (!canDrag) {
			int tolerance = 4;
			int curX = GetXAtValue(GetValue());
			if (x-curX < -tolerance || x-curX > tolerance) canDrag = true;
		}

		// Drag
		if (canDrag) {
			// Shift click to snap to keyframe
			if (shift && Display) {
				wxArrayInt KeyFrames = Display->GetKeyFrames();
				int keys = KeyFrames.Count();
				int clickedFrame = GetValueAtX(x);
				int closest = 0;
				int cur;

				// Find closest
				for (int i=0;i<keys;i++) {
					cur = KeyFrames[i];
					if (abs(cur-clickedFrame) < abs(closest-clickedFrame)) {
						closest = cur;
					}
				}

				// Jump to frame
				if (closest == GetValue()) return;
				SetValue(closest);
			}

			// Normal click
			else {
				int go = GetValueAtX(x);
				if (go == GetValue()) return;
				SetValue(go);
			}
			Refresh(false);

			// Playing?
			if (Display->IsPlaying) {
				Display->Stop();
				UpdateVideo();
				Display->Play();
			}
			else UpdateVideo();
		}

		// Get focus
		SetFocus();
	}

	// Right/middle click
	if (event.ButtonDown(wxMOUSE_BTN_RIGHT) || event.ButtonDown(wxMOUSE_BTN_MIDDLE)) {
		SetFocus();
	}

	// Something else
	else if (!Display->IsPlaying) event.Skip();
}