add quick access panel

This commit is contained in:
2019-03-03 21:43:18 +01:00
parent e7f734c824
commit 91ce555c0a
9 changed files with 113 additions and 8 deletions

View File

@@ -34,6 +34,7 @@
#include "node_about.h"
#include "node_changelog.h"
#include "node_usermanual.h"
#include "node_panel_quick.h"
void Node::app_redraw()
{
@@ -232,11 +233,12 @@ const Node* Node::init_template(const char* id)
{
auto node = c->clone();
add_child(node);
node->init();
node->create();
node->loaded();
//node->init();
//node->create();
//node->loaded();
}
YGNodeCopyStyle(y_node, m_template->y_node);
m_template->clone_copy(this);
return m_template;
}
@@ -1045,6 +1047,7 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
CASE(kWidget::PanelColor, NodePanelColor);
CASE(kWidget::PanelStroke, NodePanelStroke);
CASE(kWidget::PanelGrid, NodePanelGrid);
CASE(kWidget::PanelQuick, NodePanelQuick);
CASE(kWidget::ColorQuad, NodeColorQuad);
CASE(kWidget::StrokePreview, NodeStrokePreview);
CASE(kWidget::Canvas, NodeCanvas);

View File

@@ -1,4 +1,5 @@
#pragma once
#include "util.h"
#include "event.h"
enum class kAttribute : uint16_t
@@ -74,6 +75,7 @@ enum class kWidget : uint16_t
PanelColor = const_hash("panel-color"),
PanelStroke = const_hash("panel-stroke"),
PanelGrid = const_hash("panel-grid"),
PanelQuick = const_hash("panel-quick"),
ColorQuad = const_hash("color-quad"),
StrokePreview = const_hash("stroke-preview"),
Canvas = const_hash("canvas"),

View File

@@ -35,7 +35,7 @@ class NodePanelBrush : public Node
NodeButtonCustom* m_btn_remove;
struct header_t {
char magic[5]{ 'P', 'P', 'B', 'R', 0 };
uint16_t version = 1;
uint16_t version = 0;
uint16_t build = g_version_build;
uint16_t brushes = 0;
uint16_t deleted = 0;

31
src/node_panel_quick.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include "pch.h"
#include "node_panel_quick.h"
#include "node_stroke_preview.h"
Node* NodePanelQuick::clone_instantiate() const
{
return new this_class;
}
void NodePanelQuick::clone_finalize(Node* dest) const
{
parent::clone_finalize(dest);
auto n = static_cast<this_class*>(dest);
n->init_controls();
}
void NodePanelQuick::init()
{
parent::init();
auto t = static_cast<const NodeBorder*>(init_template("panel-quick"));
init_controls();
}
void NodePanelQuick::init_controls()
{
auto s = find<NodeStrokePreview>("quick-brush1");
s->m_brush = std::make_shared<Brush>();
s->m_brush->m_tip_size = 10;
s->m_brush->load_tip("data/brushes/Round-Hard.png", "data/brushes/thumbs/Round-Hard.png");
s->draw_stroke();
}

22
src/node_panel_quick.h Normal file
View File

@@ -0,0 +1,22 @@
#pragma once
#include "node.h"
#include "node_button_custom.h"
#include "node_border.h"
class NodePanelQuick : public NodeBorder
{
public:
using this_class = NodePanelQuick;
using parent = NodeBorder;
NodeButtonCustom* m_slider_size;
NodeButtonCustom* m_slider_flow;
NodeButtonCustom* m_button_color1;
NodeButtonCustom* m_button_color2;
NodeButtonCustom* m_button_color3;
virtual Node* clone_instantiate() const override;
virtual void clone_finalize(Node* dest) const override;
virtual void init() override;
private:
void init_controls();
};

View File

@@ -298,10 +298,10 @@ void NodeStrokePreview::draw_stroke_immediate()
}
{
float pad = (5.f + glm::max(glm::min(m_stroke.m_max_size, m_brush->m_tip_size) / 2.f, 10.f)) * App::I.zoom;
float min_pad = size.x * 0.05f;
float pad = (5.f + glm::max(glm::min(m_stroke.m_max_size, m_brush->m_tip_size) / 2.f, min_pad)) * App::I.zoom;
if (b->m_tip_size_pressure)
pad = 10.f * App::I.zoom;
pad = min_pad * App::I.zoom;
float w = m_size.x * App::I.zoom;
float h = m_size.y * App::I.zoom;
std::vector<glm::vec2> kp = {
@@ -530,7 +530,6 @@ void NodeStrokePreview::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
if (m_rtt.getWidth() == new_size.x && m_rtt.getHeight() == new_size.y || !m_brush)
return;
float pad = m_size.x * .15f;
new_size *= root()->m_zoom;
m_rtt.create((int)new_size.x, (int)new_size.y);