void EditRatioWindow::draw(DrawBuf buf,bool) const { if( pane.dx<10 || pane.dy<10 ) return; MCoord w=+cfg.width; VColor face=+cfg.face; VColor gray=+cfg.gray; SmoothDrawArt art(buf.cut(pane)); MPane p(pane); FigureBox fig(p); // body { fig.solid(art,+cfg.back); buf.erase(shade1,gray); buf.erase(shade2,gray); } // length { Coord d=RoundUpLen(w); MPoint endA=base.addX(Cap<Coord>(-base.x+d,a,base.x+1+d)); MPoint endB=base.subY(b); art.ball(base,2*w,face); art.ball(endA,2*w,face); art.ball(endB,2*w,face); art.path(w,face,base,endA); art.path(w,face,base,endB); } // text { char temp[TextBufLen]; PrintBuf out(Range(temp)); Printf(out,"#;/#;",a,b); cfg.font->text(buf,text,TextPlace(AlignX_Center,AlignY_Top),out.close(),+cfg.text); } // border { VColor vc = focus? +cfg.focus : ( hilight? +cfg.hilight : +cfg.border ) ; fig.loop(art,HalfPos,w,vc); } }
void PointEditWindow::drawBack(DrawBuf buf,bool) const { SmoothDrawArt art(buf); Pane pane=Envelope(pos,pos+getPoint()); MCoord width=+cfg.width; FigureBox fig(pane); fig.loop(art,HalfPos,width,+cfg.line); }
void InfoShape::draw(const DrawBuf &buf) const { if( !pane ) return; Smooth::DrawArt art(buf); VColor text=enable?+cfg.text:+cfg.inactive; Point space=+cfg.space; // decor { MPane p(pane); MCoord width=+cfg.width; MCoord dx=Fraction(space.x)-width; MCoord dy=Fraction(space.y)-width; if( focus ) { FigureBox fig(p.shrink(Fraction(space.x)/2,Fraction(space.y)/2)); fig.loop(art,width,+cfg.focus); } if( xoff>0 ) { FigureLeftMark fig(p,dx); fig.solid(art,text); } if( xoff<xoffMax ) { FigureRightMark fig(p,dx); fig.solid(art,text); } if( yoff>0 ) { FigureUpMark fig(p,dy); fig.solid(art,text); } if( yoff<yoffMax ) { FigureDownMark fig(p,dy); fig.solid(art,text); } } // text { Pane inner=pane.shrink(space); if( !inner ) return; ulen count=info->getLineCount(); ulen index=yoff; Font font=cfg.font.get(); FontSize fs=font->getSize(); DrawBuf tbuf=buf.cutRebase(inner); Pane row(-xoff,0,IntAdd(xoff,inner.dx),fs.dy); for(; index<count && row.y+row.dy<=inner.dy ;index++,row.y+=row.dy) { font->text(tbuf,row,TextPlace(AlignX_Left,AlignY_Top),info->getLine(index),text); } } }
void ButtonShape::draw(const DrawBuf &buf) const { MPane p(pane); if( !p ) return; Smooth::DrawArt art(buf); Font font=cfg.font.get(); // figure MCoord width=+cfg.width; FontSize fs=font->getSize(); MCoord ex=(Fraction(fs.dy)+2*width)/4; FigureButton fig(p,ex); VColor bottom=+cfg.bottom; // body if( down ) { fig.curveSolid(art,bottom); } else { VColor top; if( mover && enable ) top=+cfg.topUp; else top=+cfg.top; fig.curveSolid(art,TwoField(p.getTopLeft(),top,p.getBottomLeft(),bottom)); } // text { Coord dx=RoundUpLen(ex); Coord dy=RoundUpLen(width); Point shift=Null; if( down ) shift=Point::Diag( (dy+1)/2 ); VColor text=enable?+cfg.text:bottom; font->text(buf,pane.shrink(dx,dy)+shift,TextPlace(AlignX_Center,AlignY_Center),Range(face),text); } // border { VColor border; if( focus ) { border=+cfg.focus; } else { if( enable ) border=+cfg.border; else border=bottom; } fig.curveLoop(art,HalfPos,width,border); } }
void ScrollListShape::draw(const DrawBuf &buf) const { if( !pane ) return; SmoothDrawArt art(buf.cut(pane)); art.block(pane,+cfg.back); VColor text = enable? +cfg.text : +cfg.inactive ; VColor title = enable? +cfg.title : +cfg.inactive ; VColor gray=+cfg.gray; VColor snow=+cfg.snow; Point space=+cfg.space; // decor { MPane p(pane); MCoord width=+cfg.width; MPoint s(space); FigureTopBorder fig_top(p,width); fig_top.solid(art,gray); FigureBottomBorder fig_bottom(p,width); fig_bottom.solid(art,snow); if( focus ) { FigureBox fig(p.shrink(s/2)); fig.loop(art,width,+cfg.focus); } MCoord dx=s.x-width; MCoord dy=s.y-width; if( xoff>0 ) { FigureLeftMark fig(p,dx); fig.solid(art,text); } if( xoff<xoffMax ) { FigureRightMark fig(p,dx); fig.solid(art,text); } if( yoff>0 ) { FigureUpMark fig(p,dy); fig.solid(art,text); } if( yoff<yoffMax ) { FigureDownMark fig(p,dy); fig.solid(art,text); } } // text { Pane inner=pane.shrink(space); if( !inner ) return; ulen count=info->getLineCount(); ulen index=yoff; Font font=cfg.font.get(); FontSize fs=font->getSize(); DrawBuf tbuf=buf.cut(inner); SmoothDrawArt tart(tbuf); Pane row=inner; row.dy=fs.dy; Coord pos_x=fs.dx0-xoff; Coord lim=inner.y+inner.dy; VColor titleTop=+cfg.titleTop; VColor titleBottom=+cfg.titleBottom; Coord off=fs.dy; for(; index<count && IntAdd(row.y,row.dy)<=lim ;index++,row.y+=row.dy) { if( enable && index==select ) tbuf.erase(row,+cfg.select); ComboInfoItem item=info->getLine(index); switch( item.type ) { case ComboInfoText : { font->text(tbuf,row,TextPlace(pos_x,AlignY_Top),item.text,text); } break; case ComboInfoTitle : { MPane p(row); TwoField field(p.getTopLeft(),titleTop,p.getBottomLeft(),titleBottom); FigureBox(p).solid(tart,field); font->text(tbuf,row,TextPlace(pos_x+off,AlignY_Top),item.text,title); } break; default: // case ComboInfoSeparator : { MPane p(row); MCoord delta=2*(p.dy/5); p=p.shrinkY(delta); TwoField field(p.getTopLeft(),snow,p.getBottomLeft(),gray); FigureBox(p).solid(tart,field); } } } } }
void CacheList::load_cache_prof_info(char *filename, level *lev) { int j; for (j=0; j<this->total; j++) if (list[j].last_access>=0) // reset all loaded cache items to 0, all non-load to -1 list[j].last_access=0; preload_cache(lev); // preliminary guesses at stuff to load int load_fail=1; bFILE *fp=open_file(filename,"rb"); if (!fp->open_failure()) { spec_directory sd(fp); spec_entry *se=sd.find("cache profile info"); // see if the cache profile info is in the file if (se) { fp->seek(se->offset,0); char name[255]; int tnames=0; int *fnum_remap; // remaps old filenumbers into current ones tnames=fp->read_uint16(); if (tnames) /// make sure there isn't bad info in the file { fnum_remap=(int *)malloc(sizeof(int)*tnames); int i; for (i=0; i<tnames; i++) { fp->read(name,fp->read_uint8()); fnum_remap[i]=-1; // initialize the map to no-map int j; for (j=0; j<crc_manager.total_filenames(); j++) if (!strcmp(crc_manager.get_filename(j),name)) fnum_remap[i]=j; } int tsaved = fp->read_uint32(); int *priority=(int *)malloc(tsaved*sizeof(int)); memset(priority,0xff,tsaved*sizeof(int)); // initialize to -1 int tmatches=0; sorted_id_list=(int *)malloc(sizeof(int)*total); for (j=0; j<total; j++) sorted_id_list[j]=j; qsort(sorted_id_list,total,sizeof(int),s_offset_compare); for (i=0; i<tsaved; i++) { fp->read_uint8(); // read type short file_num=fp->read_uint16(); if (file_num>=tnames) // bad data? file_num=-1; else file_num=fnum_remap[file_num]; uint32_t offset=fp->read_uint32(); // search for a match j=search(sorted_id_list,file_num,offset); if (j!=-1) { if (list[j].last_access<0) // if not loaded list[j].last_access=-2; // mark as needing loading else list[j].last_access=2; // mark as loaded and needing to stay that way priority[i]=j; tmatches++; } } free(sorted_id_list); // was used for searching, no longer needed for (j=0; j<total; j++) if (list[j].last_access==0) unmalloc(list+j); // free any cache entries that are not accessed at all in the level ful=0; int tcached=0; for (j=0; j<total; j++) // now load all of the objects until full { // stat_man->update(j*70/total+25); if (list[j].file_number>=0 && list[j].last_access==-2) { list[j].last_access=-1; if (!ful) { switch (list[j].type) { case SPEC_BACKTILE : backt(j); break; case SPEC_FORETILE : foret(j); break; case SPEC_CHARACTER : case SPEC_CHARACTER2 : fig(j); break; case SPEC_IMAGE : img(j); break; case SPEC_PARTICLE : part(j); break; case SPEC_EXTERN_SFX : sfx(j); break; case SPEC_EXTERNAL_LCACHE : lblock(j); break; case SPEC_PALETTE : ctint(j); break; } tcached++; } } } load_fail=0; // if (full()) // dprintf("Cache filled while loading\n"); if (tsaved>tmatches) tmatches=tsaved+1; last_access=tmatches+1; for (i=0; i<tsaved; i++) // reorder the last access of each cache to reflect prioirties { if (priority[i]!=-1) { if (list[priority[i]].last_access!=-1) // make sure this wasn't the last item list[priority[i]].last_access=tmatches--; } } free(priority); free(fnum_remap); } } } if (load_fail) // no cache file, go solely on above gueses { int j; for (j=0; j<total; j++) // now load all of the objects until full, don't free old stuff { // stat_man->update(j*70/total+25); if (list[j].file_number>=0 && list[j].last_access==-2) { list[j].last_access=-1; if (!ful) { switch (list[j].type) { case SPEC_BACKTILE : backt(j); break; case SPEC_FORETILE : foret(j); break; case SPEC_CHARACTER : case SPEC_CHARACTER2 : fig(j); break; case SPEC_IMAGE : img(j); break; case SPEC_PARTICLE : part(j); break; case SPEC_EXTERN_SFX : sfx(j); break; case SPEC_EXTERNAL_LCACHE : lblock(j); break; case SPEC_PALETTE : ctint(j); break; } } } } if (full()) dprintf("Cache filled while loading\n"); } delete fp; }
void YScrollShape::draw(const DrawBuf &buf) const { MPane p(pane); if( !p ) return; Smooth::DrawArt art(buf); MPoint a=p.getBase(); MPoint s=p.getSize(); art.block(pane,+cfg.back); if( s.y<5*s.x ) return; MCoord x0=a.x; MCoord x1=x0+s.x; MCoord y0=a.y; MCoord y1=y0+s.x; MCoord y5=y0+s.y; MCoord y4=y5-s.x; bool enable_=enable; MCoord y2; MCoord y3; if( page>=total ) { enable_=false; y2=y1; y3=y4; } else { ulen cap=total-page; ulen pos_=Min(pos,cap); MCoord len=Max(Position(page,total,0,y4-y1),s.x); y2=Position(pos_,cap,y1,y4-len); y3=y2+len; } MCoord width=+cfg.width; MCoord d=Max<MCoord>(s.x/6,width); VColor top=+cfg.top; VColor bottom=+cfg.bottom; VColor face=+cfg.face; VColor faceUp=+cfg.faceUp; VColor topf=focus?+cfg.focus:top; VColor eface=enable_?face:bottom; // down if( down==ScrollType_Down ) { FigureBox fig_box(x0,x1,y0,y1); fig_box.solid(art,bottom); FigureUpArrow fig(x0+d,x1-d,y0+d,y1-d); fig.transform(Smooth::DotShift(MPoint::Diag(width))); fig.curveSolid(art,eface); } else { FigureTopBorder fig_top(x0,x1,y0,y1,width); fig_top.solid(art,topf); FigureBottomBorder fig_bottom(x0,x1,y0,y1,width); fig_bottom.solid(art,bottom); FigureUpArrow fig(x0+d,x1-d,y0+d,y1-d); VColor fc; if( enable_ ) { if( mover==ScrollType_Down ) fc=faceUp; else fc=face; } else { fc=bottom; } fig.curveSolid(art,fc); } // up if( down==ScrollType_Up ) { FigureBox fig_box(x0,x1,y4,y5); fig_box.solid(art,bottom); FigureDownArrow fig(x0+d,x1-d,y4+d,y5-d); fig.transform(Smooth::DotShift(MPoint::Diag(width))); fig.curveSolid(art,eface); } else { FigureTopBorder fig_top(x0,x1,y4,y5,width); fig_top.solid(art,topf); FigureBottomBorder fig_bottom(x0,x1,y4,y5,width); fig_bottom.solid(art,bottom); FigureDownArrow fig(x0+d,x1-d,y4+d,y5-d); VColor fc; if( enable_ ) { if( mover==ScrollType_Up ) fc=faceUp; else fc=face; } else { fc=bottom; } fig.curveSolid(art,fc); } // down page { FigureBox fig_top(x0,x0+width,y1,y2); fig_top.solid(art,topf); FigureBox fig_bottom(x1-width,x1,y1,y2); fig_bottom.solid(art,bottom); } if( down==ScrollType_DownPage ) { MCoord e=Ratio(427,10)*s.x; FigureBox fig(x0+e,x1-e,y1,y2); fig.solid(art,face); } else { MCoord e=Ratio(3,3)*s.x; FigureBox fig(x0+e,x1-e,y1,y2); VColor fc; if( enable_ ) { if( mover==ScrollType_DownPage ) fc=faceUp; else fc=face; } else { fc=bottom; } fig.solid(art,fc); } // up page { FigureBox fig_top(x0,x0+width,y3,y4); fig_top.solid(art,topf); FigureBox fig_bottom(x1-width,x1,y3,y4); fig_bottom.solid(art,bottom); } if( down==ScrollType_UpPage ) { MCoord e=Ratio(427,10)*s.x; FigureBox fig(x0+e,x1-e,y3,y4); fig.solid(art,face); } else { MCoord e=Ratio(3,3)*s.x; FigureBox fig(x0+e,x1-e,y3,y4); VColor fc; if( enable_ ) { if( mover==ScrollType_UpPage ) fc=faceUp; else fc=face; } else { fc=bottom; } fig.solid(art,fc); } // drag { FigureBox fig(x0,x1,y2,y3); fig.solid(art,TwoField({x0,y0},top,{x1,y0},bottom)); } { MCoord e=s.x/3; MCoord a0=x0+e; MCoord a1=x0+s.x/2; MCoord a2=x1-e; MCoord f=(y3-y2)/4; MCoord b0=y2+f; MCoord b1=y2+(y3-y2)/2; MCoord b2=y3-f; VColor fc; if( enable_ ) { if( mover==ScrollType_Drag ) fc=faceUp; else fc=face; } else { fc=bottom; } if( b2-b0>2*(a2-a0) ) { MCoord c=(b2-b0)/2-(a2-a0); FigurePoints<6> fig; fig[0]={a0,b1-c}; fig[1]={a1,b0}; fig[2]={a2,b1-c}; fig[3]={a2,b1+c}; fig[4]={a1,b2}; fig[5]={a0,b1+c}; fig.solid(art,fc); } else { FigurePoints<4> fig; fig[0]={a0,b1}; fig[1]={a1,b0}; fig[2]={a2,b1}; fig[3]={a1,b2}; fig.solid(art,fc); } } }
void TextLineShape::draw(const DrawBuf &buf) const { MPane p(pane); if( !p ) return; SmoothDrawArt art(buf.cut(pane)); Font font=cfg.font.get(); // figure MCoord width=+cfg.width; FontSize fs=font->getSize(); MCoord ex=FigEX(fs.dy,width); if( ex>p.dx/3 ) { art.block(pane,+cfg.inactive); return; } FigureButton fig(p,ex); VColor text=+cfg.text; // body fig.curveSolid(art, alert? +cfg.alert : +cfg.back ); // text { Coord dx=RoundUpLen(ex+width); Coord dy=RoundUpLen(width); Pane inner=pane.shrink(dx,dy); Coord pos_x=fs.dx0-xoff; font->text(buf,inner,TextPlace(pos_x,AlignY_Center),this->text.str(), enable? text : +cfg.inactive ); } // border if( focus ) { fig.curveLoop(art,HalfPos,width,+cfg.focus); } else { auto fig_top=fig.getTop(); fig_top.curvePath(art,HalfPos,width,+cfg.gray); auto fig_bottom=fig.getBottom(); fig_bottom.curvePath(art,HalfPos,width,+cfg.snow); } // arrows { MCoord len=ex-width; MCoord y=p.y+p.dy/2; if( xoff>0 ) // Left { MCoord x=p.x+width; FigureLeftMark fig(x,y,len); fig.solid(art,text); } if( xoff<xoffMax ) // Right { MCoord x=p.ex-width; FigureRightMark fig(x,y,len); fig.solid(art,text); } } }
void output_draw(struct lstopo_output *output) { output_compute_pu_min_textwidth(output); fig(output->topology, output->methods, output->logical, output->legend, hwloc_get_root_obj(output->topology), output, 100, 0, 0); }