| @@ -1 +1 @@ | |||||
| Subproject commit 39c93d6aa2beae64e411feaef300e384196c1e64 | |||||
| Subproject commit 3562ad248c032f7906bde90b81d127009c7f3b43 | |||||
| @@ -45,7 +45,7 @@ app: app.cpp ../dpf/dgl/* | |||||
| color: color.cpp ../dpf/dgl/* | color: color.cpp ../dpf/dgl/* | ||||
| $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | ||||
| demo: demo.cpp ../dpf/dgl/* | |||||
| demo: demo.cpp widgets/* ../dpf/dgl/* | |||||
| $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ | ||||
| images: images.cpp images_res/* ../dpf/dgl/* | images: images.cpp images_res/* ../dpf/dgl/* | ||||
| @@ -67,14 +67,12 @@ public: | |||||
| protected: | protected: | ||||
| void onDisplay() override | void onDisplay() override | ||||
| { | { | ||||
| const int cx = getX(); | |||||
| const int cy = getY(); | |||||
| const int iconSize = getWidth(); | const int iconSize = getWidth(); | ||||
| glColor3f(0.027f, 0.027f, 0.027f); | glColor3f(0.027f, 0.027f, 0.027f); | ||||
| bg.draw(); | bg.draw(); | ||||
| bgIcon.setY(cy + curPage*iconSize + curPage + 1); | |||||
| bgIcon.setY(curPage*iconSize + curPage + 1); | |||||
| glColor3f(0.129f, 0.129f, 0.129f); | glColor3f(0.129f, 0.129f, 0.129f); | ||||
| bgIcon.draw(); | bgIcon.draw(); | ||||
| @@ -84,7 +82,7 @@ protected: | |||||
| if (curHover != curPage && curHover != -1) | if (curHover != curPage && curHover != -1) | ||||
| { | { | ||||
| Rectangle<int> rHover(cx + 1, cy + curHover*iconSize + curHover + 1, iconSize-2, iconSize-2); | |||||
| Rectangle<int> rHover(1, curHover*iconSize + curHover + 1, iconSize-2, iconSize-2); | |||||
| glColor3f(0.071f, 0.071f, 0.071f); | glColor3f(0.071f, 0.071f, 0.071f); | ||||
| rHover.draw(); | rHover.draw(); | ||||
| @@ -102,10 +100,10 @@ protected: | |||||
| const int pad = iconSize/2 - DemoArtwork::ico1Width/2; | const int pad = iconSize/2 - DemoArtwork::ico1Width/2; | ||||
| img1.drawAt(cx + pad, cy + pad); | |||||
| img2.drawAt(cx + pad, cy + pad + 1 + iconSize); | |||||
| img3.drawAt(cx + pad, cy + pad + 2 + iconSize*2); | |||||
| img4.drawAt(cx + pad, cy + pad + 3 + iconSize*3); | |||||
| img1.drawAt(pad, pad); | |||||
| img2.drawAt(pad, pad + 1 + iconSize); | |||||
| img3.drawAt(pad, pad + 2 + iconSize*2); | |||||
| img4.drawAt(pad, pad + 3 + iconSize*3); | |||||
| } | } | ||||
| bool onMouse(int button, bool press, int x, int y) override | bool onMouse(int button, bool press, int x, int y) override | ||||
| @@ -135,7 +133,7 @@ protected: | |||||
| bool onMotion(int x, int y) override | bool onMotion(int x, int y) override | ||||
| { | { | ||||
| if (getArea().contains(x, y)) | |||||
| if (contains(x, y)) | |||||
| { | { | ||||
| const int iconSize = getWidth(); | const int iconSize = getWidth(); | ||||
| @@ -172,19 +170,15 @@ protected: | |||||
| } | } | ||||
| } | } | ||||
| void onReshape(int, int) override | |||||
| void onReshape(int width, int height) override | |||||
| { | { | ||||
| const int cx = getX(); | |||||
| const int iconSize = getWidth(); | |||||
| bg = getArea(); | |||||
| bg.setSize(width, height); | |||||
| bgIcon.setX(cx+1); | |||||
| bgIcon.setWidth(iconSize-2); | |||||
| bgIcon.setHeight(iconSize-2); | |||||
| bgIcon.setWidth(width-2); | |||||
| bgIcon.setHeight(width-2); | |||||
| lineSep.setStartPos(iconSize+4, getY()); | |||||
| lineSep.setEndPos(iconSize+4, getHeight()); | |||||
| lineSep.setStartX(width+2); | |||||
| lineSep.setEndPos(width+2, height); | |||||
| } | } | ||||
| private: | private: | ||||
| @@ -216,10 +210,10 @@ public: | |||||
| wRects.hide(); | wRects.hide(); | ||||
| wShapes.hide(); | wShapes.hide(); | ||||
| wColor.setPos(80, 2); | |||||
| wImages.setPos(80, 2); | |||||
| wRects.setPos(80, 2); | |||||
| wShapes.setPos(80, 2); | |||||
| wColor.setX(80); | |||||
| wImages.setX(80); | |||||
| wRects.setX(80); | |||||
| wShapes.setX(80); | |||||
| wLeft.setPos(2, 2); | wLeft.setPos(2, 2); | ||||
| setSize(600, 500); | setSize(600, 500); | ||||
| @@ -236,7 +230,7 @@ public: | |||||
| wRects.setSize(size); | wRects.setSize(size); | ||||
| wShapes.setSize(size); | wShapes.setSize(size); | ||||
| wLeft.setSize(73, height); | |||||
| wLeft.setSize(73, height-4); | |||||
| Window::onReshape(width, height); | Window::onReshape(width, height); | ||||
| } | } | ||||
| @@ -116,16 +116,14 @@ protected: | |||||
| void onReshape(int, int) override | void onReshape(int, int) override | ||||
| { | { | ||||
| const int cx = getX(); | |||||
| const int cy = getY(); | |||||
| const int width = getWidth(); | const int width = getWidth(); | ||||
| const int height = getHeight(); | const int height = getHeight(); | ||||
| // full bg | // full bg | ||||
| bgFull = getArea(); | |||||
| bgFull = Rectangle<int>(0, 0, width, height); | |||||
| // small bg, centered 2/3 size | // small bg, centered 2/3 size | ||||
| bgSmall = Rectangle<int>(cx+width/6, cy+height/6, width*2/3, height*2/3); | |||||
| bgSmall = Rectangle<int>(width/6, height/6, width*2/3, height*2/3); | |||||
| } | } | ||||
| char cur; | char cur; | ||||
| @@ -144,45 +144,42 @@ private: | |||||
| void onDisplay() override | void onDisplay() override | ||||
| { | { | ||||
| const int cx = getX(); | |||||
| const int cy = getY(); | |||||
| switch (fImgTop3rd) | switch (fImgTop3rd) | ||||
| { | { | ||||
| case 1: | case 1: | ||||
| fImg1.drawAt(fImg1x+cx, kImg1y+cy); | |||||
| fImg1.drawAt(fImg1x, kImg1y); | |||||
| break; | break; | ||||
| case 2: | case 2: | ||||
| fImg2.drawAt(fImg2x+cx, kImg2y+cy); | |||||
| fImg2.drawAt(fImg2x, kImg2y); | |||||
| break; | break; | ||||
| case 3: | case 3: | ||||
| fImg3.drawAt(kImg3x+cx, fImg3y+cy); | |||||
| fImg3.drawAt(kImg3x, fImg3y); | |||||
| break; | break; | ||||
| }; | }; | ||||
| switch (fImgTop2nd) | switch (fImgTop2nd) | ||||
| { | { | ||||
| case 1: | case 1: | ||||
| fImg1.drawAt(fImg1x+cx, kImg1y+cy); | |||||
| fImg1.drawAt(fImg1x, kImg1y); | |||||
| break; | break; | ||||
| case 2: | case 2: | ||||
| fImg2.drawAt(fImg2x+cx, kImg2y+cy); | |||||
| fImg2.drawAt(fImg2x, kImg2y); | |||||
| break; | break; | ||||
| case 3: | case 3: | ||||
| fImg3.drawAt(kImg3x+cx, fImg3y+cy); | |||||
| fImg3.drawAt(kImg3x, fImg3y); | |||||
| break; | break; | ||||
| }; | }; | ||||
| switch (fImgTop1st) | switch (fImgTop1st) | ||||
| { | { | ||||
| case 1: | case 1: | ||||
| fImg1.drawAt(fImg1x+cx, kImg1y+cy); | |||||
| fImg1.drawAt(fImg1x, kImg1y); | |||||
| break; | break; | ||||
| case 2: | case 2: | ||||
| fImg2.drawAt(fImg2x+cx, kImg2y+cy); | |||||
| fImg2.drawAt(fImg2x, kImg2y); | |||||
| break; | break; | ||||
| case 3: | case 3: | ||||
| fImg3.drawAt(kImg3x+cx, fImg3y+cy); | |||||
| fImg3.drawAt(kImg3x, fImg3y); | |||||
| break; | break; | ||||
| }; | }; | ||||
| } | } | ||||
| @@ -48,8 +48,6 @@ public: | |||||
| protected: | protected: | ||||
| void onDisplay() override | void onDisplay() override | ||||
| { | { | ||||
| const int cx = getX(); | |||||
| const int cy = getY(); | |||||
| const int width = getWidth(); | const int width = getWidth(); | ||||
| const int height = getHeight(); | const int height = getHeight(); | ||||
| @@ -61,10 +59,10 @@ protected: | |||||
| // draw a 3x3 grid | // draw a 3x3 grid | ||||
| for (int i=0; i<3; ++i) | for (int i=0; i<3; ++i) | ||||
| { | { | ||||
| r.setX(cx + 3 + i*width/3); | |||||
| r.setX(3 + i*width/3); | |||||
| // 1st | // 1st | ||||
| r.setY(cy + 3); | |||||
| r.setY(3); | |||||
| if (fClicked[0+i]) | if (fClicked[0+i]) | ||||
| glColor3f(0.8f, 0.5f, 0.3f); | glColor3f(0.8f, 0.5f, 0.3f); | ||||
| @@ -74,7 +72,7 @@ protected: | |||||
| r.draw(); | r.draw(); | ||||
| // 2nd | // 2nd | ||||
| r.setY(cy + 3 + height/3); | |||||
| r.setY(3 + height/3); | |||||
| if (fClicked[3+i]) | if (fClicked[3+i]) | ||||
| glColor3f(0.8f, 0.5f, 0.3f); | glColor3f(0.8f, 0.5f, 0.3f); | ||||
| @@ -84,7 +82,7 @@ protected: | |||||
| r.draw(); | r.draw(); | ||||
| // 3rd | // 3rd | ||||
| r.setY(cy + 3 + height*2/3); | |||||
| r.setY(3 + height*2/3); | |||||
| if (fClicked[6+i]) | if (fClicked[6+i]) | ||||
| glColor3f(0.8f, 0.5f, 0.3f); | glColor3f(0.8f, 0.5f, 0.3f); | ||||
| @@ -100,8 +98,6 @@ protected: | |||||
| if (button != 1 || ! press) | if (button != 1 || ! press) | ||||
| return false; | return false; | ||||
| const int cx = getX(); | |||||
| const int cy = getY(); | |||||
| const int width = getWidth(); | const int width = getWidth(); | ||||
| const int height = getHeight(); | const int height = getHeight(); | ||||
| @@ -113,10 +109,10 @@ protected: | |||||
| // draw a 3x3 grid | // draw a 3x3 grid | ||||
| for (int i=0; i<3; ++i) | for (int i=0; i<3; ++i) | ||||
| { | { | ||||
| r.setX(cx + 3 + i*width/3); | |||||
| r.setX(3 + i*width/3); | |||||
| // 1st | // 1st | ||||
| r.setY(cy + 3); | |||||
| r.setY(3); | |||||
| if (r.contains(x, y)) | if (r.contains(x, y)) | ||||
| { | { | ||||
| @@ -126,7 +122,7 @@ protected: | |||||
| } | } | ||||
| // 2nd | // 2nd | ||||
| r.setY(cy + 3 + height/3); | |||||
| r.setY(3 + height/3); | |||||
| if (r.contains(x, y)) | if (r.contains(x, y)) | ||||
| { | { | ||||
| @@ -136,7 +132,7 @@ protected: | |||||
| } | } | ||||
| // 3rd | // 3rd | ||||
| r.setY(cy + 3 + height*2/3); | |||||
| r.setY(3 + height*2/3); | |||||
| if (r.contains(x, y)) | if (r.contains(x, y)) | ||||
| { | { | ||||
| @@ -83,22 +83,20 @@ protected: | |||||
| void onReshape(int, int) override | void onReshape(int, int) override | ||||
| { | { | ||||
| const int cx = getX(); | |||||
| const int cy = getY(); | |||||
| const int width = getWidth(); | const int width = getWidth(); | ||||
| const int height = getHeight(); | const int height = getHeight(); | ||||
| // background | // background | ||||
| bg = getArea(); | |||||
| bg = Rectangle<int>(0, 0, width, height); | |||||
| // rectangle | // rectangle | ||||
| rect = Rectangle<int>(cx+20, cy+10, width-40, height-20); | |||||
| rect = Rectangle<int>(20, 10, width-40, height-20); | |||||
| // center triangle | // center triangle | ||||
| tri = Triangle<int>(cx+width*0.5, cy+height*0.1, cx+width*0.1, cy+height*0.9, cx+width*0.9, cy+height*0.9); | |||||
| tri = Triangle<int>(width*0.5, height*0.1, width*0.1, height*0.9, width*0.9, height*0.9); | |||||
| // circle | // circle | ||||
| cir = Circle<int>(cx+width/2, cy+height*2/3, height/6, 300); | |||||
| cir = Circle<int>(width/2, height*2/3, height/6, 300); | |||||
| } | } | ||||
| private: | private: | ||||