int main(int argc, char ** argv){ GLV top(drawCB); Window win(600, 400, "Example: Widgets", &top); sl1HS.interval(1,-1); sl1VS.interval(1,-1); sliders1.interval(1,-1); sg3.interval(20,-20); sl2.interval(20,-20); slRH.interval(2,-2); glv::Style::standard().color.set(StyleColor::BlackOnWhite); // glv::Style::standard().color.set(StyleColor::WhiteOnBlack); // glv::Style::standard().color.set(StyleColor::Gray); // glv::Style::standard().color.hsv(0.5,0.5,0.2); for(int i=0; i<pages; ++i){ top << groups[i].disable(Visible | HitTest).stretch(1,1); } fg.tension(1.); table << new Label("col span") << new Label("row span", true) << new Label("top-left") << new Label("top-center") << new Label("top-right") << new Label("center-left") << new Label("center-center") << new Label("center-right") << new Label("bottom-left") << new Label("bottom-center") << new Label("bottom-right"); table.arrange(); //table.enable(DrawBorder); plotXY.data().resize(Data::FLOAT, 2, 64); const float ffreq = 2*M_PI/(plotXY.data().size(1)-1); for(int i=0; i<plotXY.data().size(1); ++i){ float phs = i*ffreq; float sigX = (cos(phs) + 0.5*cos(2*phs))/(1+0.5); float sigY = (sin(phs) + 0.5*sin(2*phs))/(1+0.5); plotXY.data().assign(sigX, 0,i); plotXY.data().assign(sigY, 1,i); } plotXY.numbering(true); plotY.data() = plotXY.data().slice(0).shape(1,1,64).stride(2); plotX.data() = plotXY.data().slice(1).shape(1,64,1).stride(2); plotY.major(8,1).range(0, plotXY.data().size(1), 1); plotX.major(8,0).range(0, plotXY.data().size(1), 0); plotX.disable(glv::Controllable); // Produce matrix of values { dplot.data().resize(Data::FLOAT, 1,32,32); Data& data = dplot.data(); for(int j=0; j<data.size(2); ++j){ for(int i=0; i<data.size(1); ++i){ double y = double(j)/data.size(2)*2-1; double x = double(i)/data.size(1)*2-1; double r = (sin(hypot(x,y)*8)); data.assign(r, 0, i,j); } } } v3D << v3D2.pos(Place::BR).anchor(Place::BR); //btsLED.enable(Momentary); int i=-1; groups[++i]<< bt1.pos(Place::BL).anchor(Place::CC)(Event::MouseDrag, Behavior::mouseResize); groups[ i]<< bt2.pos(Place::BR, -4,0).anchor(Place::CC)(Event::MouseDrag, Behavior::mouseResize); groups[ i]<< (btl.pos(Place::TR, -4, 4).anchor(Place::CC) << new Label("OK", Place::CC, 0,0)); groups[++i]<< bts14.pos(Place::BR, -4,0).anchor(Place::CC); groups[ i]<< bts41.pos(Place::TL, 0, 4).anchor(Place::CC); groups[ i]<< bts44.pos(Place::BL).anchor(Place::CC); groups[ i]<< btsLED.padding(3).pos(Place::BL, bts44.w+4,0).anchor(Place::CC).enable(SelectOnDrag).disable(DrawGrid); groups[++i]<< fg.pos(Place::BL).anchor(Place::CC); // groups[++i]<< fontView.stretch(1,1); groups[++i]<< (new Label("Horizontal"))->pos(Place::BL).anchor(Place::CC); groups[ i]<< (new Label("Vertical", true))->pos(Place::BR,-16,0).anchor(Place::CC); groups[++i]<< nd1.pos(Place::BL).anchor(Place::CC); groups[ i]<< nd2.showSign(false).pos(Place::TL, 0, 4).anchor(Place::CC); groups[++i]<< sl1H.pos(Place::BL).anchor(Place::CC); groups[ i]<< sl1V.pos(Place::BR, -4,0).anchor(Place::CC); groups[ i]<< sl1HS.pos(Place::BL).anchor(Place::CC); sl1HS.top(sl1H.bottom()+4); groups[ i]<< sl1VS.pos(Place::BR, -4,0).anchor(Place::CC); sl1VS.right(sl1V.left()-4); groups[++i]<< sl2.pos(Place::BL).anchor(Place::CC); groups[++i]<< sg3.pos(Place::BL).anchor(Place::CC); groups[ i]<< sg4.pos(Place::TL, 0, 4).anchor(Place::CC); groups[++i]<< slRH.pos(Place::BL).anchor(Place::CC); groups[ i]<< slRV.pos(Place::BR, -4,0).anchor(Place::CC); groups[++i]<< sliders1.pos(Place::BR).anchor(Place::CC); groups[ i]<< sliders2.pos(Place::BL, 4,0).anchor(Place::CC); groups[++i]<< table.pos(Place::BC).anchor(Place::CC); groups[++i]<< plotXY.pos(Place::BL).anchor(Place::CC); groups[ i]<< plotX.pos(Place::TL, 0,4).anchor(Place::CC); groups[ i]<< plotY.pos(Place::BR,-4,0).anchor(Place::CC); groups[++i]<< dplot.pos(Place::CC).anchor(Place::CC); groups[++i]<< tv1.pos(Place::CC, 0,0).anchor(Place::CC); groups[++i]<< v3D.pos(Place::CC, 0,0).anchor(Place::CC); float y = 1./(tabs.size()*2), dy=2*y; tabs << (new Label("Button" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("Buttons" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("FunctionGraph" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("Label" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("NumberDialer" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("Slider" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("Slider2D" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("SliderGrid" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("SliderRange" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("Sliders" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("Table" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("Function Plots" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("Density Plot" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("TextView" ))->anchor(0.5, y).pos(Place::CC); y+=dy; tabs << (new Label("View3D" ))->anchor(0.5, y).pos(Place::CC); y+=dy; top << tabs; //tabs(Event::MouseDrag, Behavior::mouseResize); //#define PRINT_SIZE(x) printf("sizeof(%s) = %d\n", #x, sizeof(x)); //PRINT_SIZE(View) PRINT_SIZE(Notifier) PRINT_SIZE(Rect) Application::run(); }
void drawCB(View * v, GLV& g){ using namespace glv::draw; for(int i=0; i<tabs.size(); ++i) groups[i].property(Visible, tabs.getValue(i)); }