fix stroke preview, add license messages, fix node scroll
This commit is contained in:
@@ -1151,7 +1151,7 @@ Here's a list of what's available in this release.
|
|||||||
</border>
|
</border>
|
||||||
<!-- side bar -->
|
<!-- side bar -->
|
||||||
<node height="100%" dir="row" shrink="1">
|
<node height="100%" dir="row" shrink="1">
|
||||||
<scroll id="panels" pad="5 25 5 5" margin="0 0 0 0" color=".3 .3 .3 .4" height="100%" dir="col" wrap="0" shrink="1">
|
<scroll id="panels" pad="5 5 5 5" margin="0 0 0 0" color=".3 .3 .3 .4" height="100%" dir="col" wrap="0" shrink="1">
|
||||||
<!--Stroke-->
|
<!--Stroke-->
|
||||||
<!--<panel-stroke id="panel-stroke"/>-->
|
<!--<panel-stroke id="panel-stroke"/>-->
|
||||||
<!--Brushes-->
|
<!--Brushes-->
|
||||||
|
|||||||
@@ -371,6 +371,11 @@ void App::init()
|
|||||||
initAssets();
|
initAssets();
|
||||||
initLayout();
|
initLayout();
|
||||||
title_update();
|
title_update();
|
||||||
|
|
||||||
|
if (!check_license())
|
||||||
|
{
|
||||||
|
message_box("License", "Could not validate this license, running in demo mode.");
|
||||||
|
}
|
||||||
|
|
||||||
//GLfloat width_range[2];
|
//GLfloat width_range[2];
|
||||||
//glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, width_range);
|
//glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, width_range);
|
||||||
|
|||||||
@@ -308,6 +308,12 @@ void App::dialog_browse()
|
|||||||
|
|
||||||
void App::dialog_save_ver()
|
void App::dialog_save_ver()
|
||||||
{
|
{
|
||||||
|
if (!check_license())
|
||||||
|
{
|
||||||
|
message_box("License", "This function is disabled in demo mode.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int current = 0;
|
int current = 0;
|
||||||
std::string next = doc_name + ".01";
|
std::string next = doc_name + ".01";
|
||||||
std::string base = doc_name;
|
std::string base = doc_name;
|
||||||
@@ -338,6 +344,12 @@ void App::dialog_save_ver()
|
|||||||
|
|
||||||
void App::dialog_save()
|
void App::dialog_save()
|
||||||
{
|
{
|
||||||
|
if (!check_license())
|
||||||
|
{
|
||||||
|
message_box("License", "This function is disabled in demo mode.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (canvas)
|
if (canvas)
|
||||||
{
|
{
|
||||||
auto dialog = std::make_shared<NodeDialogSave>();
|
auto dialog = std::make_shared<NodeDialogSave>();
|
||||||
@@ -402,6 +414,12 @@ void App::dialog_save()
|
|||||||
|
|
||||||
void App::dialog_export()
|
void App::dialog_export()
|
||||||
{
|
{
|
||||||
|
if (!check_license())
|
||||||
|
{
|
||||||
|
message_box("License", "This function is disabled in demo mode.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (canvas)
|
if (canvas)
|
||||||
{
|
{
|
||||||
// TODO: use picker
|
// TODO: use picker
|
||||||
|
|||||||
13
src/canvas.h
13
src/canvas.h
@@ -307,9 +307,22 @@ public:
|
|||||||
if (!m_image[i])
|
if (!m_image[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
LOG("undo box %d dirty=%s [%d,%d,%d,%d] to dirty=%s [%d,%d,%d,%d]",
|
||||||
|
i,
|
||||||
|
m_canvas->m_layers[m_layer_idx].m_dirty_face[i] ? "true" : "false",
|
||||||
|
(int)m_canvas->m_layers[m_layer_idx].m_dirty_box[i].x,
|
||||||
|
(int)m_canvas->m_layers[m_layer_idx].m_dirty_box[i].y,
|
||||||
|
(int)m_canvas->m_layers[m_layer_idx].m_dirty_box[i].z,
|
||||||
|
(int)m_canvas->m_layers[m_layer_idx].m_dirty_box[i].w,
|
||||||
|
m_old_dirty[i] ? "true" : "false",
|
||||||
|
(int)m_old_box[i].x,
|
||||||
|
(int)m_old_box[i].y,
|
||||||
|
(int)m_old_box[i].z,
|
||||||
|
(int)m_old_box[i].w);
|
||||||
m_canvas->m_layers[m_layer_idx].m_dirty_box[i] = m_old_box[i];
|
m_canvas->m_layers[m_layer_idx].m_dirty_box[i] = m_old_box[i];
|
||||||
m_canvas->m_layers[m_layer_idx].m_dirty_face[i] = m_old_dirty[i];
|
m_canvas->m_layers[m_layer_idx].m_dirty_face[i] = m_old_dirty[i];
|
||||||
|
|
||||||
|
|
||||||
glm::vec2 box_sz = zw(m_box[i]) - xy(m_box[i]);
|
glm::vec2 box_sz = zw(m_box[i]) - xy(m_box[i]);
|
||||||
if (box_sz.x > 0 && box_sz.y > 0 && box_sz.x <= m_canvas->m_layers[m_layer_idx].w && box_sz.y <= m_canvas->m_layers[m_layer_idx].h)
|
if (box_sz.x > 0 && box_sz.y > 0 && box_sz.x <= m_canvas->m_layers[m_layer_idx].w && box_sz.y <= m_canvas->m_layers[m_layer_idx].h)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,11 @@
|
|||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "node_border.h"
|
#include "node_border.h"
|
||||||
|
|
||||||
|
void LayoutManager::create()
|
||||||
|
{
|
||||||
|
m_layouts[const_hash("main")] = std::make_unique<Node>();
|
||||||
|
}
|
||||||
|
|
||||||
bool LayoutManager::load(const char* path)
|
bool LayoutManager::load(const char* path)
|
||||||
{
|
{
|
||||||
auto abs_path = Asset::absolute(path);
|
auto abs_path = Asset::absolute(path);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class LayoutManager
|
|||||||
public:
|
public:
|
||||||
bool m_loaded = false;
|
bool m_loaded = false;
|
||||||
std::function<void()> on_loaded;
|
std::function<void()> on_loaded;
|
||||||
|
void create();
|
||||||
bool load(const char* path);
|
bool load(const char* path);
|
||||||
bool reload();
|
bool reload();
|
||||||
class Node* operator[](uint16_t id)
|
class Node* operator[](uint16_t id)
|
||||||
|
|||||||
@@ -408,12 +408,14 @@ int main(int argc, char** argv)
|
|||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
App::I.initLog();
|
App::I.initLog();
|
||||||
|
|
||||||
|
/*
|
||||||
if (!App::I.check_license())
|
if (!App::I.check_license())
|
||||||
{
|
{
|
||||||
MessageBoxA(NULL, "Unable to verify this demo license, please make sure you are connected to Internet.",
|
MessageBoxA(NULL, "Unable to verify this demo license, please make sure you are connected to Internet.",
|
||||||
"PanoPainter - License Error", MB_ICONERROR | MB_OK);
|
"PanoPainter - License Error", MB_ICONERROR | MB_OK);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
FILE* fp_check = fopen("data\\layout.xml", "rb");
|
FILE* fp_check = fopen("data\\layout.xml", "rb");
|
||||||
|
|||||||
@@ -36,15 +36,21 @@ void NodeScroll::draw()
|
|||||||
{
|
{
|
||||||
NodeBorder::draw();
|
NodeBorder::draw();
|
||||||
glm::vec4 rect = get_children_rect();
|
glm::vec4 rect = get_children_rect();
|
||||||
if (rect.x == 0 || rect.w < m_size.y)
|
glm::vec4 pad = GetPadding();
|
||||||
|
float sz = m_size.y - (pad[0] + pad[2]);
|
||||||
|
if (rect.w == 0 || rect.w <= sz)
|
||||||
|
{
|
||||||
|
YGNodeStyleSetPadding(y_node, YGEdgeRight, 5);
|
||||||
return;
|
return;
|
||||||
float h = m_size.y / rect.w * m_size.y;
|
}
|
||||||
float offset_percent = m_offset.y / (rect.w - m_size.y);
|
YGNodeStyleSetPadding(y_node, YGEdgeRight, 35);
|
||||||
|
float h = sz / rect.w * sz;
|
||||||
|
float offset_percent = m_offset.y / (rect.w - sz);
|
||||||
float pr = YGNodeLayoutGetPadding(y_node, YGEdgeRight) - 5;
|
float pr = YGNodeLayoutGetPadding(y_node, YGEdgeRight) - 5;
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
ShaderManager::use(kShader::Color);
|
ShaderManager::use(kShader::Color);
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, m_proj
|
ShaderManager::u_mat4(kShaderUniform::MVP, m_proj
|
||||||
* glm::translate(glm::vec3(m_pos.x + m_size.x - pr, m_pos.y - offset_percent * (m_size.y - h), 0))
|
* glm::translate(glm::vec3(m_pos.x + m_size.x - pr, m_pos.y - offset_percent * (sz - h) + pad[0], 0))
|
||||||
* glm::scale(glm::vec3(pr, h, 1))
|
* glm::scale(glm::vec3(pr, h, 1))
|
||||||
* glm::translate(glm::vec3(.5, .5, 0))
|
* glm::translate(glm::vec3(.5, .5, 0))
|
||||||
);
|
);
|
||||||
@@ -71,7 +77,10 @@ kEventResult NodeScroll::handle_event(Event* e)
|
|||||||
case kEventType::MouseMove:
|
case kEventType::MouseMove:
|
||||||
if (m_dragging)
|
if (m_dragging)
|
||||||
{
|
{
|
||||||
m_offset = m_offset_start + (me->m_pos - m_drag_start) * m_mask * m_scroll_dir;
|
glm::vec4 rect = get_children_rect();
|
||||||
|
glm::vec4 pad = GetPadding();
|
||||||
|
float speed = rect.w / (m_size.y - (pad[0] + pad[2]));
|
||||||
|
m_offset = m_offset_start + (me->m_pos - m_drag_start) * m_mask * m_scroll_dir * speed;
|
||||||
fix_scroll();
|
fix_scroll();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -148,10 +148,14 @@ void NodeStrokePreview::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
|
|||||||
|
|
||||||
float pad = m_size.x * .15f;
|
float pad = m_size.x * .15f;
|
||||||
new_size *= root()->m_zoom;
|
new_size *= root()->m_zoom;
|
||||||
|
|
||||||
|
m_rtt.destroy();
|
||||||
|
m_rtt.create((int)new_size.x, (int)new_size.y);
|
||||||
|
|
||||||
float w = new_size.x;
|
float w = new_size.x;
|
||||||
float h = new_size.y;
|
float h = new_size.y;
|
||||||
std::vector<glm::vec2> kp = { { pad, pad },{ pad, h - pad },{ w - pad, pad },{ w - pad, h - pad } };
|
std::vector<glm::vec2> kp = { { pad, pad },{ pad, h - pad },{ w - pad, pad },{ w - pad, h - pad } };
|
||||||
m_stroke.reset();
|
m_stroke.reset(true);
|
||||||
m_stroke.start(m_brush);
|
m_stroke.start(m_brush);
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
@@ -160,7 +164,5 @@ void NodeStrokePreview::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
|
|||||||
m_stroke.add_point(glm::vec3(BezierCurve::Bezier2D(kp, t), 0), p);
|
m_stroke.add_point(glm::vec3(BezierCurve::Bezier2D(kp, t), 0), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_rtt.destroy();
|
|
||||||
m_rtt.create((int)new_size.x, (int)new_size.y);
|
|
||||||
draw_stroke();
|
draw_stroke();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user