Example #1
0
// This callback function gets called by the Glut
// system whenever any mouse button goes up or down.
void mouse(int mouse_button, int state, int x, int y_inverted)
{
    // translate pixel coordinates to display coordinates
    //  int xdisplay = x;
    //  int ydisplay = screen_y - y;
    int y = SCREEN_Y - y_inverted;
    bool buttonClicked = false;
    bool sliderClicked = false;
    
    if (mouse_button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
        for (auto itr : BUTTONS) {
            if (itr->contains(Point(x, y))) {
                handleButtonClick(x, y, itr);
                buttonClicked = true;
            }
        }
        for (auto itr : SLIDERS) {
            if (itr->contains(Point(x, y))) {
                handleSliderClick(x, y, itr);
                sliderClicked = true;
            }
        }
        if (!(buttonClicked || sliderClicked)) {
            handleOtherClick(x, y);
        }
    }
    if (mouse_button == GLUT_LEFT_BUTTON && state == GLUT_UP) {
    }
    if (mouse_button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN) {
    }
    if (mouse_button == GLUT_MIDDLE_BUTTON && state == GLUT_UP) {
    }
    glutPostRedisplay();
}
Example #2
0
void handleMouseEvent(SDL_Event event, GraphicModule * module){
    //Welcome to the bottleneck, we got fun and games
    //If lagging is your issue, here you must change!
    if(withinMenu(module->menu,event.motion.x, event.motion.y) != -1){
        int button = checkButtons(module->menu, event.motion.x,event.motion.y);
        if(button != -1){
            if(mouseDown){
                //Click
                module->menu->buttons[button]->clicked = 1;
                module->menu->buttons[button]->hover = 0;
            }else{
                //Hover or finished clicking
                if(module->menu->buttons[button]->clicked == 1){
                    //We just finished clicking and are about to change back to a hover state
                    handleButtonClick(module, button);

                }
                module->menu->buttons[button]->clicked = 0;
                module->menu->buttons[button]->hover = 1;
            }
        }else{
            //Not in any buttons, make sure all of them are in their default state
            int i;
            for(i=0; i < NUMBER_OF_BUTTONS; i++){
                module->menu->buttons[i]->clicked = 0;
                module->menu->buttons[i]->hover = 0;
            }
        }
    }else{
        //Drawing mode. (Once we are loading documents some more stuff will have to go here)
        if(mouseDown){
            if(event.motion.x < SCREENWIDTH && event.motion.y < SCREENHEIGHT){
                buffered[bufferPointer] = event.motion.x;
                buffered[bufferPointer+1] = event.motion.y;
                //If smoothing is off this will be optimized out by the compiler
                if(SMOOTHING==1){
                    smoothPath(event.motion.x,event.motion.y,event.motion.xrel,event.motion.yrel);
                }
                bufferPointer = bufferPointer+2;
            }    
            if(bufferPointer > CLICKBUFFERSIZE){
                puts("aw shit ");//what a good error message for now
                bufferPointer = 0;
            }
        }
    }
}
Example #3
0
BaseClient::BaseClient(ClientId clientId,
        MocapSubjectList *subjectList,
        QPushButton *pushButton,
        QLineEdit *lineEditStatus,
        QObject *parent)
: QObject(parent)
, subjects(subjectList)
, button(pushButton)
, statusLine(lineEditStatus)
, count(0)
, id(clientId)
{
    QObject::connect(button, SIGNAL(clicked()),                  this,   SLOT(handleButtonClick()));
    QObject::connect(this,   SIGNAL(stateConnecting()),          this,   SLOT(UIConnectingState()));
    QObject::connect(this,   SIGNAL(stateConnected()),           this,   SLOT(UIConnectedState()));
    QObject::connect(this,   SIGNAL(stateDisconnecting()),       this,   SLOT(UIDisconnectingState()));
    QObject::connect(this,   SIGNAL(stateDisconnected()),        this,   SLOT(UIDisconnectedState()));
    QObject::connect(this,   SIGNAL(outMessage_(QString)),       parent, SLOT(showMessage(QString)));
    QObject::connect(this,   SIGNAL(updateFrame(ClientId,uint)), parent, SLOT(processFrame(ClientId, uint)));
}
Example #4
0
BOOL CALLBACK MonitorCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg) {
		case WM_MOVE: {
			if (!IsIconic(hwndDlg)) {
			RECT wrect;
			GetWindowRect(hwndDlg,&wrect);
			Monitor_wndx = wrect.left;
			Monitor_wndy = wrect.top;

			#ifdef WIN32
			WindowBoundsCheckNoResize(Monitor_wndx,Monitor_wndy,wrect.right);
			#endif
			}
			break;
		};

		case WM_INITDIALOG:
			if (Monitor_wndx==-32000) Monitor_wndx=0; //Just in case
			if (Monitor_wndy==-32000) Monitor_wndy=0;
			SetWindowPos(hwndDlg,0,Monitor_wndx,Monitor_wndy,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER);
			monitor_open = 1;
//			CenterWindow(hwndDlg);

			InitControls(hwndDlg);
			break;
		case WM_COMMAND:
			switch(HIWORD(wParam))
			{
				case BN_CLICKED:
					if ( GameInfo )
					{
						if ( !handleButtonClick(hwndDlg, LOWORD(wParam)) )
						{
							MessageBox(hwndDlg, "Invalid byte value", "Error", MB_OK | MB_ICONERROR);
						}
					}
					break;
				case CBN_SELCHANGE:
				{
					unsigned int sl = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0);
					
					EnableWindow(GetDlgItem(hwndDlg, ruleBox_to_ruleInput(LOWORD(wParam))), sl == RULE_EXACT || sl == RULE_EXACT_NOT);

					break;
				}
				case LBN_DBLCLK:
				{
					if (LOWORD(wParam) == RESULTS_BOX)
					{
						char str[259] = { 0 },str2[259] = { 0 };
						SendDlgItemMessage(hwndDlg,RESULTS_BOX,LB_GETTEXT,SendDlgItemMessage(hwndDlg,RESULTS_BOX,LB_GETCURSEL,0,0),(LPARAM)(LPCTSTR)str);
						strcpy(str2,str);
						str2[4] = 0;
						AddMemWatch(str2);
					}
				}
			}
			break;
		case WM_CLOSE:
		case WM_QUIT:
			DeleteObject(hNewFont);
			monitor_open = 0;
			DestroyWindow(hwndDlg);
			break;
	}
	return FALSE;
}