void Flu_Wrap_Group :: draw()
{
  // we first try to fit all children assuming no scrollbar. if they do not all fit,
  // we have to turn the scrollbar on and try again
  if( layout( false, false ) )
    {
      scrollbar.show();
      layout( true, false );
    }
  else
    scrollbar.hide();

  // hack to look right when resizing smaller
  if( scrollbar.value() > scrollbar.maximum() )
    {
      ((Fl_Valuator*)&scrollbar)->value( scrollbar.maximum() );
      layout( scrollbar.visible(), scrollTo!=NULL );
    }
  else if( scrollTo )
    layout( scrollbar.visible(), true );

  scrollTo = NULL;

  if( damage() & ~FL_DAMAGE_CHILD)
    {
      draw_box();
      draw_label();
    }
  fl_push_clip( x()+Fl::box_dx(box()), y()+Fl::box_dy(box()),
		w()-Fl::box_dw(box()), h()-Fl::box_dh(box()) );
  draw_children();
  fl_pop_clip();
}
Exemple #2
0
int
main(int argc, char ** argv)
{

   struct Exclamation parent;

   struct Exclamation *children;

   int handle, size;

   parent.height = 200;
   parent.width = 20;
   parent.bottom = -100;
   parent.left = -10;

   // Get the children from the recursion
   children = fractal(&parent, &size);

   handle = start_drawing();

   draw_children(size, children);

   free(children);

   stop_drawing(handle);

   return 0;

}
Exemple #3
0
static void
normal_draw(struct lstopo_output *loutput, hwloc_obj_t level, unsigned depth, unsigned x, unsigned y)
{
  struct lstopo_obj_userdata *lud = level->userdata;
  unsigned gridsize = loutput->gridsize;
  unsigned fontsize = loutput->fontsize;

  if (loutput->drawing == LSTOPO_DRAWING_PREPARE) {
    /* compute children size and position, our size, and save it */
    prepare_text(loutput, level);
    lud->width = lud->textwidth + gridsize + FONTGRIDSIZE;
    lud->height = gridsize + (fontsize + FONTGRIDSIZE) * lud->ntext;
    place_children(loutput, level,
		   gridsize, gridsize + (fontsize + FONTGRIDSIZE) * lud->ntext);

  } else { /* LSTOPO_DRAWING_DRAW */
    struct draw_methods *methods = loutput->methods;
    struct lstopo_style style;
    unsigned totwidth, totheight;

    /* restore our size that was computed during prepare */
    totwidth = lud->width;
    totheight = lud->height;

    lstopo_set_object_color(loutput, level, &style);
    methods->box(loutput, &style.bg, depth, x, totwidth, y, totheight);
    draw_text(loutput, level, &style.t, depth-1, x + gridsize, y + gridsize);

    /* Draw sublevels for real */
    draw_children(loutput, level, depth-1, x, y);
  }
}
void Flu_Choice_Group :: draw()
{
  int i;

  // make sure the selected child is still a child
  bool found = false;
  for( i = 1; i < children(); i++ )
    if( child(i) == selected )
      {
	found = true;
	break;
      }
  if( !found )
    selected = NULL;

  if( !selected && children() > 1 )
    value( child(1) );

  int lblW = 0, lblH = 0, X;

  for( i = 1; i < children(); i++ )
    {
      int W = 0, H;
      fl_measure( child(i)->label(), W, H );
      if( W > lblW )
	lblW = W;
      if( H > lblH )
	lblH = H;
    }

  lblW += 26;
  lblH += 6;

  // align the label
  if( align() & FL_ALIGN_LEFT )
    X = 4;
  else if( align() & FL_ALIGN_RIGHT )
    X = w() - lblW - 8;
  else
    X = w()/2 - lblW/2 - 2;

  // draw the main group box
  if( damage() & ~FL_DAMAGE_CHILD )
    fl_draw_box( box(), x(), y()+lblH/2, w(), h()-lblH/2, color() );

  // clip and draw the children
  choice->resize( choice->x(), choice->y(), 0, 0 );
  fl_clip( x()+2, y()+lblH+1, w()-4, h()-lblH-3 );
  draw_children();
  fl_pop_clip();

  // clear behind the button and draw it
  fl_color( color() );
  fl_rectf( x()+X, y(), lblW+4, lblH );
  fl_color( labelcolor() );
  choice->resize( x()+X+2, y(), lblW, lblH );
  draw_child( *choice );
}
void gActionChannel::draw() {

	/* draw basic boundaries (+ beat bars) and hide the unused area. Then
	 * draw the children (the actions) */

	baseDraw();
	fl_rectf(parent->coverX, y()+1, parent->totalWidth-parent->coverX+x(), h()-2, COLOR_BG_1);
	draw_children();
}
Exemple #6
0
void item_button::draw_triangles(draw_info in) {
	if (is_inventory_root()) {
		draw_children(in);
		return;
	}

	if (!is_being_dragged(in.owner)) 
		draw_complete_with_children(in);
}
Exemple #7
0
static void
pci_device_draw(struct lstopo_output *loutput, hwloc_obj_t level, unsigned depth, unsigned x, unsigned y)
{
  struct lstopo_obj_userdata *lud = level->userdata;
  unsigned gridsize = loutput->gridsize;
  unsigned fontsize = loutput->fontsize;
  unsigned overlaidoffset = 0;

  if (lud->pci_collapsed > 1) {
    /* additional depths and height for overlaid boxes */
    depth -= 2;
    if (lud->pci_collapsed > 2) {
      overlaidoffset = gridsize;
    } else {
      overlaidoffset = gridsize/2;
    }
  }

  if (loutput->drawing == LSTOPO_DRAWING_PREPARE) {
    /* compute children size and position, our size, and save it */
    prepare_text(loutput, level);
    lud->width = lud->textwidth + gridsize + overlaidoffset + FONTGRIDSIZE;
    lud->height = fontsize + gridsize + overlaidoffset + FONTGRIDSIZE;
    place_children(loutput, level,
		   gridsize, fontsize + gridsize + FONTGRIDSIZE);

  } else { /* LSTOPO_DRAWING_DRAW */
    struct draw_methods *methods = loutput->methods;
    struct lstopo_style style;
    unsigned totwidth, totheight;

    /* restore our size that was computed during prepare */
    totwidth = lud->width;
    totheight = lud->height;

    lstopo_set_object_color(loutput, level, &style);

    if (lud->pci_collapsed > 1) {
      methods->box(loutput, &style.bg, depth+2, x + overlaidoffset, totwidth - overlaidoffset, y + overlaidoffset, totheight - overlaidoffset);
      if (lud->pci_collapsed > 2)
	methods->box(loutput, &style.bg, depth+1, x + overlaidoffset/2, totwidth - overlaidoffset, y + overlaidoffset/2, totheight - overlaidoffset);
      methods->box(loutput, &style.bg, depth, x, totwidth - overlaidoffset, y, totheight - overlaidoffset);
    } else {
      methods->box(loutput, &style.bg, depth, x, totwidth, y, totheight);
    }

    draw_text(loutput, level, &style.t, depth-1, x + gridsize, y + gridsize);

    /* Draw sublevels for real */
    draw_children(loutput, level, depth-1, x, y);
  }
}
Exemple #8
0
void urlbar::draw() {

	if (damage() == FL_DAMAGE_CHILD) {
		draw_children();
		return;
	}

	const u32 startx = x();
	const u32 endx = x() + w() - 1;

	// Background
	u32 i;
	const u32 max = h() - 3;
	u32 r1 = 209, g1 = 209, b1 = 209;
	u32 r2 = 120, g2 = 138, b2 = 147;
	for (i = 0; i <= max; i++) {
		const float pos = i / (float) max;

		fl_color(mix(r1, r2, pos),
			mix(g1, g2, pos),
			mix(b1, b2, pos));

		const u32 posy = y() + i;
		fl_line(startx, posy, endx, posy);
	}

	// Two border lines
	u32 posy = y() + max + 1;
	fl_color(79, 89, 100);
	fl_line(startx, posy, endx, posy);

	posy = y() + max + 2;
	fl_color(25, 35, 45);
	fl_line(startx, posy, endx, posy);

	// Kids
	draw_children();
}
void vsx_widget_controller_slider::draw()
{
  if (!visible) return;

  vsx_widget_controller_base::draw();
  glLineWidth(1.0f);
  float ypos=parentpos.y+pos.y+get_y_pos();
  ((vsx_widget_base_edit*)editor)->set_string(vsx_string_helper::f2s(presentation_value,15));
  glBegin(GL_LINES);
    glColor4f(1,1,1,0.2);
    float ymin=parentpos.y+pos.y-size.y/2+handlesize/2,
          ymax=parentpos.y+pos.y+size.y/2-handlesize/2,
          stepfactor=(ymax-ymin)/20;
    int c=0;
    for (float yy=ymax;yy>=ymin-(stepfactor/2);yy-=stepfactor)
    {
      float ww=size.x*0.25;
      if (c%2==1) ww=size.x*0.4;
      if (c%10==0) ww=size.x*0.1;
      ++c;
      glVertex3f(parentpos.x+pos.x+size.x/2, yy,pos.z);
      glVertex3f(parentpos.x+pos.x+ww, yy,pos.z);
      glVertex3f(parentpos.x+pos.x-size.x/2, yy,pos.z);
      glVertex3f(parentpos.x+pos.x-ww, yy,pos.z);
    }
    glColor4f(0,0,0,1);
    glVertex3f(parentpos.x+pos.x, parentpos.y+pos.y+size.y/2-handlesize/2,pos.z);
    glVertex3f(parentpos.x+pos.x, parentpos.y+pos.y-size.y/2+handlesize/2,pos.z);
  glEnd();
  glBegin(GL_TRIANGLE_FAN);
    glColor4f(lightshade*color.r,lightshade*color.g,lightshade*color.b,color.a);
    glVertex3f(parentpos.x+pos.x+size.x/3, ypos+handlesize*0.5,pos.z);//top right
    glColor4f(darkshade*color.r,darkshade*color.g,darkshade*color.b,color.a);
    glVertex3f(parentpos.x+pos.x+size.x/3, ypos,pos.z);//right center
    glColor4f(lightshade*color.r,lightshade*color.g,lightshade*color.b,color.a);
    glVertex3f(parentpos.x+pos.x+size.x/3,ypos-handlesize*0.5,pos.z); //bottom right
    glVertex3f(parentpos.x+pos.x-size.x/3,ypos-handlesize*0.5,pos.z); //bottom left
    glColor4f(darkshade*color.r,darkshade*color.g,darkshade*color.b,color.a);
    glVertex3f(parentpos.x+pos.x-size.x/3, ypos,pos.z); //left center
    glColor4f(lightshade*color.r,lightshade*color.g,lightshade*color.b,color.a);
    glVertex3f(parentpos.x+pos.x-size.x/3,ypos+handlesize*0.5,pos.z); //top left
    glVertex3f(parentpos.x+pos.x+size.x/3, ypos+handlesize*0.5,pos.z);//top right
  glEnd();
  glBegin(GL_LINES);
    glColor4f(0,0,0,1);
    glVertex3f(parentpos.x+pos.x+size.x/3, ypos,pos.z);
    glVertex3f(parentpos.x+pos.x-size.x/3, ypos,pos.z);
  glEnd();
  draw_children();
}
Exemple #10
0
void vsx_widget_desktop::draw() {
  if (!init_run)
    return;

  camera.run();

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(45,screen_x/screen_y,0.001,120.0);

  gluLookAt(
        camera.get_pos_x(), camera.get_pos_y(), camera.get_pos_z() - 1.1f,
        camera.get_pos_x(), camera.get_pos_y(), -1.1f,
        0.0,1.0,0.0
  );
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glEnable(GL_BLEND);
  if (!performance_mode)
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  if (!performance_mode)
  {
    glDisable(GL_DEPTH_TEST);
    glDepthMask(GL_FALSE);
    glColor4f(1,1,1,1);
    if (!mtex.bind())
    vsx_widget_skin::get_instance()->set_color_gl(13);
      glBegin(GL_QUADS);
        glTexCoord2f(0, 0);
        glVertex3f(pos.x-size.x/2,pos.y-size.y/2,-10.0f);
        glTexCoord2f(0, 1);
        glVertex3f(pos.x-size.x/2,pos.y+size.y/2,-10.0f);
        glTexCoord2f(1, 1);
        glVertex3f(pos.x+size.x/2,pos.y+size.y/2,-10.0f);
        glTexCoord2f(1, 0);
        glVertex3f(pos.x+size.x/2,pos.y-size.y/2,-10.0f);
      glEnd();
    mtex._bind();
  }
  draw_children();
}
Exemple #11
0
void gActionChannel::draw() {

	/* draw basic boundaries (+ beat bars) and hide the unused area. Then
	 * draw the children (the actions) */

	baseDraw();

	/* print label */

	fl_color(COLOR_BG_1);
	fl_font(FL_HELVETICA, 12);
	if (active())
		fl_draw("actions", x()+4, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_CENTER));  /// FIXME h() is too much!
	else
		fl_draw("actions (disabled)", x()+4, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_CENTER));  /// FIXME h() is too much!

	fl_rectf(pParent->coverX, y()+1, pParent->totalWidth-pParent->coverX+x(), h()-2, COLOR_BG_1);

	draw_children();
}
Exemple #12
0
static void
cache_draw(struct lstopo_output *loutput, hwloc_obj_t level, unsigned depth, unsigned x, unsigned y)
{
  struct lstopo_obj_userdata *lud = level->userdata;
  unsigned gridsize = loutput->gridsize;
  unsigned fontsize = loutput->fontsize;
  unsigned myheight = fontsize + gridsize + FONTGRIDSIZE; /* totheight also contains children outside of this actual cache box */

  if (loutput->drawing == LSTOPO_DRAWING_PREPARE) {
    /* compute children size and position, our size, and save it */
    prepare_text(loutput, level);
    lud->width = lud->textwidth + gridsize + FONTGRIDSIZE;
    lud->height = myheight;
    place_children(loutput, level,
		   0, myheight + gridsize);

  } else { /* LSTOPO_DRAWING_DRAW */
    struct draw_methods *methods = loutput->methods;
    struct lstopo_style style;
    unsigned totwidth;
    unsigned myoff = 0;

    /* restore our size that was computed during prepare */
    totwidth = lud->width;

    if (lud->above_children.kinds) {
      /* display above_children even above the cache itself */
      myoff = lud->above_children.height + gridsize;
      lud->above_children.yrel = 0;
    }

    lstopo_set_object_color(loutput, level, &style);
    methods->box(loutput, &style.bg, depth, x, totwidth, y + myoff, myheight);

    draw_text(loutput, level, &style.t, depth-1, x + gridsize, y + gridsize + myoff);

    /* Draw sublevels for real */
    draw_children(loutput, level, depth-1, x, y);
  }
}
Exemple #13
0
int
main(int argc, char ** argv)
{
   // Space for the children
   struct Exclamation children[STEPCHILDREN];
   // The parent
   struct Exclamation parent;

   // The handle
   int handle;

   // The parameters for the children
   float width, height, xGap, ySlot;
 
   parent.height = 160;
   parent.width = 20;
   parent.bottom = -79;
   parent.left = -8;

   // Get the paramters for a fractal step
   child_params(&parent,
         &width, &height,
         &xGap, &ySlot);

   // Recurse one step
   fractal_step(width, height, 
         parent.left, parent.bottom, 
         xGap, ySlot,
         children);

   handle = start_drawing();
  
   draw_children(STEPCHILDREN, children);

   stop_drawing(handle);

   return 0;
}
Exemple #14
0
Fichier : Panner.C Projet : 0mk/non
void
Panner::draw ( void )
{
    int tw, th, tx, ty;

    bbox( tx, ty, tw, th );

    fl_push_clip( x(),y(),w(),h() );

    draw_the_box( tx, ty, tw, th );

//    draw_box();
    draw_label();

    /* if ( _bypassed ) */
    /* { */
    /*     draw_box(); */
    /*     fl_color( 0 ); */
    /*     fl_font( FL_HELVETICA, 12 ); */
    /*     fl_draw( "(bypass)", x(), y(), w(), h(), FL_ALIGN_CENTER ); */
    /*     goto done; */
    /* } */
   
    /* tx += b; */
    /* ty += b; */
    /* tw -= b * 2; */
    /* th -= b * 2; */

    fl_line_style( FL_SOLID, 1 );

    fl_color( FL_WHITE );

    for ( unsigned int i = 0; i < _points.size(); i++ )
    {
        Point *p = &_points[i];

        if ( ! p->visible )
            continue;

        Fl_Color c = fl_color_add_alpha( p->color, 100 );

        fl_color(c);

        int px, py, pw, ph;
        point_bbox( p, &px, &py, &pw, &ph );
      
        {
            float po = 5;

            fl_push_clip( px - ( po * 12 ), 
                          py - ( po * 12 ),
                          pw + ( po * 24 ), ph + (po * 24 ));

            fl_pie( px + 5, py + 5, pw - 10, ph - 10, 0, 360 );


            fl_pie( px, py, pw, ph, 0, 360 );

            fl_pop_clip();

            if ( projection() == POLAR )
            {
           
                fl_color( fl_color_average( fl_rgb_color( 127,127,127 ), p->color, 0.50 ) );
                fl_begin_loop();
                fl_circle( tx + tw/2, ty + th/2, tw/2.0f * ( ( p->radius() / range() )));
                fl_end_loop();
            }

        }
    
        const char *s = p->label;

        fl_color( fl_color_add_alpha( fl_rgb_color( 220,255,255 ), 127 ) );
        fl_font( FL_HELVETICA_BOLD_ITALIC, 10 );
        fl_draw( s, px + 20, py + 1, 50, ph - 1, FL_ALIGN_LEFT );

        if ( tw > 100 )
        {
            char pat[50];
            snprintf( pat, sizeof(pat), "%.1f°:%.1f° %.1fm", p->azimuth(), p->elevation(), p->radius() );
            
//        fl_color( fl_color_add_alpha( fl_rgb_color( 220,255,255 ), 127 ) );
            fl_font( FL_COURIER, 9 );

            fl_draw( pat, px + 20, py + 15, 50, ph - 1, FL_ALIGN_LEFT | FL_ALIGN_WRAP );

            /* fl_font( FL_HELVETICA_ITALIC, 9 ); */
            /* snprintf(pat, sizeof(pat), "range: %.1f meters", range() ); */
            /* fl_draw( pat, tx, ty, tw, th, FL_ALIGN_LEFT | FL_ALIGN_BOTTOM | FL_ALIGN_INSIDE ); */
                
            /* if ( _projection == POLAR ) */
            /* { */
            /*     fl_draw( "Polar perspective; azimuth, elevation and radius input. Right click controls radius.", tx, ty, tw, th, FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE ); */
            /* } */
            /* else */
            /* { */
            /*     fl_draw( "Polar orthographic; angle and distance input.", tx, ty, tw, th, FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE ); */
            /* } */
        }

    }
    
    if ( tw > 200 )
        draw_children();

    fl_line_style( FL_SOLID, 0 );

    fl_pop_clip();
}
void vsx_widget_controller_dialog::draw() //include first, don't forget to add draw_children(); to the end of inheriting method
{
  vsx_widget_controller_base::draw();
  draw_children();
}
Exemple #16
0
void slot_button::draw(const viewing_gui_context& context, const const_this_in_container& this_id, augs::gui::draw_info info) {
	if (!this_id->get_flag(augs::gui::flag::ENABLE_DRAWING)) {
		return;
	}

	const auto& step = context.get_step();
	const auto& cosmos = step.get_cosmos();

	const auto slot_id = cosmos[this_id.get_location().slot_id];
	const bool is_hand_slot = slot_id.is_hand_slot();
	const auto& detector = this_id->detector;

	rgba inside_col, border_col;
	
	if (slot_id->for_categorized_items_only) {
		inside_col = violet;
	}
	else {
		inside_col = cyan;
	}

	border_col = inside_col;
	inside_col.a = 4 * 5;
	border_col.a = 220;

	if (detector.is_hovered || detector.current_appearance == augs::gui::appearance_detector::appearance::pushed) {
		inside_col.a = 12 * 5;
		border_col.a = 255;
	}

	const auto inside_tex = assets::texture_id::ATTACHMENT_CIRCLE_FILLED;
	const auto border_tex = assets::texture_id::ATTACHMENT_CIRCLE_BORDER;

	const augs::gui::material inside_mat(inside_tex, inside_col);
	const augs::gui::material border_mat(border_tex, border_col);

	if (slot_id->always_allow_exactly_one_item) {
		draw_centered_texture(context, this_id, info, inside_mat);
		draw_centered_texture(context, this_id, info, border_mat);

		const auto slot_type = slot_id.get_id().type;

		if (slot_type == slot_function::PRIMARY_HAND) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::PRIMARY_HAND_ICON, border_col), vec2i(1, 0));
		}

		if (slot_type == slot_function::SECONDARY_HAND) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::SECONDARY_HAND_ICON, border_col));
		}

		if (slot_type == slot_function::SHOULDER_SLOT) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::SHOULDER_SLOT_ICON, border_col));
		}

		if (slot_type == slot_function::TORSO_ARMOR_SLOT) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::ARMOR_SLOT_ICON, border_col));
		}

		if (slot_type == slot_function::GUN_CHAMBER) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::CHAMBER_SLOT_ICON, border_col));
		}

		if (slot_type == slot_function::GUN_MUZZLE) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::GUN_MUZZLE_SLOT_ICON, border_col));
		}

		if (slot_type == slot_function::GUN_DETACHABLE_MAGAZINE) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::DETACHABLE_MAGAZINE_ICON, border_col));
		}
	}
	else {
		draw_centered_texture(context, this_id, info, inside_mat);
		draw_centered_texture(context, this_id, info, border_mat);

		const auto space_available_text = augs::gui::text::format(to_wstring(slot_id.calculate_free_space_with_parent_containers() / long double(SPACE_ATOMS_PER_UNIT), 2, true)
			, augs::gui::text::style(assets::font_id::GUI_FONT, border_col));

		augs::gui::text_drawer space_caption;
		space_caption.set_text(space_available_text);
		space_caption.center(context.get_tree_entry(this_id).get_absolute_rect());
		space_caption.draw(info);

		draw_children(context, this_id, info);
	}

	if (slot_id.get_container().get_owning_transfer_capability() != slot_id.get_container()) {
		const_dereferenced_location<item_button_in_item> child_item_button 
			= context.dereference_location(item_button_in_item{ slot_id.get_container().get_id() });

		draw_pixel_line_connector(context.get_tree_entry(this_id).get_absolute_rect(), context.get_tree_entry(child_item_button).get_absolute_rect(), info, border_col);
	}
}
void Flu_Toggle_Group :: draw()
{
  int lblW = 0, lblH, X, i;

  if( label() == 0 )
    lblW = lblH = 0;
  else if( strlen( label() ) == 0 )
    lblW = lblH = 0;
  else
    {
      measure_label( lblW, lblH );
      lblW += 18;
      lblH += 2;
    }

  // align the label
  if( align() & FL_ALIGN_LEFT )
    X = 4;
  else if( align() & FL_ALIGN_RIGHT )
    X = w() - lblW - 8;
  else
    X = w()/2 - lblW/2 - 2;

  // draw the main group box
  if( damage() & ~FL_DAMAGE_CHILD )
    fl_draw_box( box(), x(), y()+lblH/2, w(), h()-lblH/2, color() );

  unsigned char *active = 0;
  if( !chkBtn->value() )
    {
      active = (unsigned char*)malloc( children() );
      for( i = 1; i < children(); i++ )
	{
	  active[i-1] = child(i)->active();
	  child(i)->deactivate();
	}
    }

  // clip and draw the children
  chkBtn->resize( chkBtn->x(), chkBtn->y(), 0, 0 );
  fl_clip( x()+2, y()+lblH+1, w()-4, h()-lblH-3 );
  draw_children();
  fl_pop_clip();

  // clear behind the button and draw it
  fl_color( color() );
  fl_rectf( x()+X, y(), lblW+4, lblH );
  fl_color( labelcolor() );
  chkBtn->label( label() );
  chkBtn->resize( x()+X+2, y(), lblW, lblH );
  draw_child( *chkBtn );

  if( !chkBtn->value() )
    {
      for( i = 1; i < children(); i++ )
	{
	  if( active[i-1] )
	    child(i)->activate();
	  else
	    child(i)->deactivate();
	}
      free( active );
    }
}
Exemple #18
0
// Draw the block window...
void BlockWindow::draw() {
	int		j, k, xx, yy;
	Block		*b;
	Column	*c;

	// Draw the blocks...
	fl_color(FL_BLACK);
	fl_rectf(0, 0, w(), h());

	// Draw the blocks...
	for (j = num_columns_, c = columns_; j > 0; j --, c ++)
		for (k = c->num_blocks, b = c->blocks; k > 0; k --, b ++) {
			xx = w() - c->x;
			yy = h() - BLOCK_SIZE - b->y;

			if (b->color >= BLOCK_BLAST) {
				b->color ++;
				blast_pixmap.draw(xx, yy);
			} else if (b->color < 0) {
				if (b->bomb) bomb_pixmaps[-b->color - 1]->draw(xx, yy);
				else normal_pixmaps[-b->color - 1]->draw(xx, yy);
			} else {
				if (b->bomb) bomb_pixmaps[b->color - 1]->draw(xx, yy);
				else normal_pixmaps[b->color - 1]->draw(xx, yy);
			}
		}

	if (interval_ < 0.0 || paused_) {
		fl_color(FL_BLACK);
		screen_tile.draw(0, 0, w(), h(), 0, 0);
	}

	// Redraw the widgets...
	play_button_->redraw();
	help_button_->redraw();
	draw_children();

	// Draw any paused/game over/new game message...
	if ((paused_ || interval_ < 0.0) && play_button_->w() == 80) {
		const char *s;

		if (help_) {
			s = "Click on adjacent blocks of the same color. Clear all blocks "
				"before they reach the left side.";

			fl_font(FL_HELVETICA_BOLD, 24);
			fl_color(FL_BLACK);
			fl_draw(s, 171, 3, w() - 250, h() - 6,
					(Fl_Align)(FL_ALIGN_WRAP | FL_ALIGN_LEFT));

			fl_color(FL_YELLOW);
			fl_draw(s, 168, 0, w() - 250, h(),
					(Fl_Align)(FL_ALIGN_WRAP | FL_ALIGN_LEFT));
		} else {
			if (interval_ < 0.0) {
#ifdef DEBUG
				// Show sample waveform...
				short *sample_ptr;

				for (i = 0; i < 2; i ++)
				{
					fl_color(FL_RED + i);
					fl_begin_line();
					for (j = 0, sample_ptr = sound_->sample_data + i;
							j < sound_->sample_size;
							j ++, sample_ptr += 2)
						fl_vertex(j * w() / sound_->sample_size,
								*sample_ptr * h() / 4 / 65534 + h() / 2);
					fl_end_line();
				}
#endif // DEBUG

				if (num_columns_ && (time(NULL) & 7) < 4) s = "Game Over";
				else s = "Block Attack!\nby Michael R Sweet";
			} else s = "Paused";

			fl_font(FL_HELVETICA_BOLD, 32);
			fl_color(FL_BLACK);
			fl_draw(s, 6, 6, w() - 6, h() - 6, FL_ALIGN_CENTER);

			fl_color(FL_YELLOW);
			fl_draw(s, 0, 0, w(), h(), FL_ALIGN_CENTER);
		}
	}

	// Draw the scores and level...
	char s[255];

	sprintf(s, " Score: %d", score_);
	fl_color(FL_WHITE);
	fl_font(FL_HELVETICA, 14);
	fl_draw(s, 40, 0, w() - 40, 20, FL_ALIGN_LEFT);

	sprintf(s, "High Score: %d ", high_score_);
	fl_draw(s, 0, 0, w(), 20, FL_ALIGN_RIGHT);

	if (level_ > 1 || title_y_ <= 0)
	{
		sprintf(s, "Level: %d ", level_);
		fl_draw(s, 0, 0, w(), 20, FL_ALIGN_CENTER);
	}

	if (title_y_ > 0 && interval_ > 0.0)
	{
		int sz = 14 + title_y_ * 86 / h();

		fl_font(FL_HELVETICA_BOLD, sz);
		fl_color(FL_YELLOW);
		fl_draw(title_, 0, title_y_, w(), sz, FL_ALIGN_CENTER);
	}
}
Exemple #19
0
static void
bridge_draw(struct lstopo_output *loutput, hwloc_obj_t level, unsigned depth, unsigned x, unsigned y)
{
  struct lstopo_obj_userdata *lud = level->userdata;
  unsigned gridsize = loutput->gridsize;
  unsigned fontsize = loutput->fontsize;
  unsigned speedwidth = fontsize ? fontsize + gridsize : 0;

  if (loutput->drawing == LSTOPO_DRAWING_PREPARE) {
    /* compute children size and position, our size, and save it */
    lud->width = 2*gridsize + gridsize + speedwidth;
    lud->height = gridsize + FONTGRIDSIZE;
    place_children(loutput, level,
		   3*gridsize + speedwidth, 0);

  } else { /* LSTOPO_DRAWING_DRAW */
    struct draw_methods *methods = loutput->methods;
    struct lstopo_style style;

    /* Square and left link */
    lstopo_set_object_color(loutput, level, &style);
    methods->box(loutput, &style.bg, depth, x, gridsize, y + BRIDGE_HEIGHT/2 - gridsize/2, gridsize);
    methods->line(loutput, &BLACK_COLOR, depth, x + gridsize, y + BRIDGE_HEIGHT/2, x + 2*gridsize, y + BRIDGE_HEIGHT/2);

    if (level->io_arity > 0) {
      hwloc_obj_t child = NULL;
      unsigned ymax = -1;
      unsigned ymin = (unsigned) -1;
      int ncstate;
      while ((child=next_child(loutput, level, LSTOPO_CHILD_KIND_ALL, child, &ncstate)) != NULL) {
	struct lstopo_obj_userdata *clud = child->userdata;
	unsigned ymid = y + clud->yrel + BRIDGE_HEIGHT/2;
	/* Line to PCI device */
	methods->line(loutput, &BLACK_COLOR, depth-1, x+2*gridsize, ymid, x+3*gridsize+speedwidth, ymid);
	if (ymin == (unsigned) -1)
	  ymin = ymid;
	ymax = ymid;
	/* Negotiated link speed */
	if (fontsize) {
	  float speed = 0.;
	  if (child->type == HWLOC_OBJ_PCI_DEVICE)
	    speed = child->attr->pcidev.linkspeed;
	  if (child->type == HWLOC_OBJ_BRIDGE && child->attr->bridge.upstream_type == HWLOC_OBJ_BRIDGE_PCI)
	    speed = child->attr->bridge.upstream.pci.linkspeed;
	  if (loutput->show_attrs[HWLOC_OBJ_BRIDGE] && speed != 0.) {
	    char text[4];
	    if (speed >= 10.)
	      snprintf(text, sizeof(text), "%.0f", child->attr->pcidev.linkspeed);
	    else
	      snprintf(text, sizeof(text), "%0.1f", child->attr->pcidev.linkspeed);
	    methods->text(loutput, &style.t2, fontsize, depth-1, x + 3*gridsize, ymid - BRIDGE_HEIGHT/2, text);
	  }
	}
      }
      methods->line(loutput, &BLACK_COLOR, depth-1, x+2*gridsize, ymin, x+2*gridsize, ymax);

      /* Draw sublevels for real */
      draw_children(loutput, level, depth-1, x, y);
    }
  }
}
Exemple #20
0
/**
 * Draws given node as a node in a tree - first draws element,
 * then calls the draw function of all children
 */
int draw_node(Control* node, Control* parent) {
	if (draw_children(node, NULL )) {
		return draw_leaf(node, parent);
	}
	return 0;
}
Exemple #21
0
void item_button::draw_complete_with_children(draw_info in) {
	draw_children(in);
	draw_proc(in, true, true, true, false, false, true);
}
Exemple #22
0
void vsx_widget_desktop::draw() {
  if (!init_run) return;
  // this is designed to be root, so set up things

  // Deal with movement around the desktop

	#define SGN(N) (N >= 0 ? 1 : -1)
	#define MAX(N, M) ((N) >= (M) ? (N) : (M))
	#define MIN(N, M) ((N) <= (M) ? (N) : (M))
	#define CLAMP(N, L, U) (MAX(MIN((N), (U)), (L)))
	//if (logo_time > animlen) {
	if (!interpolating) {
		double acc = 4, dec = 3, spd = global_key_speed;
		// interpolation falloff control
		float tt = dtime*interpolation_speed*global_interpolation_speed;
		if (tt > 1) { tt = 1; }

		if(zpd != 0.0) {
			double sgn = SGN(zpd);
			zps += dtime * acc * sgn * global_interpolation_speed;
			zps = CLAMP(zps, -1.2f, 1.2f);
		}
		if(zpd == 0.0) {
			double sgn = SGN(zps);
			zps -= dtime * dec * sgn * global_interpolation_speed;
			zps = MAX(zps * sgn, 0) * sgn;
		}

		zp += zps * fabs(zp - 1.1)* spd * dtime + zpp*(zp - 1.0f);
		zpp = zpp*(1-tt);

		if (zp > 100) {zp = 100; zps = 0;}
		if (zp < 1.2) {zp = 1.2; zps = 0;}

		if(xpd != 0.0) {
			double sgn = SGN(xpd);
			xps += dtime * acc * sgn * global_interpolation_speed;
			xps = CLAMP(xps, -1, 1);
		}
		if(xpd == 0.0) {
			double sgn = SGN(xps);
			xps -= dtime * dec * sgn * global_interpolation_speed;
			xps = MAX(xps * sgn, 0) * sgn;
		}
		xp += xps * fabs(zp - 1.1)* spd * dtime*0.6 + xpp*(zp-1.0f);
		xpp = xpp*(1-tt);

		if (xp > 10) {xp = 10; xps = 0;}
		if (xp < -10) {xp = -10; xps = 0;}

		if(ypd != 0.0) {
			double sgn = SGN(ypd);
			yps += dtime * acc * sgn * global_interpolation_speed;
			yps = CLAMP(yps, -1, 1);
		}
		if(ypd == 0.0) {
			double sgn = SGN(yps);
			yps -= dtime * dec * sgn * global_interpolation_speed;
			yps = MAX(yps * sgn, 0) * sgn;
		}
		yp += yps * fabs(zp - 1.1)* spd * dtime*0.6 + ypp*(zp-1.0f);
		ypp = ypp*(1-tt);

		if (yp > 10) {yp = 10; yps = 0;}
		if (yp < -10) {yp = -10; yps = 0;}
//    			printf("xp: %f xps: %f xpd %f dt %f::",xp,xps,xpd,tt);

	}
	else {
		float tt = dtime*10.0f*global_interpolation_speed;
		if (tt > 1) { tt = 1; interpolating = false;}
		xp = xp*(1-tt)+camera_target.x*tt;
		yp = yp*(1-tt)+camera_target.y*tt;
		zp = zp*(1-tt)+camera_target.z*tt;
		if (
			(round(xp*2000) == round(camera_target.x*2000)) &&
			(round(yp*2000) == round(camera_target.y*2000)) &&
			(round(zp*2000) == round(camera_target.z*2000))
		) interpolating = false;
	}

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45,screen_x/screen_y,0.001,120.0);

	gluLookAt(xp,yp,zp-1.1f,xp,yp,-1.1f,0.0,1.0,0.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	// PERFORMANCE_MODE_CHANGE
	// if (performance_mode)
	//  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	//else
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	//
	//return;
	glEnable(GL_BLEND);
	//glClear(GL_COLOR_BUFFER_BIT);
	if (!performance_mode)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
//glEnable(GL_LINE_SMOOTH);
	if (!performance_mode)
	{
		glDisable(GL_DEPTH_TEST);
		glDepthMask(GL_FALSE);
		glColor4f(1,1,1,1);
		#ifndef VSXU_PLAYER
    if (!mtex.bind())
		#endif
    glColor4f(skin_color[13].r,skin_color[13].g,skin_color[13].b,skin_color[13].a);
    //else
     	glBegin(GL_QUADS);
      	glTexCoord2f(0, 0);
        glVertex3f(pos.x-size.x/2,pos.y-size.y/2,-10.0f);
      	glTexCoord2f(0, 1);
        glVertex3f(pos.x-size.x/2,pos.y+size.y/2,-10.0f);
      	glTexCoord2f(1, 1);
        glVertex3f(pos.x+size.x/2,pos.y+size.y/2,-10.0f);
      	glTexCoord2f(1, 0);
        glVertex3f(pos.x+size.x/2,pos.y-size.y/2,-10.0f);
      glEnd();
		#ifndef VSXU_PLAYER
    mtex._bind();
		#endif
	}
  draw_children();
}