fix texture id bug, few gestures bugs solved

This commit is contained in:
2017-05-12 01:30:56 +01:00
parent 6f785c1944
commit 6dbb8bf3a1
9 changed files with 58 additions and 26 deletions

View File

@@ -332,7 +332,8 @@
<button-custom id="menu-layers" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8" color=".1">
<text text="Layers" font-face="arial" font-size="11"/>
</button-custom>
<node height="100%" color="1" grow="1" justify="center" align="flex-end">
<node height="100%" color="1" grow="1" align="center" justify="flex-end" dir="row">
<text id="txt-memory" text="History memory: 0.0 Kb" font-face="arial" font-size="11" margin="0 20 0 0" color=".6 .6 .6 1"/>
<text text="PanoPainter 0.1.2 alpha" font-face="arial" font-size="11" margin="0 10 0 0" color=".2 .5 1 1"/>
</node>
</border>
@@ -341,6 +342,7 @@
<button id="btn-open" width="50" height="100%" margin="0 5 0 0" text="Open"/>
<button id="btn-save" width="50" height="100%" margin="0 5 0 0" text="Save"/>
<button id="btn-export" width="50" height="100%" margin="0 5 0 0" text="Export"/>
<button id="btn-anim" width="50" height="100%" margin="0 5 0 0" text="Anim"/>
<button id="btn-clear" width="50" height="100%" margin="0 5 0 15" text="Clear"/>
<button-custom id="btn-bucket" width="50" height="100%" margin="0 20 0 0" thickness="1" border-color="0 0 0 1" pad="2">
<image path="data/ui/bucket.png" width="100%" height="100%" align="center" justify="flex-end"/>

View File

@@ -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);
}

View File

@@ -15,19 +15,8 @@ public:
static ActionManager I;
std::stack<std::unique_ptr<Action>> 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();

View File

@@ -584,6 +584,15 @@ void App::initLayout()
}
};
}
if (auto* button = layout[main_id]->find<NodeButton>("btn-anim"))
{
button->on_click = [this,button](Node*) {
if (canvas)
{
//canvas->m_canvas->export_anim(data_path);
}
};
}
if (auto* button = layout[main_id]->find<NodeButton>("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<NodeText>("txt-memory"))
{
static char buffer[128];
sprintf(buffer, "History memory: %.2f Kb", bytes / 1024.f);
txt->set_text(buffer);
layout[main_id]->update();
}
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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
{

View File

@@ -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;

View File

@@ -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();