Example #1
0
/*
 * Set up main window, draw it.
 */
void ui_main() {

	mainwin = AG_WindowNew(AG_WINDOW_PLAIN);

	plpane = AG_PaneNew(mainwin, AG_PANE_VERT, 0);
	AG_Expand(plpane);

	{
		AG_LabelNew(plpane->div[0], 0, "Playlist");
		playlisttable = AG_TableNewPolled(plpane->div[0], AG_TABLE_EXPAND, update_playlisttable, NULL);
		AG_TableSizeHint(playlisttable, 200, 15);
		AG_SetInt(playlisttable->hbar, "max", 0); /* HURR jak wylaczyc scrollbar?
		//AG_TableAddCol(playlisttable, "id", "<foo>", NULL); */
		AG_TableAddCol(playlisttable, "Artist", "<some lengthy artist name>", NULL);
		AG_TableAddCol(playlisttable, "Title", NULL, NULL);
		AG_TableAddCol(playlisttable, "Length", "<9999:99>", NULL);

		/*AG_TableSetRowDblClickFn(playlisttable, handle_ui_events, "%i,%p", 
			UI_CMD_PLAY_ID, playlisttable ); */
 
		AG_TableSetRowDblClickFn(playlisttable, handle_ui_events, "%i", 
			UI_CMD_PLAY_ID );
		//jak to samo klawiatura osiagnac?*/
		//AG_SetEvent(playlisttable, "window-keydown", keyboard_handler, NULL);

	}	

	{
		AG_LabelNew(plpane->div[1], 0, "Library");
		librarytable = AG_TableNewPolled(plpane->div[1], AG_TABLE_EXPAND, update_librarytable, NULL);		
		AG_SetInt(librarytable->hbar, "max", 0); /* HURR jak wylaczyc scrollbar? */
		AG_TableAddCol(librarytable, "Artist", "<some lengthy artist name>", NULL);
		AG_TableAddCol(librarytable, "Title", NULL, NULL);
		AG_TableAddCol(librarytable, "Length", "<9999:99>", NULL);

		AG_TableSetRowDblClickFn(librarytable, handle_ui_events, "%i", 
			UI_CMD_PLAYLIST_ADD );
	}	

	artistlbl = AG_LabelNewPolled(mainwin, 0, "Artist: %s", &artistBuf);
	titlelbl = AG_LabelNewPolled(mainwin, 0, "Title: %s", &titleBuf);

	buttonbox = AG_BoxNew(mainwin, AG_BOX_HORIZ, 0);
	AG_ExpandHoriz(buttonbox);
	{
		prevbutton = AG_ButtonNewFn(buttonbox, 0, "|<", handle_ui_events, "%i", UI_CMD_PREV);
		stopbutton = AG_ButtonNewFn(buttonbox, 0, "[]", handle_ui_events, "%i", UI_CMD_STOP);
		pausebutton = AG_ButtonNewFn(buttonbox, 0, "||", handle_ui_events, "%i", UI_CMD_PAUSE);
		playbutton = AG_ButtonNewFn(buttonbox, 0, ">", handle_ui_events, "%i", UI_CMD_PLAY);
		nextbutton = AG_ButtonNewFn(buttonbox, 0, ">|", handle_ui_events, "%i", UI_CMD_NEXT);
	}

	statuslbl = AG_LabelNewPolled(mainwin, 0, "Status: %s", &statusBuf);

	AG_WindowMaximize(mainwin);
	AG_WindowShow(mainwin);

}
Example #2
0
File: perfmon.c Project: adsr/agar
/* Initialize the performance monitor window. */
void
AG_PerfMonInit(void)
{
	AG_Label *lbl;

	agPerfWindow = AG_WindowNewNamedS(0, "event-fps-counter");
	AG_WindowSetCaptionS(agPerfWindow, _("Performance counters"));
	AG_WindowSetPosition(agPerfWindow, AG_WINDOW_LOWER_CENTER, 0);
	lbl = AG_LabelNewPolled(agPerfWindow, AG_LABEL_HFILL,
	    "%d evnt, %dms idle", &agEventAvg, &agIdleAvg);
	AG_LabelSizeHint(lbl, 1, "00 evnt, 000ms idle");
	agPerfGraph = AG_FixedPlotterNew(agPerfWindow, AG_FIXED_PLOTTER_LINES,
	                                               AG_FIXED_PLOTTER_XAXIS|
						       AG_FIXED_PLOTTER_EXPAND);
	agPerfFPS = AG_FixedPlotterCurve(agPerfGraph, "refresh", 0,160,0, 99);
	agPerfEvnts = AG_FixedPlotterCurve(agPerfGraph, "event", 0,0,180, 99);
	agPerfIdle = AG_FixedPlotterCurve(agPerfGraph, "idle", 180,180,180, 99);
}
Example #3
0
static int
TestGUI(void *obj, AG_Window *win)
{
	M_Plotter *plt;
	AG_Pane *pane;
	AG_Numerical *num;
	AG_Box *box;
	int i;

	pane = AG_PaneNew(win, AG_PANE_HORIZ, AG_PANE_EXPAND);
	{
		/* Create our plotter widget */
		plt = M_PlotterNew(pane->div[1], M_PLOTTER_EXPAND);

		/*
		 * Create the velocity plot item. This is what our algorithm
		 * computes.
		 */
		plVel = M_PlotNew(plt, M_PLOT_LINEAR);
		M_PlotSetLabel(plVel, "m/s");
		M_PlotSetYoffs(plVel, -45);
		M_PlotSetScale(plVel, 0.0, 50.0);

		/* Create a label we will use to show the "case". */
		plblCase = M_PlotLabelNew(plVel, M_LABEL_OVERLAY, 0, 16, "-");

		/* Plot the derivative of the velocity (the acceleration). */
		plAcc = M_PlotFromDerivative(plt, M_PLOT_LINEAR, plVel);
		M_PlotSetLabel(plAcc, "m/s^2");
		M_PlotSetScale(plAcc, 0.0, 3000.0);

		/* Plot the derivative of the acceleration (the jerk). */
		plJerk = M_PlotFromDerivative(plt, M_PLOT_LINEAR, plAcc);
		M_PlotSetLabel(plJerk, "m/s^3");
		M_PlotSetScale(plJerk, 0.0, 100.0);
		M_PlotSetScale(plJerk, 0.0, 150000.0);
		M_PlotSetYoffs(plJerk, 70);
	}

	/* Allow the user to play with the parameters. */
	box = AG_BoxNew(pane->div[0], AG_BOX_VERT, AG_BOX_EXPAND);
	{
		struct {
			const char *name;
			M_Real *f;
			double incr;
		} param[7] = {
			{ "Jmax: ",	&Jmax,	0.00001 },
			{ "Amax: ",	&Amax,	0.0005 },
			{ "F: ",	&F,	0.01 },
			{ "L: ",	&L,	10.0 },
			{ "Ts tweak: ",	&uTs,	1.0 },
			{ "Ta tweak: ",	&uTa,	1.0 },
			{ "To tweak: ",	&uTo,	1.0 },
		};

		for (i = 0; i < 7; i++) {
			num = AG_NumericalNewS(box, AG_NUMERICAL_HFILL, NULL,
			    param[i].name);
			AG_BindDouble(num, "value", param[i].f);
			AG_SetDouble(num, "inc", param[i].incr);
			AG_SetEvent(num, "numerical-changed",
			    GeneratePlot, "%p", plt);
		}

		AG_SeparatorNewHoriz(box);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "Aref: %lf", &Aref);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "v1: %lf", &v1);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "v2: %lf", &v2);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "v3: %lf", &v3);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "Ts: %lf", &Ts);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "Ta: %lf", &Ta);
		AG_LabelNewPolled(box, AG_LABEL_HFILL, "To: %lf", &To);

		AG_ButtonNewFn(box, AG_BUTTON_HFILL, "Generate",
		    GeneratePlot, "%p", plt);
	}
	AG_SetEvent(win, "window-shown", GeneratePlot, "%p", plt);
	AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 50, 30);
	return (0);
}