void IGraphics::OnMouseDown(int x, int y, IMouseMod* pMod) { ReleaseMouseCapture(); int c = GetMouseControlIdx(x, y); if (c >= 0) { mMouseCapture = c; mMouseX = x; mMouseY = y; IControl* pControl = mControls.Get(c); int paramIdx = pControl->ParamIdx(); #if defined OS_WIN || defined VST3_API // on Mac, IGraphics.cpp is not compiled in a static library, so this can be #ifdef'd if (mPlug->GetAPI() == kAPIVST3) { if (pMod->R && paramIdx >= 0) { ReleaseMouseCapture(); mPlug->PopupHostContextMenuForParam(paramIdx, x, y); return; } } #endif #ifdef AAX_API if (mAAXViewContainer && paramIdx >= 0) { uint32_t mods = GetAAXModifiersFromIMouseMod(pMod); #ifdef OS_WIN // required to get start/windows and alt keys uint32_t aaxViewMods = 0; mAAXViewContainer->GetModifiers(&aaxViewMods); mods |= aaxViewMods; #endif WDL_String paramID; paramID.SetFormatted(32, "%i", paramIdx+1); if (mAAXViewContainer->HandleParameterMouseDown(paramID.Get(), mods) == AAX_SUCCESS) { return; // event handled by PT } } #endif if (paramIdx >= 0) { mPlug->BeginInformHostOfParamChange(paramIdx); } pControl->OnMouseDown(x, y, pMod); } }
bool DesktopWindowManager::HandleMouseEvent( view::Widget* widget, const view::MouseEvent& event) { if(mouse_capture_) { view::MouseEvent translated(event, widget->GetRootView(), mouse_capture_->GetRootView()); mouse_capture_->OnMouseEvent(translated); return true; } if(event.type() == ui::ET_MOUSE_PRESSED) { ActivateWidgetAtLocation(widget, event.location()); } else if(event.type()==ui::ET_MOUSEWHEEL && active_widget_) { return active_widget_->OnMouseEvent(event); } if(window_controller_.get()) { if(!window_controller_->OnMouseEvent(event)) { ReleaseMouseCapture(); window_controller_.reset(); } return true; } return false; }
void Button::OnMouseLeftButtonUp(MouseButtonEventArgs* args) { if (get_IsMouseCaptured()) { ReleaseMouseCapture(); RaiseEvent(new RoutedEventArgs(get_ClickEvent(), this)); } }
void IGraphics::Resize(int w, int h) { // The OS implementation class has to do all the work, then call up to here. mWidth = w; mHeight = h; ReleaseMouseCapture(); mControls.Empty(true); mPlug->ResizeGraphics(w, h); }
void Thumb::handleEvent(Event* evt) { StringW* type = evt->get_type(); if (evt->get_eventPhase() != CAPTURING_PHASE) { if (type == MouseEvent::mousedown) { MouseEvent* mouseevt = static_cast<MouseEvent*>(evt); if (!m_dragging) { CaptureMouse(); m_dragging = true; m_oldpoint = LDraw::PointD(mouseevt->get_ScreenX(), mouseevt->get_ScreenY()); } // OnLButtonDown(static_cast<MouseEvent*>(evt)); evt->stopPropagation(); } else if (type == MouseEvent::mouseup) { if (m_dragging) { ReleaseMouseCapture(); m_dragging = false; } // OnLButtonUp(static_cast<MouseEvent*>(evt)); evt->stopPropagation(); } else if (type == MouseEvent::mousemove) { MouseEvent* mouseevt = static_cast<MouseEvent*>(evt); //LDraw::PointD point = ScreenToClient(evt->get_ScreenX(), evt->get_ScreenY()); LDraw::PointD point(mouseevt->get_ScreenX(), mouseevt->get_ScreenY()); if (m_dragging) { DragDeltaEvent* dragevent = new DragDeltaEvent; dragevent->InitEvent(WSTR("DragDelta"), true, true); dragevent->m_HorizontalChange = point.X - m_oldpoint.X; dragevent->m_VerticalChange = point.Y - m_oldpoint.Y; m_oldpoint = point; dispatchEvent(dragevent); } // OnMouseMove(static_cast<MouseEvent*>(evt)); evt->stopPropagation(); } } }
void IGraphics::Resize(int w, int h) { mWidth = w; mHeight = h; ReleaseMouseCapture(); mControls.Empty(true); DELETE_NULL(mDrawBitmap); DELETE_NULL(mTmpBitmap); PrepDraw(); mPlug->ResizeGraphics(w, h); }
bool DesktopWindowManager::ReleaseMouseCapture(view::Widget* widget) { if(!widget || mouse_capture_!=widget) { return false; } DCHECK(HasMouseCapture()); ReleaseMouseCapture(); mouse_capture_ = NULL; return true; }
void Thumb::OnMouseUp(MouseButtonEventArgs* args) { if (m_dragging) { ReleaseMouseCapture(); set_IsDragging(false); m_dragging = false; } args->set_Handled(true); }
void IGraphics::OnMouseDown(int x, int y, IMouseMod* pMod) { ReleaseMouseCapture(); int c = GetMouseControlIdx(x, y); if (c >= 0) { mMouseCapture = c; mMouseX = x; mMouseY = y; IControl* pControl = mControls.Get(c); pControl->OnMouseDown(x, y, pMod); int paramIdx = pControl->ParamIdx(); if (paramIdx >= 0) { mPlug->BeginInformHostOfParamChange(paramIdx); } } }
bool IGraphics::OnMouseDblClick(int x, int y, IMouseMod* pMod) { ReleaseMouseCapture(); bool newCapture = false; int c = GetMouseControlIdx(x, y); if (c >= 0) { IControl* pControl = mControls.Get(c); if (pControl->MouseDblAsSingleClick()) { mMouseCapture = c; mMouseX = x; mMouseY = y; pControl->OnMouseDown(x, y, pMod); newCapture = true; } else { pControl->OnMouseDblClick(x, y, pMod); } } return newCapture; }
void Control::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType() != Type::CONTROL) { FrameworkElement::OnPropertyChanged (args, error); return; } if (args->GetId () == Control::TemplateProperty) { if (GetSubtreeObject ()) ElementRemoved ((UIElement *) GetSubtreeObject ()); InvalidateMeasure (); } else if (args->GetId () == Control::PaddingProperty || args->GetId () == Control::BorderThicknessProperty) { InvalidateMeasure (); } else if (args->GetId () == Control::IsEnabledProperty) { if (!args->GetNewValue ()->AsBool ()) { Surface *surface = Deployment::GetCurrent ()->GetSurface (); if (surface && surface->GetFocusedElement () == this) { // Ensure this element loses focus, then try to focus the next suitable element surface->FocusElement (NULL); TabNavigationWalker::Focus (this, true); } ReleaseMouseCapture (); } PropertyChangedEventArgs *pargs = new PropertyChangedEventArgs (args->GetProperty(), args->GetId (), args->GetOldValue(), args->GetNewValue()); EmitAsync (IsEnabledChangedEvent, pargs); } else if (args->GetId () == Control::HorizontalContentAlignmentProperty || args->GetId () == Control::VerticalContentAlignmentProperty) { InvalidateArrange (); } NotifyListenersOfPropertyChange (args, error); }
// // ICWindowTitle::HandleEvent // U32 ICWindowTitle::HandleEvent(Event &e) { if (e.type == Input::EventID()) { // Input events switch (e.subType) { case Input::MOUSEBUTTONDOWN: case Input::MOUSEBUTTONDBLCLK: { if (e.input.code == Input::LeftButtonCode()) { // Don't move window if it has immovable style ICWindow *parentWnd = IFace::Promote<ICWindow>(parent); if (parentWnd && !(parentWnd->GetWinStyle() & ICWindow::STYLE_IMMOVABLE)) { // Take mouse capture GetMouseCapture(); // Raise window SendNotify(parent, ICWindowMsg::Raise, FALSE); // Start dragging dragPos = Point<S32>(e.input.mouseX, e.input.mouseY); } } break; } case Input::MOUSEBUTTONUP: case Input::MOUSEBUTTONDBLCLKUP: { if (e.input.code == Input::LeftButtonCode()) { // Release mouse capture if (HasMouseCapture()) { ReleaseMouseCapture(); } // Handled return (TRUE); } // Not handled break; } case Input::MOUSEMOVE: { if (HasMouseCapture()) { ASSERT(parent); // Track the mouse Point<S32> mouse = Point<S32>(e.input.mouseX, e.input.mouseY); Point<S32> newPos = parent->GetPos() + mouse - dragPos; parent->MoveTo(newPos); dragPos = mouse; // Don't allow button to process this return (TRUE); } break; } } } // This event can't be handled by this control, so pass it to the parent class return (IControl::HandleEvent(e)); }
// // HandleEvent // // Passes events through to the user // U32 ICGrid::HandleEvent(Event &e) { if (e.type == Input::EventID()) { // Input events switch (e.subType) { case Input::MOUSEBUTTONDOWN: case Input::MOUSEBUTTONDBLCLK: { // Is the click inside the client area if (InClient(Point<S32>(e.input.mouseX, e.input.mouseY))) { // Ignore if we already have capture if (IFace::GetCapture() != this) { // Grab capture GetMouseCapture(); // Save mouse code captureCode = e.input.code; } } break; } case Input::MOUSEBUTTONUP: case Input::MOUSEBUTTONDBLCLKUP: { if (HasMouseCapture() && e.input.code == captureCode) { ReleaseMouseCapture(); // Get mouse position relative to client window Point<S32> p = ScreenToClient(Point<S32>(e.input.mouseX, e.input.mouseY)); // Calculate the (flipped) cell positions U32 x = xFlip ? gridSize.x - (p.x / cellSize.x) - 1 : p.x / cellSize.x; U32 y = yFlip ? gridSize.y - (p.y / cellSize.y) - 1 : p.y / cellSize.y; // Set currently selected if (x < gridSize.x && y < gridSize.y) { selected.Set(x, y); } if (captureCode == Input::LeftButtonCode()) { CallEventHandler(0x90E4DA5D); // "LeftClick" } else if (captureCode == Input::MidButtonCode()) { CallEventHandler(0x316EC946); // "MiddleClick" } else if (captureCode == Input::RightButtonCode()) { CallEventHandler(0x173F5F78); // "RightClick" } return (TRUE); } break; } } } // Allow parent class to process this event return IControl::HandleEvent(e); }
IPopupMenu* IGraphicsWin::CreateIPopupMenu(IPopupMenu* pMenu, IRECT* pAreaRect) { ReleaseMouseCapture(); int numItems = pMenu->GetNItems(); POINT cPos; cPos.x = pAreaRect->L; cPos.y = pAreaRect->B; ClientToScreen(mPlugWnd, &cPos); HMENU hMenu = CreatePopupMenu(); int flags = 0; if(numItems && hMenu) { for(int i = 0; i< numItems;i++) { IPopupMenuItem* menuItem = pMenu->GetItem(i); if (menuItem->GetIsSeparator()) { AppendMenu (hMenu, MF_SEPARATOR, 0, 0); } else { const char* str = menuItem->GetText(); char* titleWithPrefixNumbers = 0; if (pMenu->GetPrefix()) { titleWithPrefixNumbers = (char*)malloc(strlen(str) + 50); switch (pMenu->GetPrefix()) { case 1: { sprintf(titleWithPrefixNumbers, "%1d: %s", i+1, str); break; } case 2: { sprintf(titleWithPrefixNumbers, "%02d: %s", i+1, str); break; } case 3: { sprintf(titleWithPrefixNumbers, "%03d: %s", i+1, str); break; } } } const char* entryText (titleWithPrefixNumbers ? titleWithPrefixNumbers : str); flags = MF_STRING; //if (nbEntries < 160 && _menu->getNbItemsPerColumn () > 0 && inc && !(inc % _menu->getNbItemsPerColumn ())) // flags |= MF_MENUBARBREAK; if (menuItem->GetSubmenu()) { // HMENU submenu = createMenu (item->getSubmenu (), offsetIdx); // if (submenu) // { // AppendMenu (menu, flags|MF_POPUP|MF_ENABLED, (UINT_PTR)submenu, (const TCHAR*)entryText); // } } else { if (menuItem->GetEnabled()) flags |= MF_ENABLED; else flags |= MF_GRAYED; if (menuItem->GetIsTitle()) flags |= MF_DISABLED; //if (multipleCheck && menuItem->GetChecked()) // flags |= MF_CHECKED; if (menuItem->GetChecked()) flags |= MF_CHECKED; else flags |= MF_UNCHECKED; //if (!(flags & MF_CHECKED)) // flags |= MF_UNCHECKED; AppendMenu(hMenu, flags, i+1, entryText); } if(titleWithPrefixNumbers) FREE_NULL(titleWithPrefixNumbers); } } int itemChosen = TrackPopupMenu(hMenu, TPM_LEFTALIGN/*|TPM_VCENTERALIGN*/|TPM_NONOTIFY|TPM_RETURNCMD, cPos.x, cPos.y, 0, mPlugWnd, 0); // IPopupMenu* chosenMenu; if (itemChosen > 0) { pMenu->SetChosenItemIdx(itemChosen - 1); DestroyMenu(hMenu); return pMenu; } else { DestroyMenu(hMenu); return 0; } } else return 0; }