bool Asnap::mouse(int x, int y, int state, int event) { switch(event) { case mouseLDOWN: control->select(); case mouseNORMAL: case mouseLUP: cursor(cursorHANDSEL); focus(this); { if(getKeyboardState()&keyboardLALT) { if(defpos!=-1) set(defpos); else set(0); father->notify(this, nyCHANGE); return true; } } switch(event) { case mouseLDOWN: mouseCapture(true); return true; case mouseLUP: { int xx=(x-X)/28; int yy=(y-Y)/18; if((xx>=0)&&(xx<4)&&(yy>=0)&&(yy<4)) { set(yy*4+xx); father->notify(this, nyCHANGE); repaint(); } mouseCapture(false); return TRUE; } break; } break; } return FALSE; }
void processCameraInput(SpectatorCamera* camera, float dt) { if (uiState != STATE_DEFAULT) { if (mouseIsCaptured()) mouseRelease(); return; } bool LCTRL_Down_LALT_Released = keyIsPressed (SDL_SCANCODE_LCTRL) && keyWasReleased(SDL_SCANCODE_LALT ); bool LALT_Down_LCTRL_Released = keyIsPressed (SDL_SCANCODE_LALT ) && keyWasReleased(SDL_SCANCODE_LCTRL); bool LALT_Released_LCTRL_Released = keyWasReleased(SDL_SCANCODE_LALT ) && keyWasReleased(SDL_SCANCODE_LCTRL); bool actionReleaseMouse = LCTRL_Down_LALT_Released || LALT_Down_LCTRL_Released || LALT_Released_LCTRL_Released; if (mouseWasPressed(SDL_BUTTON_LEFT)) { mouseCapture(); } else if (mouseIsCaptured() && actionReleaseMouse) { mouseRelease(); } else if (mouseIsCaptured()) { float dx = 0.0f, dy = 0.0f, dz = 0.0f; float heading = 0.0f; float pitch = 0.0f; dx += ui::keyIsPressed(SDL_SCANCODE_D)?1.0f:0.0f; dx -= ui::keyIsPressed(SDL_SCANCODE_A)?1.0f:0.0f; dy += ui::keyIsPressed(SDL_SCANCODE_E)?1.0f:0.0f; dy -= ui::keyIsPressed(SDL_SCANCODE_Q)?1.0f:0.0f; dz += ui::keyIsPressed(SDL_SCANCODE_W)?1.0f:0.0f; dz -= ui::keyIsPressed(SDL_SCANCODE_S)?1.0f:0.0f; pitch += ui::keyIsPressed(SDL_SCANCODE_KP_8)?1.50f:0.0f; pitch -= ui::keyIsPressed(SDL_SCANCODE_KP_5)?1.50f:0.0f; heading += ui::keyIsPressed(SDL_SCANCODE_KP_4)?1.50f:0.0f; heading -= ui::keyIsPressed(SDL_SCANCODE_KP_6)?1.50f:0.0f; camera->rotateSmoothly(heading * FLT_DEG_TO_RAD_SCALE, pitch * FLT_DEG_TO_RAD_SCALE); camera->rotateSmoothly((float)-ui::deltaX * FLT_DEG_TO_RAD_SCALE, (float)-ui::deltaY * FLT_DEG_TO_RAD_SCALE); camera->updatePosition(dx, dy, dz, dt); } }
bool AbrowserItem::mouse(int x, int y, int state, int event) { switch(event) { case mouseLDOWN: cursor(cursorHANDSEL); donedown=false; mouseCapture(true); test=true; if(!selected) donedown=setSel(state); return true; case mouseMOVE: if(indrag) { Awindow *w=getWindow(); if(w->NCdragdrop(w->mouseX, w->mouseY, dragdropFILE, dragdropOVER, NULL)) cursor(cursorCROSS); else cursor(cursorNO); } else if(test&&((x<0)||(y<0)||(x>pos.w)||(y>pos.h))) { if(selected) { test=false; donedown=false; father->father->notify(this, nyCOMMAND); indrag=true; } else cursor(cursorHANDSEL); } else { cursor(cursorHANDSEL); } return true; case mouseLUP: if(indrag) { Awindow *w=getWindow(); mouseCapture(false); indrag=false; w->NCdragdrop(w->mouseX, w->mouseY, dragdropFILE, dragdropDROP, dragFiles); free(dragFiles); dragFiles=NULL; } else if(test) { mouseCapture(false); if(!donedown) setSel(state); test=false; } return true; } return false; }
EDLL bool Apaddle::mouse(int x, int y, int state, int event) { switch(event) { case mouseLDOWN: control->select(); case mouseNORMAL: case mouseLUP: cursor(cursorHANDSEL); focus(this); { if(getKeyboardState()&keyboardLALT) { if((defxx!=-1)&&(defyy!=-1)) set(defxx, defyy); else if(defyy!=-1) set(0.f, defyy); else if(defxx!=-1) set(defxx, 0.f); else set(0.f, 0.f); father->notify(this, nyCHANGE); return true; } } switch(event) { case mouseLDOWN: mouseCapture(true); test=TRUE; x0=x; y0=y; xx0=xx; yy0=yy; break; } if(test&&(state&mouseL)) { switch(mode) { case paddleX: { float dy=0.05f*alib.mouseSensibility*(float)(y-y0); xx=mini(maxi(-dy+xx0+alib.mouseSensibility*(float)(x-x0), 0.f), 1.f); control->set(Acontrol::CONTROLER_01, xx); { char str[256]; sprintf(str, "%s [%1.2f]", tooltips?tooltips:"", xx); notify(this, nyTOOLTIPS, (dword)str); } } break; case paddleY: { int dxi=x-x0; int dyi=y-y0; if(abs(dxi)>=abs(dyi)) dyi=0; else dxi=0; float dx=0.05f*alib.mouseSensibility*(float)(dxi); float dy=alib.mouseSensibility*(float)(dyi); yy=mini(maxi(yy-dy+dx, 0.f), 1.f); control->set(Acontrol::CONTROLER_01, yy); { char str[256]; sprintf(str, "%s [%1.2f]", tooltips?tooltips:"", yy); notify(this, nyTOOLTIPS, (dword)str); } x0=x; y0=y; } break; case paddleXY: xx=mini(maxi(xx0+alib.mouseSensibility*(float)(x-x0), 0.f), 1.f); yy=mini(maxi(yy0-alib.mouseSensibility*(float)(y-y0), 0.f), 1.f); control->set(Acontrol::CONTROLER_01, xx); control->set(Acontrol::CONTROLER_02, yy); { char str[256]; sprintf(str, "%s [%1.2f,%f1.2]", tooltips?tooltips:"", xx, yy); notify(this, nyTOOLTIPS, (dword)str); } break; } repaint(); father->notify(this, nyCHANGE); } switch(event) { case mouseLUP: mouseCapture(FALSE); test=FALSE; break; } return TRUE; } return FALSE; }