From ca41785f18ea70ccdad0f74b113739d7ebbe74ff Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 16 Apr 2021 12:09:49 -0300 Subject: [PATCH] Fix regression: 'Simple Crosshair' mouse cursor dissapears when we switch to Eraser tool Regression introduced in: ef4f691459d13b45459c56383ab3673ca6fbec0a --- src/app/ui/editor/brush_preview.cpp | 10 +++++++++- src/app/ui/editor/editor.cpp | 4 ---- src/ui/system.cpp | 8 +++++++- src/ui/system.h | 3 ++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/ui/editor/brush_preview.cpp b/src/app/ui/editor/brush_preview.cpp index e6ddd820c..010ed2af7 100644 --- a/src/app/ui/editor/brush_preview.cpp +++ b/src/app/ui/editor/brush_preview.cpp @@ -469,7 +469,11 @@ void BrushPreview::createNativeCursor() if (cursorBounds.isEmpty()) { ASSERT(!m_cursor); - m_editor->manager()->getDisplay()->setNativeMouseCursor(os::NativeCursor::kNoCursor); + if (!(m_type & NATIVE_CROSSHAIR)) { + // TODO should we use ui::set_mouse_cursor()? + ui::set_mouse_cursor_reset_info(); + m_editor->manager()->getDisplay()->setNativeMouseCursor(os::NativeCursor::kNoCursor); + } return; } @@ -508,6 +512,10 @@ void BrushPreview::forEachLittleCrossPixel( } if (m_cursor) { + ASSERT(m_cursor); + + // TODO should we use ui::set_mouse_cursor()? + ui::set_mouse_cursor_reset_info(); m_editor->manager()->getDisplay()->setNativeMouseCursor( m_cursor, m_cursorCenter, m_editor->manager()->getDisplay()->scale()); diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 670950e64..124dc17a7 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -2680,10 +2680,6 @@ void Editor::showMouseCursor(CursorType cursorType, void Editor::showBrushPreview(const gfx::Point& screenPos) { - if (Preferences::instance().cursor.paintingCursorType() != - app::gen::PaintingCursorType::SIMPLE_CROSSHAIR) - ui::set_mouse_cursor(kNoCursor); - m_brushPreview.show(screenPos); } diff --git a/src/ui/system.cpp b/src/ui/system.cpp index 2aa0da5f9..16fcab42a 100644 --- a/src/ui/system.cpp +++ b/src/ui/system.cpp @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2018-2020 Igara Studio S.A. +// Copyright (C) 2018-2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -299,6 +299,12 @@ void set_mouse_cursor_scale(const int newScale) update_mouse_cursor(); } +void set_mouse_cursor_reset_info() +{ + mouse_cursor_type = kCustomCursor; + mouse_cursor_custom = nullptr; +} + void hide_mouse_cursor() { ASSERT(mouse_scares >= 0); diff --git a/src/ui/system.h b/src/ui/system.h index 6fb5497fd..c5d8c4fbb 100644 --- a/src/ui/system.h +++ b/src/ui/system.h @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2019-2020 Igara Studio S.A. +// Copyright (C) 2019-2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -57,6 +57,7 @@ namespace ui { CursorType get_mouse_cursor(); void set_mouse_cursor(CursorType type, const Cursor* cursor = nullptr); void set_mouse_cursor_scale(const int newScale); + void set_mouse_cursor_reset_info(); void hide_mouse_cursor(); void show_mouse_cursor();