From 43513e0f1b0a25daa951299379aac687f3c488ad Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 11 Apr 2022 09:52:45 -0300 Subject: [PATCH] Don't show tooltip when a new frame/layer is created from a script transaction This might improve the performance of some scripts if it creates several frames/layers at the same time. --- src/app/commands/cmd_new_frame.cpp | 12 ++++++++++-- src/app/commands/cmd_new_layer.cpp | 12 +++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/app/commands/cmd_new_frame.cpp b/src/app/commands/cmd_new_frame.cpp index be0f699bf..d6d301c01 100644 --- a/src/app/commands/cmd_new_frame.cpp +++ b/src/app/commands/cmd_new_frame.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2019 Igara Studio S.A. +// Copyright (C) 2018-2022 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -93,6 +93,14 @@ void NewFrameCommand::onExecute(Context* context) ContextWriter writer(context); Doc* document(writer.document()); Sprite* sprite(writer.sprite()); + +#if ENABLE_UI + // Show the tooltip feedback only if we are not inside a transaction + // (e.g. we can be already in a transaction if we are running in a + // Lua script app.transaction()). + const bool showTooltip = (document->transaction() == nullptr); +#endif + { Tx tx(writer.context(), friendlyName()); DocApi api = document->getApi(tx); @@ -169,7 +177,7 @@ void NewFrameCommand::onExecute(Context* context) } #ifdef ENABLE_UI - if (context->isUIAvailable()) { + if (context->isUIAvailable() && showTooltip) { update_screen_for_document(document); StatusBar::instance()->showTip( diff --git a/src/app/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp index b75fbab42..810e5e17b 100644 --- a/src/app/commands/cmd_new_layer.cpp +++ b/src/app/commands/cmd_new_layer.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2020 Igara Studio S.A. +// Copyright (C) 2019-2022 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -148,6 +148,13 @@ void NewLayerCommand::onExecute(Context* context) Sprite* sprite(writer.sprite()); std::string name; +#if ENABLE_UI + // Show the tooltip feedback only if we are not inside a transaction + // (e.g. we can be already in a transaction if we are running in a + // Lua script app.transaction()). + const bool showTooltip = (document->transaction() == nullptr); +#endif + Doc* pasteDoc = nullptr; Scoped destroyPasteDoc( [&pasteDoc, context]{ @@ -416,10 +423,9 @@ void NewLayerCommand::onExecute(Context* context) } #ifdef ENABLE_UI - if (context->isUIAvailable()) { + if (context->isUIAvailable() && showTooltip) { update_screen_for_document(document); - StatusBar::instance()->invalidate(); StatusBar::instance()->showTip( 1000, fmt::format("{} '{}' created", layerPrefix(),