Fix minor issues redrawing auto cel guides on Editor

E.g. We could open a (foreground) dialog (e.g. New File), and move the
window, and press the Ctrl key to show the auto-guides (or released it
to hide the auto-guides) for new painted areas of the Editor. This
patch fixes that bug.
This commit is contained in:
David Capello 2020-08-04 16:29:22 -03:00
parent 6862bb8ab0
commit 893c8cbe32
2 changed files with 21 additions and 15 deletions

View File

@ -156,6 +156,7 @@ Editor::Editor(Doc* document, EditorFlags flags)
, m_aniSpeed(1.0)
, m_isPlaying(false)
, m_showGuidesThisCel(nullptr)
, m_showAutoCelGuides(false)
, m_tagFocusBand(-1)
{
if (!m_renderEngine)
@ -875,8 +876,7 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
}
// Draw active layer/cel edges
bool showGuidesThisCel = this->showAutoCelGuides();
if ((m_docPref.show.layerEdges() || showGuidesThisCel) &&
if ((m_docPref.show.layerEdges() || m_showAutoCelGuides) &&
// Show layer edges only on "standby" like states where brush
// preview is shown (e.g. with this we avoid to showing the
// edges in states like DrawingState, etc.).
@ -887,9 +887,10 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
g, cel,
color_utils::color_for_ui(Preferences::instance().guides.layerEdgesColor()));
if (showGuidesThisCel &&
m_showGuidesThisCel != cel)
if (m_showAutoCelGuides &&
m_showGuidesThisCel != cel) {
drawCelGuides(g, cel, m_showGuidesThisCel);
}
}
}
@ -1764,6 +1765,9 @@ bool Editor::onProcessMessage(Message* msg)
case kMouseLeaveMessage:
m_brushPreview.hide();
StatusBar::instance()->showDefaultText();
// Hide autoguides
updateAutoCelGuides(nullptr);
break;
case kMouseDownMessage:
@ -2774,22 +2778,21 @@ void Editor::invalidateIfActive()
invalidate();
}
bool Editor::showAutoCelGuides()
{
return
(getCurrentEditorInk()->isCelMovement() &&
m_docPref.show.autoGuides() &&
m_customizationDelegate &&
int(m_customizationDelegate->getPressedKeyAction(KeyContext::MoveTool) & KeyAction::AutoSelectLayer));
}
void Editor::updateAutoCelGuides(ui::Message* msg)
{
Cel* oldShowGuidesThisCel = m_showGuidesThisCel;
bool oldShowAutoCelGuides = m_showAutoCelGuides;
m_showAutoCelGuides = (
msg &&
getCurrentEditorInk()->isCelMovement() &&
m_docPref.show.autoGuides() &&
m_customizationDelegate &&
int(m_customizationDelegate->getPressedKeyAction(KeyContext::MoveTool) & KeyAction::AutoSelectLayer));
// Check if the user is pressing the Ctrl or Cmd key on move
// tool to show automatic guides.
if (showAutoCelGuides() &&
if (m_showAutoCelGuides &&
m_state->requireBrushPreview()) {
ui::MouseMessage* mouseMsg = dynamic_cast<ui::MouseMessage*>(msg);
@ -2805,8 +2808,10 @@ void Editor::updateAutoCelGuides(ui::Message* msg)
m_showGuidesThisCel = nullptr;
}
if (m_showGuidesThisCel != oldShowGuidesThisCel)
if (m_showGuidesThisCel != oldShowGuidesThisCel ||
m_showAutoCelGuides != oldShowAutoCelGuides) {
invalidate();
}
}
// static

View File

@ -436,6 +436,7 @@ namespace app {
// The Cel that is above the mouse if the Ctrl (or Cmd) key is
// pressed (move key).
Cel* m_showGuidesThisCel;
bool m_showAutoCelGuides;
// Focused tag band. Used by the Timeline to save/restore the
// focused tag band for each sprite/editor.