Untitled
unknown
plain_text
a year ago
3.0 kB
7
Indexable
#ifndef CONTROLLER_H #define CONTROLLER_H #include <GL/freeglut.h> #include "AppController.h" #include "ColorSelector.h" #include "Toolbar.h" #include "Canvas.h" #include "ColorPicker.h" #include "ColorViewer.h" struct Controller : public AppController { Toolbar toolbar; Canvas canvas; ColorSelector colorSelector; ColorPicker colorPicker; ColorViewer colorViewer; Controller(){ colorPicker = ColorPicker(-0.8, -0.81, 0.6, 0.18); colorViewer = ColorViewer(-0.1, -0.81, 0.18, 0.18); } void leftMouseDown( float x, float y ){ if (toolbar.contains(x, y)){ toolbar.handleMouseClick(x, y); } else if (canvas.contains(x, y)){ //canvas.handleMouseClick(x, y, toolbar.getSelectedTool(), colorSelector.getCurrentColor()); canvas.handleMouseClick(x, y, toolbar.getSelectedTool(), colorPicker.getCurrentColor()); } else if (colorSelector.contains(x, y)){ colorSelector.handleMouseClick(x, y); } // rbg sliders if ((colorPicker.insideButtonR(x, y) && colorPicker.insideBoundingBoxR(x, y)) || colorPicker.insideBoundingBoxR(x, y)){ colorPicker.handleMouseClick(x, y, 'r'); } if ((colorPicker.insideButtonG(x, y) && colorPicker.insideBoundingBoxG(x, y)) || colorPicker.insideBoundingBoxG(x, y)){ colorPicker.handleMouseClick(x, y, 'g'); } if ((colorPicker.insideButtonB(x, y) && colorPicker.insideBoundingBoxB(x, y)) || colorPicker.insideBoundingBoxB(x, y)){ colorPicker.handleMouseClick(x, y, 'b'); } // color viewer colorViewer.handleMouseClick(colorPicker.getR(), colorPicker.getG(), colorPicker.getB()); } void mouseMotion( float x, float y ) { if (canvas.contains(x, y)){ if (toolbar.getSelectedTool() == PENCIL || toolbar.getSelectedTool() == ERASER){ //canvas.handleMouseClick(x, y, toolbar.getSelectedTool(), colorSelector.getCurrentColor()); canvas.handleMouseClick(x, y, toolbar.getSelectedTool(), colorPicker.getCurrentColor()); } } // rbg sliders if ((colorPicker.insideButtonR(x, y) && colorPicker.insideBoundingBoxR(x, y)) || colorPicker.insideBoundingBoxR(x, y)){ colorPicker.handleMouseClick(x, y, 'r'); } if ((colorPicker.insideButtonG(x, y) && colorPicker.insideBoundingBoxG(x, y)) || colorPicker.insideBoundingBoxG(x, y)){ colorPicker.handleMouseClick(x, y, 'g'); } if ((colorPicker.insideButtonB(x, y) && colorPicker.insideBoundingBoxB(x, y)) || colorPicker.insideBoundingBoxB(x, y)){ colorPicker.handleMouseClick(x, y, 'b'); } // color viewer colorViewer.handleMouseClick(colorPicker.getR(), colorPicker.getG(), colorPicker.getB()); } void render(){ canvas.draw(); toolbar.draw(); colorSelector.draw(); colorPicker.draw(); colorViewer.draw(); } }; #endif
Editor is loading...
Leave a Comment