add cursor visibility mode
This commit is contained in:
@@ -13,6 +13,7 @@ Node* NodeCanvas::clone_instantiate() const
|
||||
void NodeCanvas::init()
|
||||
{
|
||||
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_canvas = std::make_unique<Canvas>();
|
||||
@@ -561,6 +562,7 @@ kEventResult NodeCanvas::handle_event(Event* e)
|
||||
case kEventType::MouseUpR:
|
||||
case kEventType::MouseCancel:
|
||||
m_canvas->m_cur_pos = loc;
|
||||
update_cursor();
|
||||
for (auto& mode : *m_canvas->m_mode)
|
||||
mode->on_MouseEvent(me, loc);
|
||||
break;
|
||||
@@ -569,9 +571,7 @@ kEventResult NodeCanvas::handle_event(Event* e)
|
||||
App::I->show_cursor();
|
||||
break;
|
||||
case kEventType::MouseFocus:
|
||||
(*m_canvas->m_mode)[0]->hide_curor &&
|
||||
!App::I->keys[(int)kKey::KeyAlt] ?
|
||||
App::I->hide_cursor() : App::I->show_cursor();
|
||||
update_cursor();
|
||||
break;
|
||||
case kEventType::KeyDown:
|
||||
if (ke->m_key == kKey::KeyE)
|
||||
@@ -585,9 +585,7 @@ kEventResult NodeCanvas::handle_event(Event* e)
|
||||
mode->on_KeyEvent(ke);
|
||||
break;
|
||||
case kEventType::KeyUp:
|
||||
if (ke->m_key == kKey::KeyAlt && m_mouse_focus)
|
||||
(*m_canvas->m_mode)[0]->hide_curor ?
|
||||
App::I->hide_cursor() : App::I->show_cursor();
|
||||
update_cursor();
|
||||
if (ke->m_key == kKey::KeyE)
|
||||
Canvas::set_mode(kCanvasMode::Draw);
|
||||
if (ke->m_key == kKey::KeyTab)
|
||||
@@ -668,6 +666,31 @@ void NodeCanvas::set_density(float d)
|
||||
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)
|
||||
{
|
||||
m_outline_pan = glm::fract(m_outline_pan + dt * 0.01f);
|
||||
|
||||
Reference in New Issue
Block a user