add cursor visibility mode
This commit is contained in:
@@ -249,7 +249,7 @@
|
|||||||
|
|
||||||
<!-- MENU TOOLS > OPTIONS -->
|
<!-- MENU TOOLS > OPTIONS -->
|
||||||
<layout id="options-menu">
|
<layout id="options-menu">
|
||||||
<popup-menu positioning="absolute" position="100 100" width="150" thickness="1" border-color=".1" color=".4 .4 .4 .8" dir="col">
|
<popup-menu positioning="absolute" position="100 100" width="230" thickness="1" border-color=".1" color=".4 .4 .4 .8" dir="col">
|
||||||
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<text text="UI Scale" margin="0 10 0 5" grow="1"/>
|
<text text="UI Scale" margin="0 10 0 5" grow="1"/>
|
||||||
<combobox id="tools-ui-scale" height="30" width="50" margin="0 10 0 0" combo-list="0.50,0.75,0.80,0.90,1.00,1.25,1.50,2.00,2.50"/>
|
<combobox id="tools-ui-scale" height="30" width="50" margin="0 10 0 0" combo-list="0.50,0.75,0.80,0.90,1.00,1.25,1.50,2.00,2.50"/>
|
||||||
@@ -270,6 +270,10 @@
|
|||||||
<checkbox id="tools-timelapse-check" width="20" height="20"/>
|
<checkbox id="tools-timelapse-check" width="20" height="20"/>
|
||||||
<text text="Auto Timelapse" margin="0 0 0 5"/>
|
<text text="Auto Timelapse" margin="0 0 0 5"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
|
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
|
<text text="Show Cursor" margin="0 10 0 5" grow="1"/>
|
||||||
|
<combobox id="tools-show-cursor" height="30" width="100" margin="0 10 0 0" combo-list="Never,Small Brush,Not Painting,Always"/>
|
||||||
|
</button-custom>
|
||||||
</popup-menu>
|
</popup-menu>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
||||||
|
|||||||
@@ -1016,6 +1016,18 @@ void App::init_menu_tools()
|
|||||||
Settings::save();
|
Settings::save();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto mode = popup_time->find<NodeComboBox>("tools-show-cursor"))
|
||||||
|
{
|
||||||
|
mode->set_index(Settings::value_or<Serializer::Integer>("show-cursor", 0));
|
||||||
|
|
||||||
|
mode->on_select = [mode](Node* target, int index)
|
||||||
|
{
|
||||||
|
App::I->canvas->set_cursor_visibility((NodeCanvas::kCursorVisibility)index);
|
||||||
|
Settings::set("show-cursor", Serializer::Integer(index));
|
||||||
|
Settings::save();
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
popup_exp->find<NodeButtonCustom>("clear-grids")->on_click = [this, popup_exp](Node*) {
|
popup_exp->find<NodeButtonCustom>("clear-grids")->on_click = [this, popup_exp](Node*) {
|
||||||
|
|||||||
@@ -175,6 +175,10 @@ public:
|
|||||||
if (I->on_mode_changed)
|
if (I->on_mode_changed)
|
||||||
I->on_mode_changed(prev, mode);
|
I->on_mode_changed(prev, mode);
|
||||||
}
|
}
|
||||||
|
template <class T> static T* get_mode(int index = 0)
|
||||||
|
{
|
||||||
|
return dynamic_cast<T*>(modes[(int)I->m_current_mode][index]);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<LayerFrame::Snapshot> m_layers_snapshot;
|
std::vector<LayerFrame::Snapshot> m_layers_snapshot;
|
||||||
|
|
||||||
|
|||||||
@@ -159,9 +159,10 @@ void CanvasModePen::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
App::I->render_task_async([loc, pr = me->m_pressure]
|
App::I->render_task_async([loc, pr = me->m_pressure]
|
||||||
{
|
{
|
||||||
Canvas::I->stroke_start({ loc, 0 }, pr);
|
Canvas::I->stroke_start({ loc, 0 }, pr);
|
||||||
});
|
});
|
||||||
|
m_drawing = true;
|
||||||
}
|
}
|
||||||
m_dragging = true;
|
m_dragging = true;
|
||||||
node->mouse_capture();
|
node->mouse_capture();
|
||||||
@@ -184,6 +185,7 @@ void CanvasModePen::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
|
|||||||
App::I->brush_update(true, false);
|
App::I->brush_update(true, false);
|
||||||
Canvas::I->pick_end();
|
Canvas::I->pick_end();
|
||||||
}
|
}
|
||||||
|
m_drawing = false;
|
||||||
m_dragging = false;
|
m_dragging = false;
|
||||||
m_picking = false;
|
m_picking = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ class CanvasModePen : public CanvasMode
|
|||||||
float m_zoom_canvas = 1.f;
|
float m_zoom_canvas = 1.f;
|
||||||
float m_zoom_start;
|
float m_zoom_start;
|
||||||
// resizing the tip
|
// resizing the tip
|
||||||
bool m_resizing = false;
|
|
||||||
public:
|
public:
|
||||||
CanvasModePen() { hide_curor = true; m_picking = false; }
|
CanvasModePen() { hide_curor = true; m_picking = false; }
|
||||||
|
|
||||||
@@ -91,7 +90,9 @@ public:
|
|||||||
virtual void on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera) override;
|
virtual void on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera) override;
|
||||||
virtual void enter(kCanvasMode prev) override;
|
virtual void enter(kCanvasMode prev) override;
|
||||||
virtual void leave(kCanvasMode next) override;
|
virtual void leave(kCanvasMode next) override;
|
||||||
|
bool m_resizing = false;
|
||||||
bool m_picking = false;
|
bool m_picking = false;
|
||||||
|
bool m_drawing = false;
|
||||||
glm::vec2 m_cur_pos;
|
glm::vec2 m_cur_pos;
|
||||||
bool m_draw_outline = true;
|
bool m_draw_outline = true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Node* NodeCanvas::clone_instantiate() const
|
|||||||
void NodeCanvas::init()
|
void NodeCanvas::init()
|
||||||
{
|
{
|
||||||
m_density = Settings::value_or<Serializer::Float>("vp-scale", 1.f);
|
m_density = Settings::value_or<Serializer::Float>("vp-scale", 1.f);
|
||||||
|
m_cursor_visibility = (kCursorVisibility)Settings::value_or<Serializer::Integer>("show-cursor", 0);
|
||||||
|
|
||||||
m_mouse_ignore = false;
|
m_mouse_ignore = false;
|
||||||
m_canvas = std::make_unique<Canvas>();
|
m_canvas = std::make_unique<Canvas>();
|
||||||
@@ -561,6 +562,7 @@ kEventResult NodeCanvas::handle_event(Event* e)
|
|||||||
case kEventType::MouseUpR:
|
case kEventType::MouseUpR:
|
||||||
case kEventType::MouseCancel:
|
case kEventType::MouseCancel:
|
||||||
m_canvas->m_cur_pos = loc;
|
m_canvas->m_cur_pos = loc;
|
||||||
|
update_cursor();
|
||||||
for (auto& mode : *m_canvas->m_mode)
|
for (auto& mode : *m_canvas->m_mode)
|
||||||
mode->on_MouseEvent(me, loc);
|
mode->on_MouseEvent(me, loc);
|
||||||
break;
|
break;
|
||||||
@@ -569,9 +571,7 @@ kEventResult NodeCanvas::handle_event(Event* e)
|
|||||||
App::I->show_cursor();
|
App::I->show_cursor();
|
||||||
break;
|
break;
|
||||||
case kEventType::MouseFocus:
|
case kEventType::MouseFocus:
|
||||||
(*m_canvas->m_mode)[0]->hide_curor &&
|
update_cursor();
|
||||||
!App::I->keys[(int)kKey::KeyAlt] ?
|
|
||||||
App::I->hide_cursor() : App::I->show_cursor();
|
|
||||||
break;
|
break;
|
||||||
case kEventType::KeyDown:
|
case kEventType::KeyDown:
|
||||||
if (ke->m_key == kKey::KeyE)
|
if (ke->m_key == kKey::KeyE)
|
||||||
@@ -585,9 +585,7 @@ kEventResult NodeCanvas::handle_event(Event* e)
|
|||||||
mode->on_KeyEvent(ke);
|
mode->on_KeyEvent(ke);
|
||||||
break;
|
break;
|
||||||
case kEventType::KeyUp:
|
case kEventType::KeyUp:
|
||||||
if (ke->m_key == kKey::KeyAlt && m_mouse_focus)
|
update_cursor();
|
||||||
(*m_canvas->m_mode)[0]->hide_curor ?
|
|
||||||
App::I->hide_cursor() : App::I->show_cursor();
|
|
||||||
if (ke->m_key == kKey::KeyE)
|
if (ke->m_key == kKey::KeyE)
|
||||||
Canvas::set_mode(kCanvasMode::Draw);
|
Canvas::set_mode(kCanvasMode::Draw);
|
||||||
if (ke->m_key == kKey::KeyTab)
|
if (ke->m_key == kKey::KeyTab)
|
||||||
@@ -668,6 +666,31 @@ void NodeCanvas::set_density(float d)
|
|||||||
create_buffers();
|
create_buffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeCanvas::set_cursor_visibility(kCursorVisibility mode)
|
||||||
|
{
|
||||||
|
m_cursor_visibility = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeCanvas::update_cursor()
|
||||||
|
{
|
||||||
|
bool visible = true;
|
||||||
|
if (m_cursor_visibility == kCursorVisibility::Always)
|
||||||
|
visible = true;
|
||||||
|
if (m_cursor_visibility == kCursorVisibility::Never)
|
||||||
|
visible = false;
|
||||||
|
if (m_cursor_visibility == kCursorVisibility::SmallBrush)
|
||||||
|
visible = m_canvas->m_current_brush->m_tip_size < 10;
|
||||||
|
if (m_cursor_visibility == kCursorVisibility::NotPainting &&
|
||||||
|
m_canvas->m_current_mode == kCanvasMode::Draw ||
|
||||||
|
m_canvas->m_current_mode == kCanvasMode::Erase)
|
||||||
|
{
|
||||||
|
visible = !m_canvas->get_mode<CanvasModePen>()->m_drawing ||
|
||||||
|
m_canvas->get_mode<CanvasModePen>()->m_resizing ||
|
||||||
|
m_canvas->get_mode<CanvasModePen>()->m_picking;
|
||||||
|
}
|
||||||
|
visible ? App::I->show_cursor() : App::I->hide_cursor();
|
||||||
|
}
|
||||||
|
|
||||||
void NodeCanvas::on_tick(float dt)
|
void NodeCanvas::on_tick(float dt)
|
||||||
{
|
{
|
||||||
m_outline_pan = glm::fract(m_outline_pan + dt * 0.01f);
|
m_outline_pan = glm::fract(m_outline_pan + dt * 0.01f);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
class NodeCanvas : public Node
|
class NodeCanvas : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum class kCursorVisibility { Never, SmallBrush, NotPainting, Always } m_cursor_visibility;
|
||||||
std::unique_ptr<Canvas> m_canvas;
|
std::unique_ptr<Canvas> m_canvas;
|
||||||
RTT m_blender_rtt;
|
RTT m_blender_rtt;
|
||||||
RTT m_cache_rtt;
|
RTT m_cache_rtt;
|
||||||
@@ -32,4 +33,6 @@ public:
|
|||||||
void reset_camera();
|
void reset_camera();
|
||||||
void create_buffers();
|
void create_buffers();
|
||||||
void set_density(float d);
|
void set_density(float d);
|
||||||
|
void set_cursor_visibility(kCursorVisibility mode);
|
||||||
|
void update_cursor();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ void NodePanelStroke::init_controls()
|
|||||||
tick->set_image("data/ui/popup-tick.png");
|
tick->set_image("data/ui/popup-tick.png");
|
||||||
float hh = App::I->presets->m_container->m_children.size() > 10 ? App::I->height / App::I->zoom * .75f : 400.f;
|
float hh = App::I->presets->m_container->m_children.size() > 10 ? App::I->height / App::I->zoom * .75f : 400.f;
|
||||||
App::I->presets->SetHeight(glm::max(hh, 400.f));
|
App::I->presets->SetHeight(glm::max(hh, 400.f));
|
||||||
|
App::I->presets->SetWidth(300);
|
||||||
root()->update();
|
root()->update();
|
||||||
if ((pos.y + App::I->presets->m_size.y) > screen.y)
|
if ((pos.y + App::I->presets->m_size.y) > screen.y)
|
||||||
pos.y = screen.y - App::I->presets->m_size.y;
|
pos.y = screen.y - App::I->presets->m_size.y;
|
||||||
|
|||||||
Reference in New Issue
Block a user