Ejemplo n.º 1
0
static void
MouseMotion(AG_Event *event)
{
	AG_HSVPal *pal = AG_SELF();
	int x = AG_INT(1);
	int y = AG_INT(2);

	switch (pal->state) {
	case AG_HSVPAL_SEL_NONE:
		break;
	case AG_HSVPAL_SEL_H:
		UpdateHue(pal,
		    x - pal->circle.x,
		    y - pal->circle.y);
		break;
	case AG_HSVPAL_SEL_SV:
		UpdateSV(pal, x, y);
		break;
	case AG_HSVPAL_SEL_A:
		UpdateAlpha(pal, x);
		break;
	default:
		break;
	}
}
Ejemplo n.º 2
0
static void
MouseButtonUp(AG_Event *event)
{
	AG_Button *bu = AG_SELF();
	int button = AG_INT(1);
	AG_Variable *binding;
	void *pState;
	int x = AG_INT(2);
	int y = AG_INT(3);
		
	if (bu->flags & AG_BUTTON_REPEAT) {
		AG_DelTimer(bu, &bu->repeatTo);
		AG_DelTimer(bu, &bu->delayTo);
		return;
	}
	
	if (AG_WidgetDisabled(bu) ||
	    x < 0 || y < 0 ||
	    x > WIDGET(bu)->w || y > WIDGET(bu)->h) {
		return;
	}
	
	binding = AG_GetVariable(bu, "state", &pState);
	if (GetState(bu, binding, pState) && button == AG_MOUSE_LEFT &&
	    !(bu->flags & AG_BUTTON_STICKY)) {
	    	SetState(bu, binding, pState, 0);
		AG_PostEvent(NULL, bu, "button-pushed", "%i", 0);
	}
	AG_UnlockVariable(binding);
}
Ejemplo n.º 3
0
/* button mashing handler */
static void handle_ui_events(AG_Event *event) {

	/* AG_TextMsg(AG_MSG_INFO, "Hello, %i, %i!", AG_INT(1), AG_INT(2)); */

	switch(AG_INT(1)) {	
		case UI_CMD_PLAY:
			musicpd_play();
			break;
		case UI_CMD_STOP:
			musicpd_stop();
			break;
		case UI_CMD_PAUSE:
			musicpd_pause();
			break;
		case UI_CMD_NEXT:
			musicpd_next();
			break;
		case UI_CMD_PREV:
			musicpd_prev();
			break;
		case UI_CMD_PLAY_ID:
			musicpd_play_id(musicpd_get_id_playlist_entry(AG_INT(2)));
			break;
		case UI_CMD_PLAYLIST_ADD:
			musicpd_playlist_add_path(musicpd_get_path_library_entry(AG_INT(2)));
			break;
		default:
			break;
	}
}
Ejemplo n.º 4
0
void
MapMoveFunction(AG_Event *event)
{
        void *p=AG_SELF();
    int cursorX=AG_INT(1);
    int cursorY=AG_INT(2);

};
Ejemplo n.º 5
0
/* Mouse motion event handler */
static void
MouseMotion(AG_Event *event)
{
	formaText *my = (formaText*)AG_SELF();
	int x = AG_INT(1);
	int y = AG_INT(2);

	/* ... */
}
Ejemplo n.º 6
0
/* Mouse click event handler */
static void
MouseButtonUp(AG_Event *event)
{
	formaText *my = (formaText*)AG_SELF();
	int button = AG_INT(1);
	int x = AG_INT(2);
	int y = AG_INT(3);

	/* ... */
}
Ejemplo n.º 7
0
static void
MouseMotion(AG_Event *event)
{
	AG_Slider *sl = AG_SELF();

	if (!sl->ctlPressed) {
		return;
	}
	SeekToPosition(sl, ((sl->type == AG_SLIDER_HORIZ) ?
	                    AG_INT(1):AG_INT(2)) - sl->xOffs);
}
Ejemplo n.º 8
0
/*
 * This is our keyup/keydown event handler. The arguments are documented in
 * the EVENTS section of the AG_Window(3) manual page. See AG_KeySym(3) for
 * a list of available key symbols.
 */
static void
MyKeyboardHandler(AG_Event *event)
{
	AG_Console *cons = AG_PTR(1);
	int sym = AG_INT(2);
	int mod = AG_INT(3);
	Uint32 unicode = (Uint32)AG_ULONG(4);

	AG_ConsoleMsg(cons,
	    "%s: sym=%d, modifier=0x%x, unicode=0x%lx",
	    event->name, sym, (unsigned)mod, unicode);
}
Ejemplo n.º 9
0
void OnMouseMotionGL(AG_Event *event)
{
    AG_GLView *my = (AG_GLView *)AG_SELF();
    int x = AG_INT(1);
    int y = AG_INT(2);
    int w;
    int h;
    if(my == NULL) return;
    if((bMouseCaptureFlag != TRUE) || (mos_capture != TRUE)) return;
    w = my->wid.w;
    h = my->wid.h;
    CalcMouseMove(w, h, x, y);
}
Ejemplo n.º 10
0
/* Mouse click event handler */
static void
MouseButtonDown(AG_Event *event)
{
	formaText *my = (formaText*)AG_SELF();
	int button = AG_INT(1);
	int x = AG_INT(2);
	int y = AG_INT(3);

	if (button != AG_MOUSE_LEFT) {
		return;
	}
	printf("Click at %d,%d\n", x, y);
	AG_WidgetFocus(my);
}
Ejemplo n.º 11
0
static void
KeyDown(AG_Event *event)
{
	AG_Button *bu = AG_SELF();
	AG_Variable *binding;
	void *pState;
	int keysym = AG_INT(1);
	
	if (AG_WidgetDisabled(bu))
		return;
	if (keysym != AG_KEY_RETURN &&		/* TODO AG_Action */
	    keysym != AG_KEY_KP_ENTER &&
	    keysym != AG_KEY_SPACE) {
		return;
	}
	binding = AG_GetVariable(bu, "state", &pState);
	SetState(bu, binding, pState, 1);
	AG_PostEvent(NULL, bu, "button-pushed", "%i", 1);
	bu->flags |= AG_BUTTON_KEYDOWN;

	if (bu->flags & AG_BUTTON_REPEAT) {
		AG_DelTimer(bu, &bu->repeatTo);
		AG_AddTimer(bu, &bu->delayTo, agKbdDelay,
		    ExpireDelay, "%i", agKbdRepeat);
	}
	AG_UnlockVariable(binding);
}
Ejemplo n.º 12
0
static void
MouseButtonDown(AG_Event *event)
{
	AG_Button *bu = AG_SELF();
	int button = AG_INT(1);
	AG_Variable *binding;
	void *pState;
	int newState;
	
	if (AG_WidgetDisabled(bu))
		return;

	if (!AG_WidgetIsFocused(bu))
		AG_WidgetFocus(bu);

	if (button != AG_MOUSE_LEFT)
		return;
	
	binding = AG_GetVariable(bu, "state", &pState);
	if (!(bu->flags & AG_BUTTON_STICKY)) {
		SetState(bu, binding, pState, 1);
	} else {
		newState = !GetState(bu, binding, pState);
		SetState(bu, binding, pState, newState);
		AG_PostEvent(NULL, bu, "button-pushed", "%i", newState);
	}
	AG_UnlockVariable(binding);

	if (bu->flags & AG_BUTTON_REPEAT) {
		AG_DelTimer(bu, &bu->repeatTo);
		AG_PostEvent(NULL, bu, "button-pushed", "%i", 1);
		AG_AddTimer(bu, &bu->delayTo, agMouseSpinDelay,
		    ExpireDelay, "%i", agMouseSpinIval);
	}
}
Ejemplo n.º 13
0
void OnMouseMotionSDL(AG_Event *event)
{
    XM7_SDLView *my = (XM7_SDLView *)AG_SELF();
    int x = AG_INT(1);
    int y = AG_INT(2);
    int w;
    int h;
    AG_Surface *su;
   
    if(my == NULL) return;
    if((bMouseCaptureFlag != TRUE) || (mos_capture != TRUE)) return;
    su = AGWIDGET_SURFACE(my, my->mySurface);
    w = su->w;
    h = su->h;
    CalcMouseMove(w, h, x, y);
}
Ejemplo n.º 14
0
Archivo: ucombo.c Proyecto: adsr/agar
static void
Expand(AG_Event *event)
{
	AG_UCombo *com = AG_PTR(1);
	AG_Driver *drv = WIDGET(com)->drv;
	int expand = AG_INT(2);
	AG_SizeReq rList;
	int x, y, w, h;
	Uint wView, hView;

	AG_ObjectLock(com);
	if (expand) {
		com->panel = AG_WindowNew(AG_WINDOW_POPUP|AG_WINDOW_MODAL|
		                          AG_WINDOW_NOTITLE);
		AG_ObjectSetName(com->panel, "_UComboPopup");
		AG_WindowSetPadding(com->panel, 0,0,0,0);
		AG_ObjectAttach(com->panel, com->list);
		if (WIDGET(com)->window != NULL)
			AG_WindowAttach(WIDGET(com)->window, com->panel);
	
		if (com->wSaved > 0) {
			w = com->wSaved;
			h = com->hSaved;
		} else {
			if (com->wPreList != -1 && com->hPreList != -1) {
				AG_TlistSizeHintPixels(com->list,
				    com->wPreList, com->hPreList);
			}
			AG_WidgetSizeReq(com->list, &rList);
			w = rList.w + com->panel->wBorderSide*2;
			h = rList.h + com->panel->wBorderBot;
		}
		x = WIDGET(com)->rView.x2 - w;
		y = WIDGET(com)->rView.y1;
		
		AG_GetDisplaySize(WIDGET(com)->drv, &wView, &hView);
		if (x+w > wView) { w = wView - x; }
		if (y+h > hView) { h = hView - y; }
		
		if (AGDRIVER_CLASS(drv)->wm == AG_WM_MULTIPLE &&
		    WIDGET(com)->window != NULL) {
			x += WIDGET(WIDGET(com)->window)->x;
			y += WIDGET(WIDGET(com)->window)->y;
		}
		if (x < 0) { x = 0; }
		if (y < 0) { y = 0; }
		if (w < 4 || h < 4) {
			Collapse(com);
			return;
		}
		AG_SetEvent(com->panel, "window-modal-close",
		    ModalClose, "%p", com);
		AG_WindowSetGeometry(com->panel, x,y, w,h);
		AG_WindowShow(com->panel);
	} else {
		Collapse(com);
	}
	AG_ObjectUnlock(com);
}
Ejemplo n.º 15
0
/* Keystroke event handler */
static void
KeyUp(AG_Event *event)
{
	formaText *my = (formaText*)AG_SELF();
	int keysym = AG_INT(1);

	/* ... */
}
Ejemplo n.º 16
0
static void
SetAlign(AG_Event *event)
{
	VG_Text *vt = AG_PTR(1);
	enum vg_alignment align = (enum vg_alignment)AG_INT(2);

	vt->align = align;
}
Ejemplo n.º 17
0
Archivo: fill.c Proyecto: adsr/agar
static void
set_type(AG_Event *event)
{
	struct rg_fill_feature *fi = AG_PTR(1);
	int type = AG_INT(2);

	fi->type = type;
}
Ejemplo n.º 18
0
/* Keystroke event handler */
static void
KeyDown(AG_Event *event)
{
	formaText *my = (formaText*)AG_SELF();
	int keysym = AG_INT(1);

	printf("Keystroke: 0x%x\n", keysym);
}
Ejemplo n.º 19
0
static Uint32
ExpireDelay(AG_Timer *to, AG_Event *event)
{
	AG_Button *bu = AG_SELF();
	int repeatIval = AG_INT(1);

	AG_AddTimer(bu, &bu->repeatTo, repeatIval, ExpireRepeat, NULL);
	return (0);
}
Ejemplo n.º 20
0
static void XM7_DbgMMRDrawFn(AG_Event *event)
{
   XM7_SDLView *view = (XM7_SDLView *)AG_SELF();
    struct XM7_DbgMMRDump *p = (struct XM7_DbgMMRDump *)AG_PTR(1);
    BOOL forceredraw = AG_INT(2);

    if(p == NULL) return;
    XM7_ConsoleUpdate(view, p->cons, forceredraw);
}
Ejemplo n.º 21
0
static void OnChangeSampleRate(AG_Event *event)
{
	struct gui_sound *cfg = AG_PTR(1);
	int num = AG_INT(2);
	if(cfg == NULL) return;
	if(num > 6 ){
		num = 6;
	}
	cfg->nSampleRate = SampleRates[num];
}
Ejemplo n.º 22
0
void
MapClickFunction(AG_Event *event)
{
    void *p=AG_SELF();
    int b=AG_INT(1);
    int cursorX=AG_INT(2);
    int cursorY=AG_INT(3);

    GLdouble posX,posY,posZ;

    gluUnProject(viewport[0]+cursorX,viewport[1] +viewport[3]-cursorY,0,modelview,projection,viewport,&posX,&posY,&posZ);

    cursorwX=posX;
    cursorwY=posY;

    static ComplexTask followPath;
    followPath = planPath(cursorwX,cursorwY);
    if (UpdateTimerSlot.m_Observers.size()==0)
        UpdateTimerSlot.addTask<ComplexTask>(followPath);
};
Ejemplo n.º 23
0
static void
MouseMotion(AG_Event *event)
{
	AG_Button *bu = AG_SELF();
	AG_Variable *binding;
	int x = AG_INT(1);
	int y = AG_INT(2);
	void *pState;

	if (AG_WidgetDisabled(bu))
		return;

	binding = AG_GetVariable(bu, "state", &pState);
	if (!AG_WidgetRelativeArea(bu, x, y)) {
		if ((bu->flags & AG_BUTTON_STICKY) == 0 &&
		    GetState(bu, binding, pState) == 1) {
			SetState(bu, binding, pState, 0);
		}
	}
	AG_UnlockVariable(binding);
}
Ejemplo n.º 24
0
void OnMouseButtonUpGL(AG_Event *event)
{
   AG_GLView *my = (AG_GLView *)AG_SELF();
   int button = AG_INT(1);
   int x = AG_INT(2);
   int y = AG_INT(3);
   int w;
   int h;
   if(my == NULL) return;

   if((bMouseCaptureFlag != TRUE) || (mos_capture != TRUE)) return;
   w = my->wid.w;
   h = my->wid.h;
   CalcMouseMove(w, h, x, y);
   if(button == AG_MOUSE_LEFT) {
	nMouseButton |= 0x10;
   }
   if(button == AG_MOUSE_RIGHT) {
	nMouseButton |= 0x20;
   }

}
Ejemplo n.º 25
0
/* Timer callback for keyboard motion. */
static Uint32
MoveTimeout(AG_Timer *to, AG_Event *event)
{
	AG_Slider *sl = AG_SELF();
	int dir = AG_INT(1);

	if (dir < 0) {
		Decrement(sl);
	} else {
		Increment(sl);
	}
	return (agKbdRepeat);
}
Ejemplo n.º 26
0
static void
MouseButtonDown(AG_Event *event)
{
	AG_HSVPal *pal = AG_SELF();
	int btn = AG_INT(1);
	int x = AG_INT(2);
	int y = AG_INT(3);
	float r;

	if (!AG_WidgetIsFocused(pal))
		AG_WidgetFocus(pal);

	switch (btn) {
	case AG_MOUSE_LEFT:
		if (y > pal->rAlpha.y) {
			UpdateAlpha(pal, x);
			pal->state = AG_HSVPAL_SEL_A;
		} else {
			x -= pal->circle.x;
			y -= pal->circle.y;
			r = Hypot((float)x, (float)y);

			if (r > (float)pal->circle.rin) {
				UpdateHue(pal, x, y);
				pal->state = AG_HSVPAL_SEL_H;
			} else {
				UpdateSV(pal, AG_INT(2), AG_INT(3));
				pal->state = AG_HSVPAL_SEL_SV;
			}
		}
		AG_Redraw(pal);
		break;
	case AG_MOUSE_MIDDLE:
	case AG_MOUSE_RIGHT:
		OpenMenu(pal, x,y);
		break;
	}
}
Ejemplo n.º 27
0
static void
MouseButtonDown(AG_Event *event)
{
	AG_Slider *sl = AG_SELF();
	int button = AG_INT(1);
	int x = ((sl->type == AG_SLIDER_HORIZ) ? AG_INT(2) : AG_INT(3));
	int pos;

	if (button != AG_MOUSE_LEFT) {
		return;
	}
	if (GetPosition(sl, &pos) == -1)
		return;

	if (!AG_WidgetIsFocused(sl)) {
		AG_WidgetFocus(sl);
	}
	if (x >= pos && x <= (pos + sl->wControl)) {
		/*
		 * Click on the slider itself. We don't do anything except
		 * saving the cursor position which we will use in future
		 * mousemotion events.
		 */
		sl->ctlPressed = 1;
		sl->xOffs = x - pos;
		AG_PostEvent(NULL, sl, "slider-drag-begin", NULL);
	} else {
		/*
		 * Click outside of control. We seek to the absolute position
		 * described by the cursor.
		 */
		sl->ctlPressed = 1;
		sl->xOffs = sl->wControl/2;
		SeekToPosition(sl, x - sl->xOffs);
		AG_PostEvent(NULL, sl, "slider-drag-begin", NULL);
	}
	AG_Redraw(sl);
}
Ejemplo n.º 28
0
void OnMouseButtonDownSDL(AG_Event *event)
{
   XM7_SDLView *my = (XM7_SDLView *)AG_SELF();
   int button = AG_INT(1);
   int x = AG_INT(2);
   int y = AG_INT(3);
   int w;
   int h;
   AG_Surface *su;
   if(my == NULL) return;
   if((bMouseCaptureFlag != TRUE) || (mos_capture != TRUE)) return;
   su = AGWIDGET_SURFACE(my, my->mySurface);
   w = su->w;
   h = su->h;
   CalcMouseMove(w, h, x, y);
   if(button == AG_MOUSE_LEFT) {
	nMouseButton &= ~0x10;
   }
   if(button == AG_MOUSE_RIGHT) {
	nMouseButton &= ~0x20;
   }

}
Ejemplo n.º 29
0
static void SetBootMode(AG_Event *event)
{
	AG_Button *self = (AG_Button *)AG_SELF();
	int DosMode = AG_INT(1);

	if(DosMode) {
		// DOSモード
		OnDos(event);
	} else {
		OnBasic(event);
	}
	AG_WindowHide(self->wid.window);
	AG_ObjectDetach(self->wid.window);
}
Ejemplo n.º 30
0
static void
KeyUp(AG_Event *event)
{
	AG_Slider *sl = AG_SELF();
	int keysym = AG_INT(1);

	switch (keysym) {
	case AG_KEY_UP:
	case AG_KEY_LEFT:
	case AG_KEY_DOWN:
	case AG_KEY_RIGHT:
		AG_DelTimer(sl, &sl->moveTo);
		break;
	}
}