diff --git a/data/layout.xml b/data/layout.xml
index 775f905..4337143 100644
--- a/data/layout.xml
+++ b/data/layout.xml
@@ -332,7 +332,8 @@
-
+
+
@@ -341,6 +342,7 @@
+
diff --git a/engine/action.cpp b/engine/action.cpp
index 3109abc..4f3a7bf 100644
--- a/engine/action.cpp
+++ b/engine/action.cpp
@@ -1,5 +1,23 @@
#include "pch.h"
#include "log.h"
#include "action.h"
+#include "app.h"
ActionManager ActionManager::I;
+
+void ActionManager::add(Action *action)
+{
+ I.m_actions.emplace(action);
+ I.m_memory += action->memory();
+ LOG("History: %.2f KB", I.m_memory / 1024.f);
+ App::I.update_memory_usage(I.m_memory);
+}
+
+void ActionManager::undo()
+{
+ I.m_actions.top()->undo();
+ I.m_memory -= I.m_actions.top()->memory();
+ I.m_actions.pop();
+ LOG("History: %.2f KB", I.m_memory / 1024.f);
+ App::I.update_memory_usage(I.m_memory);
+}
diff --git a/engine/action.h b/engine/action.h
index 583ed8f..10a6768 100644
--- a/engine/action.h
+++ b/engine/action.h
@@ -15,19 +15,8 @@ public:
static ActionManager I;
std::stack> m_actions;
size_t m_memory = 0;
- static void add(Action* action)
- {
- I.m_actions.emplace(action);
- I.m_memory += action->memory();
- LOG("History: %.2f KB", I.m_memory / 1024.f);
- }
- static void undo()
- {
- I.m_actions.top()->undo();
- I.m_memory -= I.m_actions.top()->memory();
- I.m_actions.pop();
- LOG("History: %.2f KB", I.m_memory / 1024.f);
- }
+ static void add(Action* action);
+ static void undo();
static bool empty()
{
return I.m_actions.empty();
diff --git a/engine/app.cpp b/engine/app.cpp
index b6a385b..4375a66 100644
--- a/engine/app.cpp
+++ b/engine/app.cpp
@@ -584,6 +584,15 @@ void App::initLayout()
}
};
}
+ if (auto* button = layout[main_id]->find("btn-anim"))
+ {
+ button->on_click = [this,button](Node*) {
+ if (canvas)
+ {
+ //canvas->m_canvas->export_anim(data_path);
+ }
+ };
+ }
if (auto* button = layout[main_id]->find("btn-open"))
{
button->on_click = [this,button](Node*) {
@@ -946,3 +955,14 @@ void App::terminate()
color->clear_context();
stroke->clear_context();
}
+
+void App::update_memory_usage(size_t bytes)
+{
+ if (auto txt = layout[main_id]->find("txt-memory"))
+ {
+ static char buffer[128];
+ sprintf(buffer, "History memory: %.2f Kb", bytes / 1024.f);
+ txt->set_text(buffer);
+ layout[main_id]->update();
+ }
+}
diff --git a/engine/app.h b/engine/app.h
index 41ace1a..5c1aaf0 100644
--- a/engine/app.h
+++ b/engine/app.h
@@ -50,6 +50,7 @@ public:
void create();
void terminate();
void clear();
+ void update_memory_usage(size_t bytes);
void update(float dt);
void resize(float w, float h);
bool mouse_down(int button, float x, float y);
diff --git a/engine/canvas_modes.cpp b/engine/canvas_modes.cpp
index ef5e4ac..967e4d1 100644
--- a/engine/canvas_modes.cpp
+++ b/engine/canvas_modes.cpp
@@ -220,6 +220,8 @@ void CanvasModeGrid::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
break;
}
case kEventType::MouseCancel:
+ if (m_dragging)
+ m_lines.pop_back();
m_dragging = false;
node->mouse_release();
break;
@@ -280,13 +282,7 @@ void CanvasModeFill::init()
void CanvasModeFill::leave()
{
- auto drawer = [this](const glm::mat4& camera, const glm::mat4& proj) {
- ui::ShaderManager::use(ui::kShader::Color);
- ui::ShaderManager::u_mat4(ui::kShaderUniform::MVP, proj * camera);
- ui::ShaderManager::u_vec4(ui::kShaderUniform::Col, { node->m_brush.m_tip_color.rgb(), node->m_brush.m_tip_opacity });
- m_shape.draw_fill();
- };
- canvas->draw_objects(std::bind(drawer, std::placeholders::_1, std::placeholders::_2));
+ canvas->draw_objects(std::bind(&CanvasModeFill::on_Draw, this, glm::mat4(), std::placeholders::_1, std::placeholders::_2));
m_points.clear();
}
@@ -351,9 +347,12 @@ void CanvasModeFill::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
break;
}
case kEventType::MouseCancel:
+ if (m_dragging)
+ m_points.pop_back();
m_dragging = false;
node->mouse_release();
- m_points.clear();
+ if (m_points.size() < 4)
+ m_points.clear();
break;
default:
break;
diff --git a/engine/rtt.cpp b/engine/rtt.cpp
index e998aa5..443eed1 100644
--- a/engine/rtt.cpp
+++ b/engine/rtt.cpp
@@ -25,6 +25,7 @@ void RTT::destroy()
{
unbindTexture();
glDeleteTextures(1, &texID);
+ LOG("TEX rtt destroy %d", texID)
}
if (fboID)
{
@@ -32,6 +33,7 @@ void RTT::destroy()
glDeleteFramebuffers(1, &fboID);
LOG("RTT DESTROY %d", fboID);
}
+ texID = 0;
fboID = 0;
rboID = 0;
// w = 0;
@@ -49,6 +51,7 @@ bool RTT::create(int width, int height, int tex/* = -1*/)
if (tex == -1)
{
glGenTextures(1, &texID);
+ LOG("TEX rtt create %d", texID);
}
else
{
diff --git a/engine/rtt.h b/engine/rtt.h
index 83efdbd..6972b14 100644
--- a/engine/rtt.h
+++ b/engine/rtt.h
@@ -4,9 +4,9 @@ class RTT
{
bool bound = false;
GLint oldFboID = 0;
- GLuint fboID;
- GLuint rboID;
- GLuint texID;
+ GLuint fboID = 0;
+ GLuint rboID = 0;
+ GLuint texID = 0;
int w;
int h;
diff --git a/engine/texture.cpp b/engine/texture.cpp
index 4e4e59c..e02158a 100644
--- a/engine/texture.cpp
+++ b/engine/texture.cpp
@@ -41,7 +41,7 @@ bool Texture2D::create(int width, int height, GLint internal_format, GLint forma
m_format = format;
m_iformat = internal_format;
glGenTextures(1, &m_tex);
- LOG("genTex %d", m_tex);
+ LOG("TEX create %d", m_tex);
bind();
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
unbind();