Пример #1
0
void Plot::onDraw(GLV& g){

	GraphicsData& gd = g.graphicsData();
	draw::color(colors().fore);

	{ pushGrid();
		for(unsigned i=0; i<plottables().size(); ++i){
			Plottable& p = *plottables()[i];
			if(mActive[i] && p.drawUnderGrid()){
				gd.reset();
				gd.colors()[0] = p.color();
				p.doPlot(gd, p.data().hasData() ? p.data() : data());
			}
		}

	popGrid(); }

	Grid::onDraw(g);

	draw::color(colors().fore);

	// push into grid space and call attached plottables
	{ pushGrid();
		for(unsigned i=0; i<plottables().size(); ++i){
			Plottable& p = *plottables()[i];
			if(mActive[i] && !p.drawUnderGrid()){
				gd.reset();
				gd.colors()[0] = p.color();
				p.doPlot(gd, p.data().hasData() ? p.data() : data());
			}
		}
	popGrid(); }
}
Пример #2
0
void ListView::onDraw(GLV& g){

	using namespace glv::draw;

	Indexer idx(data().size(0), data().size(1));
	float dx_ = dx(0);
	float dy_ = dy(1);
	
	while(idx()){
		int ix = idx[0];
		int iy = idx[1];
		
		float px = dx_ * ix;
		float py = dy_ * iy;

		if(selectedX() == ix && selectedY() == iy){
			color(colors().selection);
			draw::rectangle(px,py, px+dx_,py+dy_);
		}
		
		color(colors().text);
		lineWidth(1);
		
		//font().render(data().at<std::string>(ix,iy).c_str(), pixc(px+paddingX()), pixc(py+paddingY()));
		font().render(g.graphicsData(), data().at<std::string>(ix,iy).c_str(), px+paddingX(), py+paddingY());
	}
	
	Widget::onDraw(g);
}
Пример #3
0
void Label::onDraw(GLV& g){
	using namespace glv::draw;
	lineWidth(stroke());
	color(colors().text);
	if(mVertical){ translate(0,h); rotate(0,0,-90); }
	font().render(
		g.graphicsData(),
		data().toString().c_str(),
		paddingX(),
		paddingY()
	);
	//scale(mSize, mSize);
	//text(value().c_str());
}
Пример #4
0
	virtual void onDraw3D(GLV& g){
		using namespace glv::draw;
		translateZ(-3);
		rotateY(angle+=1);
		const int n=12;

		GraphicsData& buf = g.graphicsData();

		for(int i=0; i<n; ++i){
			float p = float(i)/n;
			float x = cos(p*6.283)*1.2;
			float z = sin(p*6.283)*1.2;
			
			buf.addVertex(x, -0.7, z);
			buf.addVertex(x, +0.7, z);
			buf.addColor(HSV(p,1,1));
			buf.addColor(0);
		}

		paint(Triangles, buf);
	}
Пример #5
0
void TextView::onDraw(GLV& g){
	using namespace draw;

	float padX = paddingX();
	float padY = paddingY();
	float addY =-4;//was -2		// subtraction from top since some letters go above cap

	float tl = mPos * font().advance('M') + padX;
//	float tr = tl + font().advance('M');
	float tt = addY + padY;
	float tb = tt + fabs(font().descent()+font().cap()) - addY;
	float strokeWidth = 1;
	
	// draw selection
	if(textSelected()){
		float sl, sr;
		if(mSel>0){
			sl = tl;
			sr = sl + mSel*font().advance('M');
		}
		else{
			sr = tl;
			sl = sr + mSel*font().advance('M');
		}
		color(colors().selection);
		rectangle(sl, tt, sr, tb);
	}

	// draw cursor
	if(mBlink<0.5 && enabled(Focused)){
		stroke(1);
		color(colors().text);
		shape(Lines, pixc(tl), tt, pixc(tl), tb);
	}

	draw::lineWidth(strokeWidth);
	color(colors().text);
//	font().render(mText.c_str(), pixc(padX), pixc(padY-1));
	font().render(g.graphicsData(), mText.c_str(), padX, padY-1);
}
Пример #6
0
void NumberDialers::onDraw(GLV& g){ //printf("% g\n", value());
	using namespace glv::draw;

	fitExtent();

	float dxCell= dx();
	float dyCell= dy();
	float dxDig = font().advance('M');

//	View::enable(DrawSelectionBox);
//	View::enable(DrawGrid);

	// draw box at position (only if focused)
	if(enabled(Focused)){

		float x = dxCell*selectedX() + paddingX()/1 - 1;
		//float y = dyCell*selectedY() + paddingY()/2;
		float y = dyCell*(selectedY()+0.5);
		float ty= font().cap()/2. + 3;

//		color(colors().fore, colors().fore.a*0.4);
		color(colors().selection);
		//rectangle(bx + dig()*dxDig, by, bx + (dig()+1)*dxDig, by + dyCell-0.5f);
		rectangle(x + dig()*dxDig, y-ty, x + (dig()+1)*dxDig, y+ty);
	}

	drawSelectionBox();
	drawGrid(g.graphicsData());

	lineWidth(1);

	if(mTextEntryMode){
		mTextEntry.extent(dxCell, dyCell);
		mTextEntry.pos(dxCell*selectedX(), dyCell*selectedY());
	}

	for(int i=0; i<sizeX(); ++i){
		for(int j=0; j<sizeY(); ++j){

			float cx = dxCell*i;	// left edge of cell
			float cy = dyCell*j;	// top edge of cell

			// draw number
			int vali = valInt(i,j);
			int absVal = vali < 0 ? -vali : vali;
			int msd = mNF;	// position from right of most significant digit

			if(absVal > 0){
				msd = (int)log10((double)absVal);
				int p = numDigits() - (mShowSign ? 2:1);
				msd = msd < mNF ? mNF : (msd > p ? p : msd);
			}

			if(mNI == 0) msd-=1;

			// Determine digit string
			char str[32];
			int ic = numDigits();
			str[ic] = '\0';
			for(int i=0; i<numDigits(); ++i) str[i]=' ';

			int power = 1;
			bool drawChar = false; // don't draw until non-zero or past decimal point

			if(mShowSign && vali < 0) str[0] = '-';

			for(int i=0; i<=msd; ++i){
				char c = '0' + (absVal % (power*10))/power;
				power *= 10;
				if(c!='0' || i>=mNF) drawChar = true;
				--ic;
				if(drawChar) str[ic] = c;
			}

			// Draw the digit string
			float tx = int(cx + paddingX());
			float ty = int(cy + paddingY());

			if(vali || !dimZero()){
				color(colors().text);
			} else {
				color(colors().text.mix(colors().back, 0.8));
			}
		//	printf("%s\n", str);
//			font().render(g.graphicsData(), str, pixc(tx), pixc(ty));
//			if(mNF>0) font().render(g.graphicsData(), ".", pixc(dxDig*(mNI+numSignDigits()-0.5f) + tx), pixc(ty));
			font().render(g.graphicsData(), str, tx, ty);
			if(mNF>0) font().render(g.graphicsData(), ".", dxDig*(mNI+numSignDigits()-0.5f) + tx, ty);
		}
	}
}