mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 01:13:40 +00:00
clang-format
This commit is contained in:
parent
747518173d
commit
8c6fe820b9
@ -39,8 +39,7 @@
|
|||||||
// And running script code in a background is not supported.
|
// And running script code in a background is not supported.
|
||||||
// #define ENABLE_REMAP_TILESET_EVENT 1
|
// #define ENABLE_REMAP_TILESET_EVENT 1
|
||||||
|
|
||||||
namespace app {
|
namespace app { namespace script {
|
||||||
namespace script {
|
|
||||||
|
|
||||||
using namespace doc;
|
using namespace doc;
|
||||||
|
|
||||||
@ -242,33 +241,35 @@ private:
|
|||||||
void onBeforeCommand(CommandExecutionEvent& ev)
|
void onBeforeCommand(CommandExecutionEvent& ev)
|
||||||
{
|
{
|
||||||
s_stopPropagationFlag = false;
|
s_stopPropagationFlag = false;
|
||||||
call(BeforeCommand, { { "name", ev.command()->id() },
|
|
||||||
{ "params", ev.params() },
|
auto stopPropagation = (lua_CFunction)[](lua_State*)->int
|
||||||
{ "stopPropagation",
|
{
|
||||||
(lua_CFunction)
|
|
||||||
[](lua_State*) -> int {
|
|
||||||
s_stopPropagationFlag = true;
|
s_stopPropagationFlag = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
);
|
|
||||||
if (s_stopPropagationFlag)
|
|
||||||
ev.cancel();
|
|
||||||
} // namespace script
|
|
||||||
|
|
||||||
void onAfterCommand(CommandExecutionEvent& ev)
|
call(BeforeCommand,
|
||||||
{
|
{
|
||||||
|
{ "name", ev.command()->id() },
|
||||||
|
{ "params", ev.params() },
|
||||||
|
{ "stopPropagation", stopPropagation }
|
||||||
|
});
|
||||||
|
if (s_stopPropagationFlag)
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onAfterCommand(CommandExecutionEvent& ev)
|
||||||
|
{
|
||||||
call(AfterCommand,
|
call(AfterCommand,
|
||||||
{
|
{
|
||||||
{ "name", ev.command()->id() },
|
{ "name", ev.command()->id() },
|
||||||
{ "params", ev.params() }
|
{ "params", ev.params() }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContextObserver impl
|
// ContextObserver impl
|
||||||
void onActiveSiteChange(const Site& site) override
|
void onActiveSiteChange(const Site& site) override
|
||||||
{
|
{
|
||||||
if (m_lastActiveSite.has_value() && *m_lastActiveSite == site) {
|
if (m_lastActiveSite.has_value() && *m_lastActiveSite == site) {
|
||||||
// Avoid multiple events that can happen when closing since
|
// Avoid multiple events that can happen when closing since
|
||||||
// we're changing views at the same time we're removing
|
// we're changing views at the same time we're removing
|
||||||
@ -283,10 +284,10 @@ void onActiveSiteChange(const Site& site) override
|
|||||||
});
|
});
|
||||||
m_lastBeforeActiveSite = std::nullopt;
|
m_lastBeforeActiveSite = std::nullopt;
|
||||||
m_lastActiveSite = site;
|
m_lastActiveSite = site;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onBeforeActiveSiteChange(const Site& fromSite) override
|
void onBeforeActiveSiteChange(const Site& fromSite) override
|
||||||
{
|
{
|
||||||
if (m_lastBeforeActiveSite.has_value() && *m_lastBeforeActiveSite == fromSite)
|
if (m_lastBeforeActiveSite.has_value() && *m_lastBeforeActiveSite == fromSite)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -296,17 +297,17 @@ void onBeforeActiveSiteChange(const Site& fromSite) override
|
|||||||
{ "fromUndo", fromUndo }
|
{ "fromUndo", fromUndo }
|
||||||
});
|
});
|
||||||
m_lastBeforeActiveSite = fromSite;
|
m_lastBeforeActiveSite = fromSite;
|
||||||
}
|
}
|
||||||
|
|
||||||
obs::scoped_connection m_fgConn;
|
obs::scoped_connection m_fgConn;
|
||||||
obs::scoped_connection m_bgConn;
|
obs::scoped_connection m_bgConn;
|
||||||
obs::scoped_connection m_beforeCmdConn;
|
obs::scoped_connection m_beforeCmdConn;
|
||||||
obs::scoped_connection m_afterCmdConn;
|
obs::scoped_connection m_afterCmdConn;
|
||||||
obs::scoped_connection m_beforePaintConn;
|
obs::scoped_connection m_beforePaintConn;
|
||||||
|
|
||||||
int m_addedObserver;
|
int m_addedObserver;
|
||||||
std::optional<Site> m_lastActiveSite;
|
std::optional<Site> m_lastActiveSite;
|
||||||
std::optional<Site> m_lastBeforeActiveSite;
|
std::optional<Site> m_lastBeforeActiveSite;
|
||||||
}; // namespace app
|
}; // namespace app
|
||||||
|
|
||||||
class WindowEvents : public Events,
|
class WindowEvents : public Events,
|
||||||
@ -636,5 +637,4 @@ void push_window_events(lua_State* L, ui::Window* window)
|
|||||||
push_ptr<Events>(L, g_windowEvents.get());
|
push_ptr<Events>(L, g_windowEvents.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace script
|
}} // namespace app::script
|
||||||
} // namespace app
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user