implement pen and erase as strategy pattern introducing the CanvasMode classes

This commit is contained in:
2017-05-04 23:32:02 +01:00
parent 773ff61f92
commit 484bf6fab4
6 changed files with 162 additions and 68 deletions

View File

@@ -5,6 +5,7 @@
#include "shape.h"
#include "brush.h"
#include "action.h"
#include "canvas_modes.h"
NS_START
@@ -66,8 +67,17 @@ public:
Sampler m_sampler_mask;
glm::vec2 m_cam_rot;
float m_cam_fov = 85;
enum class kPenState { Draw, Erase, Line, Camera };
kPenState m_state{ kPenState::Draw };
enum class kCanvasMode { Draw, Erase, Line, Camera };
kCanvasMode m_state{ kCanvasMode::Draw };
static CanvasMode* modes[];
CanvasMode* m_mode;
static void set_mode(kCanvasMode mode)
{
I->m_mode = modes[(int)mode];
I->m_state = mode;
I->m_mode->canvas = I;
}
GLuint cube_id;
RTT m_latlong;
@@ -96,7 +106,6 @@ public:
void preview_generate();
};
class ActionStroke : public Action
{
public: