Exemplo n.º 1
0
static gnmc_t *gnmc_init (char *sysname) {

	gnmc_t *monitor;
	box_t *sysinfo_box,*moninfo_box;
	int32_t rows,cols,i;
  screen_t **scrs;
  struct timeval conn_time;

	getmaxyx (stdscr,rows,cols);

	monitor = calloc (1, sizeof (gnmc_t));
	monitor->name = strdup (sysname);

	monitor->nscrs = 4;
	monitor->main_scrs = calloc (monitor->nscrs,sizeof (screen_t*));
	monitor->top_screen = NULL; 

  monitor->info = calloc (1, sizeof (info_t));
  monitor->info->deliveries = 0;
  
  for (i=0;i<4;i++) {
    monitor->info->crates[i] = 0;
  }
  
  conn_time = monitor->info->conn_time;

  gettimeofday (&conn_time,NULL);

  scrs = monitor->main_scrs;

  scrs[STAT_SCR] = screen_create ("Station",rows/2,cols/2,0,0);

  sysinfo_box = box_create (scrs[STAT_SCR], NAME, 5);
  box_set_name (sysinfo_box,"sysinfo");

  moninfo_box = box_create (scrs[STAT_SCR], NAME, 2);
  box_set_name (moninfo_box,"moninfo");

	scrs[MIX_SCR] = screen_create ("Mixer",rows/2,cols/2,0,cols/2);
	scrs[COMP_SCR] = screen_create ("Compositor",rows/2,cols/2,rows/2,0);
	scrs[TRANS_SCR] = screen_create ("Transponder",rows/2,cols/2,rows/2,cols/2);

	scrs[STAT_SCR]->focus = 1;

	gnmc_krcomp_boxes_init (scrs[COMP_SCR]);

	screen_focus_curr (scrs,monitor->nscrs);

	return monitor;
}
Exemplo n.º 2
0
static void gnmc_sprites_screen_populate (scr_t *scr, sprite_t *spr, uint32_t id) {

	box_t *box;

	box = box_create (scr,ID,1);
  box_set_id (box,id);
	box_print (box,"ID: %d Filename: %s",id,spr->filename);

	return;
}
Exemplo n.º 3
0
static int32_t gnmc_krstation_handler (gnmc_t *mon, kr_crate_t *crate) {

	screen_t *screen;
	box_t *rbox;
	kr_subunit_t subunit;
	kr_radio_t *radio;
	kr_remote_t *remote;
  screen_t **main_scrs;

	subunit = crate->addr->path.subunit;
	radio = crate->inside.radio;
	remote = crate->inside.remote;

  main_scrs = mon->main_scrs;
  screen = main_scrs[STAT_SCR];


	if (subunit.zero == KR_TAGS) {
      // printf ("Station Tags");
	}


	switch (subunit.station_subunit) {

		case KR_CPU:
				// if (kr_crate_has_int (crate)) {
				// 	mvwprintw (win,5,5,"CPU %d%%",crate->integer);
				// 	update_panels ();
				// 	doupdate ();
				// }
			break;
		case KR_REMOTE:
			
			rbox = box_get_by_id (screen_boxes (screen),remote->port);

			if (rbox == NULL) {
				rbox = box_create (screen,ID,1);
				box_set_id (rbox,remote->port);
			}

			box_clear (rbox);
			box_reset_cur (rbox);
			box_print (rbox,"Remote: %s %d",remote->interface,remote->port);

			break;
		default:
			if (gnmc_sysinfo_show (screen,radio,mon->info) < 0) {
				return -1;
			}
			break;
	}
    
	return 0;
}
Exemplo n.º 4
0
static void gnmc_texts_screen_populate (scr_t *scr, kr_text_t *text, uint32_t id) {

	box_t *box;

  kr_comp_controls_t ctls = text->controls;

	box = box_create (scr,ID,1);
  box_set_id (box,id);
	box_print (box,"ID: %d X: %d Y: %d Text: %s",id,ctls.x,ctls.y,text->text);

	return;
}
Exemplo n.º 5
0
// ********************************
// Mesh geometry
// ********************************
void mesh_geometry::box_update(bool force)
{
  if((force || flag_get(GEOMETRY_BOX_DIRTY)) && vertexnum_get() && facenum_get()) {
    if(!p_box) {
      p_box = box_create(box_type);
    }
    
    lock();
    p_box->set(position_get(), vertexnum_get(), faces_get(), facenum_get());
    unlock();
    
    flag_clear(GEOMETRY_BOX_DIRTY);
    box_change_set();
  }
}
Exemplo n.º 6
0
static void gnmc_krcomp_boxes_init (screen_t *screen) {

	box_set_name (box_create (screen,NAME,1),"res");
	box_set_name (box_create (screen,NAME,1),"fps");
	box_set_name (box_create (screen,NAME,1),"texts");
	box_set_name (box_create (screen,NAME,1),"sprites");
	box_set_name (box_create (screen,NAME,1),"vectors");
	box_set_name (box_create (screen,NAME,1),"frames");

	return;
}
Exemplo n.º 7
0
// display a text message
void
message_box(int delay, int x, int y, char *fgc, char *bgc, char *bc, char *txt)
{
	workarea mon;
	monitor_dimensions_struts(x, y, &mon);
	if (fork())
		return;

	display = XOpenDisplay(0x0);

	box *b = box_create(root, BOX_OVERRIDE, 0, 0, 1, 1, config_title_bg);

	textbox *text =
	    textbox_create(b->window, TB_CENTER | TB_AUTOHEIGHT | TB_AUTOWIDTH,
	    8, 5, 1, 1, config_title_font, config_title_fg, config_title_bg,
	    txt, NULL);

	box_moveresize(b,
	    MIN(mon.x + mon.w - text->w - 26, MAX(mon.x + 26,
		    x - text->w / 2)), MIN(mon.y + mon.h - text->h - 20,
		MAX(mon.y + 20, y - text->h / 2)), text->w + 16, text->h + 10);

	XSelectInput(display, b->window, ExposureMask);

	textbox_show(text);
	box_show(b);

	double stamp = timestamp();
	while ((timestamp() - stamp) < (double) delay / 1000) {
		if (XPending(display)) {
			XEvent ev;
			XNextEvent(display, &ev);

			if (ev.type == Expose)
				textbox_draw(text);
		}
		usleep(10000);	// 10ms
	}

	textbox_free(text);
	box_free(b);

	exit(EXIT_SUCCESS);
}
Exemplo n.º 8
0
static int32_t gnmc_portgroup_show (port_t *port, screen_t *scr) {

	box_t *port_box;

	port_box = box_create (scr,NAME,1);
	box_set_name (port_box,port->sysname);

	switch (port->direction) {
		case INPUT:
			box_print (port_box,"Input %s , Vol: %0.2f%%",
      port->sysname,port->volume[0]);
			box_set_info (port_box,"Input");
      port_box->ro = 1;
			break;
		case OUTPUT:
			if (port->output_type == DIRECT) {
				box_print (port_box,"Output %s , Vol: %0.2f%%",
        port->sysname,port->volume[0]);
				box_set_info (port_box,"Output");
        port_box->ro = 1;
			}
			else {
				box_print (port_box,"Aux Output %s , Vol: %0.2f%%",
        port->sysname,port->volume[0]);
				box_set_info (port_box,"Aux Output");
        port_box->ro = 1;
			}
			break;
		case MIX:
			box_print (port_box,"Bus %s , Vol: %0.2f%%",
      port->sysname,port->volume[0]);
			box_set_info (port_box,"Bus");
      port_box->ro = 1;
			break;
	}

	return 0;
}
Exemplo n.º 9
0
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
{
    {
        box *b = box_create ( "box", BOX_HORIZONTAL );
        //box_set_padding ( b, 5 );
        widget_resize ( WIDGET (b), 100, 20);

        widget *wid1 = g_malloc0(sizeof(widget));
        box_add ( b , WIDGET( wid1 ), TRUE, 0 );
        // Widget not enabled.  no width allocated.
        TASSERTE ( wid1->h, 0);
        TASSERTE ( wid1->w, 0 );
        widget_enable ( WIDGET ( wid1 ) );
        widget_update ( WIDGET ( b ) ) ;
        // Widget enabled.  so width allocated.
        TASSERTE ( wid1->h, 20);
        TASSERTE ( wid1->w, 100 );
        widget *wid2 = g_malloc0(sizeof(widget));
        widget_enable ( WIDGET ( wid2 ) );
        box_add ( b , WIDGET( wid2 ), TRUE, 1 );
        TASSERTE ( wid1->h, 20);
        TASSERTE ( wid1->w, 49);
        TASSERTE ( wid2->h, 20);
        TASSERTE ( wid2->w, 49);

        widget *wid3 = g_malloc0(sizeof(widget));
        widget_enable ( WIDGET ( wid3 ) );
        box_add ( b , WIDGET( wid3 ), FALSE, 2 );
        TASSERTE ( wid1->h, 20);
        TASSERTE ( wid1->w, 48);
        TASSERTE ( wid2->h, 20);
        TASSERTE ( wid2->w, 48);

        widget_resize ( WIDGET (wid3) , 20, 10 );
        // TODO should this happen automagically?
        widget_update ( WIDGET ( b ) ) ;
        TASSERTE ( wid1->h, 20);
        TASSERTE ( wid1->w, 38);
        TASSERTE ( wid2->h, 20);
        TASSERTE ( wid2->w, 38);
        TASSERTE ( wid3->h, 20);
        TASSERTE ( wid3->w, 20);

        widget_resize ( WIDGET (b ), 200, 20 );
        TASSERTE ( wid1->h, 20);
        TASSERTE ( wid1->w, 88);
        TASSERTE ( wid2->h, 20);
        TASSERTE ( wid2->w, 88);
        TASSERTE ( wid3->h, 20);
        TASSERTE ( wid3->w, 20);
//        TASSERTE ( box_get_fixed_pixels ( b ) , 24 );

        widget *wid4 = g_malloc0(sizeof(widget));
        widget_enable ( WIDGET ( wid4 ) );
        widget_resize ( WIDGET ( wid4 ), 20, 20 );
        box_add ( b , WIDGET( wid4 ), FALSE, 5 );
        TASSERTE ( wid4->x, 200-20);
        widget *wid5 = g_malloc0(sizeof(widget));
        widget_enable ( WIDGET ( wid5 ) );
        widget_resize ( WIDGET ( wid5 ), 20, 20 );
        box_add ( b , WIDGET( wid5 ), TRUE, 6 );
        TASSERTE ( wid5->x, 149);
        widget_free ( WIDGET ( b ) );
    }
    {
        box *b = box_create ( "box", BOX_VERTICAL );
        widget_resize ( WIDGET (b), 20, 100);
        //box_set_padding ( b, 5 );

        widget *wid1 = g_malloc0(sizeof(widget));
        box_add ( b , WIDGET( wid1 ), TRUE, 0 );
        // Widget not enabled.  no width allocated.
        TASSERTE ( wid1->h, 0);
        TASSERTE ( wid1->w, 0 );
        widget_enable ( WIDGET ( wid1 ) );
        widget_update ( WIDGET ( b ) ) ;
        // Widget enabled.  so width allocated.
        TASSERTE ( wid1->h, 100);
        TASSERTE ( wid1->w, 20 );
        widget *wid2 = g_malloc0(sizeof(widget));
        widget_enable ( WIDGET ( wid2 ) );
        box_add ( b , WIDGET( wid2 ), TRUE, 1 );
        TASSERTE ( wid1->w, 20);
        TASSERTE ( wid1->h, 49);
        TASSERTE ( wid2->w, 20);
        TASSERTE ( wid2->h, 49);

        widget *wid3 = g_malloc0(sizeof(widget));
        widget_enable ( WIDGET ( wid3 ) );
        box_add ( b , WIDGET( wid3 ), FALSE, 2 );
        TASSERTE ( wid1->w, 20);
        TASSERTE ( wid1->h, 48);
        TASSERTE ( wid2->w, 20);
        TASSERTE ( wid2->h, 48);

        widget_resize ( WIDGET (wid3) , 10, 20 );
        // TODO should this happen automagically?
        widget_update ( WIDGET ( b ) ) ;
        TASSERTE ( wid1->w, 20);
        TASSERTE ( wid1->h, 48);
        TASSERTE ( wid2->w, 20);
        TASSERTE ( wid2->h, 48);
        TASSERTE ( wid3->w, 20);
        TASSERTE ( wid3->h, 0);

        widget_resize ( WIDGET (b ), 20, 200 );
        TASSERTE ( wid1->w, 20);
        TASSERTE ( wid1->h, 98);
        TASSERTE ( wid2->w, 20);
        TASSERTE ( wid2->h, 98);
        TASSERTE ( wid3->w, 20);
        // has no height, gets no height.
        TASSERTE ( wid3->h, 0);
//        TASSERTE ( box_get_fixed_pixels ( b ) , 4 );
        widget *wid4 = g_malloc0(sizeof(widget));
        widget_enable ( WIDGET ( wid4 ) );
        widget_resize ( WIDGET ( wid4 ), 20, 20 );
        box_add ( b , WIDGET( wid4 ), FALSE, 5 );
        TASSERTE ( wid4->y, 200);
        widget *wid5 = g_malloc0(sizeof(widget));
        widget_enable ( WIDGET ( wid5 ) );
        widget_resize ( WIDGET ( wid5 ), 20, 20 );
        box_add ( b , WIDGET( wid5 ), TRUE, 6 );
        TASSERTE ( wid5->y, 136);
        widget_free ( WIDGET ( b ) );
    }
    {
        box *b = box_create ( "box", BOX_VERTICAL );
        widget_resize ( WIDGET (b), 20, 100);
        //box_set_padding ( b, 5 );
        widget *wid1 = g_malloc0(sizeof(widget));
        widget_enable(wid1);
        wid1->clicked = test_widget_clicked;
        box_add ( b , WIDGET( wid1 ), TRUE, 0 );
        widget *wid2 = g_malloc0(sizeof(widget));
        widget_enable(wid2);
        box_add ( b , WIDGET( wid2 ), TRUE, 1 );

        xcb_button_press_event_t xce;
        xce.event_x = 10;
        xce.event_y = 60;
        TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0);

        xce.event_y = 50;
        TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0);
        xce.event_y = 48;
        TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 1);
        widget_disable ( wid2 );
        xce.event_y = 60;
        TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 1);
        widget_disable ( wid1 );
        widget_enable ( wid2 );
        TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0);
        widget_free ( WIDGET ( b ) );
    }
}