mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-02 13:09:27 +00:00
Add Shift+F7 to toggle other layers visibility on Preview window
This commit is contained in:
parent
32009723c5
commit
11644a7d16
15
data/gui.xml
15
data/gui.xml
@ -303,6 +303,12 @@
|
|||||||
<key command="LayerOpacity"><param name="opacity" value="224" /></key>
|
<key command="LayerOpacity"><param name="opacity" value="224" /></key>
|
||||||
<key command="LayerOpacity" shortcut="Shift+4"><param name="opacity" value="255" /></key>
|
<key command="LayerOpacity" shortcut="Shift+4"><param name="opacity" value="255" /></key>
|
||||||
|
|
||||||
|
<key command="ToggleOtherLayersOpacity" />
|
||||||
|
<key command="ToggleOtherLayersOpacity" shortcut="Shift+F7">
|
||||||
|
<param name="preview" value="true" />
|
||||||
|
<param name="checkedIfZero" value="true" />
|
||||||
|
</key>
|
||||||
|
|
||||||
<!-- Scroll to center -->
|
<!-- Scroll to center -->
|
||||||
<key command="ScrollCenter" shortcut="Shift+Z" />
|
<key command="ScrollCenter" shortcut="Shift+Z" />
|
||||||
<key command="FitScreen" shortcut="Ctrl+0" mac="Cmd+0" />
|
<key command="FitScreen" shortcut="Ctrl+0" mac="Cmd+0" />
|
||||||
@ -1017,7 +1023,14 @@
|
|||||||
<item command="Timeline" text="@.view_timeline">
|
<item command="Timeline" text="@.view_timeline">
|
||||||
<param name="switch" value="true" />
|
<param name="switch" value="true" />
|
||||||
</item>
|
</item>
|
||||||
<item command="TogglePreview" text="@.view_preview" />
|
<menu text="@.view_preview">
|
||||||
|
<item command="TogglePreview" text="@.view_preview" />
|
||||||
|
<separator />
|
||||||
|
<item command="ToggleOtherLayersOpacity" text="@.view_preview_hide_other_layers">
|
||||||
|
<param name="preview" value="true" />
|
||||||
|
<param name="checkedIfZero" value="true" />
|
||||||
|
</item>
|
||||||
|
</menu>
|
||||||
<item command="AdvancedMode" text="@.view_advanced_mode" />
|
<item command="AdvancedMode" text="@.view_advanced_mode" />
|
||||||
<item command="FullscreenMode" text="@.view_full_screen_mode" />
|
<item command="FullscreenMode" text="@.view_full_screen_mode" />
|
||||||
<item command="FullscreenPreview" text="@.view_full_screen_preview" />
|
<item command="FullscreenPreview" text="@.view_full_screen_preview" />
|
||||||
|
@ -234,6 +234,7 @@
|
|||||||
<option id="load_wintab_driver" type="bool" default="false" />
|
<option id="load_wintab_driver" type="bool" default="false" />
|
||||||
<option id="flash_layer" type="bool" default="false" />
|
<option id="flash_layer" type="bool" default="false" />
|
||||||
<option id="nonactive_layers_opacity" type="int" default="255" />
|
<option id="nonactive_layers_opacity" type="int" default="255" />
|
||||||
|
<option id="nonactive_layers_opacity_preview" type="int" default="255" />
|
||||||
</section>
|
</section>
|
||||||
<section id="news">
|
<section id="news">
|
||||||
<option id="cache_file" type="std::string" />
|
<option id="cache_file" type="std::string" />
|
||||||
|
@ -601,6 +601,8 @@ SwitchNonactiveLayersOpacity = Switch Nonactive Layers Opacity
|
|||||||
SymmetryMode = Symmetry Mode
|
SymmetryMode = Symmetry Mode
|
||||||
TiledMode = Tiled Mode
|
TiledMode = Tiled Mode
|
||||||
Timeline = Switch Timeline
|
Timeline = Switch Timeline
|
||||||
|
ToggleOtherLayersOpacity = Toggle Other Layers Opacity
|
||||||
|
ToggleOtherLayersOpacity_PreviewEditor = Toggle Other Layers Opacity in Preview
|
||||||
TogglePlayAll = Play All Frames (Ignore Tags)
|
TogglePlayAll = Play All Frames (Ignore Tags)
|
||||||
TogglePlayOnce = Play Once
|
TogglePlayOnce = Play Once
|
||||||
TogglePlaySubtags = Play Subtags & Repetitions
|
TogglePlaySubtags = Play Subtags & Repetitions
|
||||||
@ -1350,6 +1352,7 @@ view_set_loop_section = Set &Loop Section
|
|||||||
view_show_onion_skin = Show &Onion Skin
|
view_show_onion_skin = Show &Onion Skin
|
||||||
view_timeline = &Timeline
|
view_timeline = &Timeline
|
||||||
view_preview = Previe&w
|
view_preview = Previe&w
|
||||||
|
view_preview_hide_other_layers = &Hide Other Layers
|
||||||
view_advanced_mode = &Advanced Mode
|
view_advanced_mode = &Advanced Mode
|
||||||
view_full_screen_mode = &Full Screen Mode
|
view_full_screen_mode = &Full Screen Mode
|
||||||
view_full_screen_preview = F&ull Screen Preview
|
view_full_screen_preview = F&ull Screen Preview
|
||||||
|
@ -330,6 +330,7 @@ if(ENABLE_UI)
|
|||||||
commands/set_playback_speed.cpp
|
commands/set_playback_speed.cpp
|
||||||
commands/show_menu.cpp
|
commands/show_menu.cpp
|
||||||
commands/tileset_mode.cpp
|
commands/tileset_mode.cpp
|
||||||
|
commands/toggle_other_layers_opacity.cpp
|
||||||
commands/toggle_play_option.cpp
|
commands/toggle_play_option.cpp
|
||||||
file_selector.cpp
|
file_selector.cpp
|
||||||
modules/gfx.cpp
|
modules/gfx.cpp
|
||||||
|
@ -168,6 +168,7 @@ FOR_EACH_COMMAND(SymmetryMode)
|
|||||||
FOR_EACH_COMMAND(TiledMode)
|
FOR_EACH_COMMAND(TiledMode)
|
||||||
FOR_EACH_COMMAND(TilesetMode)
|
FOR_EACH_COMMAND(TilesetMode)
|
||||||
FOR_EACH_COMMAND(Timeline)
|
FOR_EACH_COMMAND(Timeline)
|
||||||
|
FOR_EACH_COMMAND(ToggleOtherLayersOpacity)
|
||||||
FOR_EACH_COMMAND(TogglePlayAll)
|
FOR_EACH_COMMAND(TogglePlayAll)
|
||||||
FOR_EACH_COMMAND(TogglePlayOnce)
|
FOR_EACH_COMMAND(TogglePlayOnce)
|
||||||
FOR_EACH_COMMAND(TogglePlaySubtags)
|
FOR_EACH_COMMAND(TogglePlaySubtags)
|
||||||
|
114
src/app/commands/toggle_other_layers_opacity.cpp
Normal file
114
src/app/commands/toggle_other_layers_opacity.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
// Aseprite
|
||||||
|
// Copyright (C) 2023 Igara Studio S.A.
|
||||||
|
//
|
||||||
|
// This program is distributed under the terms of
|
||||||
|
// the End-User License Agreement for Aseprite.
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
|
#include "app/commands/new_params.h"
|
||||||
|
#include "app/i18n/strings.h"
|
||||||
|
#include "app/ui/editor/editor.h"
|
||||||
|
#include "app/ui/main_window.h"
|
||||||
|
#include "app/ui/preview_editor.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
#include "ui/system.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
|
||||||
|
struct ToggleOtherLayersOpacityParams : public NewParams {
|
||||||
|
Param<bool> preview { this, false, "preview" };
|
||||||
|
Param<int> opacity { this, 255, "opacity" };
|
||||||
|
// Can be used if the option is presend as "Hide Others", so it's
|
||||||
|
// checked when the configured opacity == 0
|
||||||
|
Param<bool> checkedIfZero { this, false, "checkedIfZero" };
|
||||||
|
};
|
||||||
|
|
||||||
|
class ToggleOtherLayersOpacityCommand : public CommandWithNewParams<ToggleOtherLayersOpacityParams> {
|
||||||
|
public:
|
||||||
|
ToggleOtherLayersOpacityCommand();
|
||||||
|
private:
|
||||||
|
bool onChecked(Context* ctx) override;
|
||||||
|
void onExecute(Context* ctx) override;
|
||||||
|
std::string onGetFriendlyName() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
ToggleOtherLayersOpacityCommand::ToggleOtherLayersOpacityCommand()
|
||||||
|
: CommandWithNewParams<ToggleOtherLayersOpacityParams>(
|
||||||
|
CommandId::ToggleOtherLayersOpacity(), CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ToggleOtherLayersOpacityCommand::onChecked(Context* ctx)
|
||||||
|
{
|
||||||
|
if (params().checkedIfZero.isSet()) {
|
||||||
|
auto& pref = Preferences::instance();
|
||||||
|
auto& option =
|
||||||
|
(params().preview() ?
|
||||||
|
pref.experimental.nonactiveLayersOpacityPreview:
|
||||||
|
pref.experimental.nonactiveLayersOpacity);
|
||||||
|
return (option() == 0);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToggleOtherLayersOpacityCommand::onExecute(Context* ctx)
|
||||||
|
{
|
||||||
|
auto& pref = Preferences::instance();
|
||||||
|
auto& option =
|
||||||
|
(params().preview() ?
|
||||||
|
pref.experimental.nonactiveLayersOpacityPreview:
|
||||||
|
pref.experimental.nonactiveLayersOpacity);
|
||||||
|
|
||||||
|
// If we want to toggle the other layers in the preview window, and
|
||||||
|
// the preview window is hidden, we just show it with the "other
|
||||||
|
// layers" hidden.
|
||||||
|
if (params().preview()) {
|
||||||
|
PreviewEditorWindow* previewWin =
|
||||||
|
App::instance()->mainWindow()->getPreviewEditor();
|
||||||
|
if (!previewWin->isPreviewEnabled()) {
|
||||||
|
option(0);
|
||||||
|
previewWin->setPreviewEnabled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params().opacity.isSet()) {
|
||||||
|
option(params().opacity());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
option(option() == 0 ? 255: 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO make the editors listen the opacity change
|
||||||
|
if (params().preview()) {
|
||||||
|
PreviewEditorWindow* previewWin =
|
||||||
|
App::instance()->mainWindow()->getPreviewEditor();
|
||||||
|
previewWin->previewEditor()->invalidate();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
app_refresh_screen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ToggleOtherLayersOpacityCommand::onGetFriendlyName() const
|
||||||
|
{
|
||||||
|
std::string text;
|
||||||
|
if (params().preview())
|
||||||
|
text = Strings::commands_ToggleOtherLayersOpacity_PreviewEditor();
|
||||||
|
else
|
||||||
|
text = Strings::commands_ToggleOtherLayersOpacity();
|
||||||
|
if (params().opacity.isSet())
|
||||||
|
text = fmt::format("{} ({})", text, params().opacity());
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command* CommandFactory::createToggleOtherLayersOpacityCommand()
|
||||||
|
{
|
||||||
|
return new ToggleOtherLayersOpacityCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace app
|
@ -383,7 +383,7 @@ void Editor::setLayer(const Layer* layer)
|
|||||||
// If the user want to see the active layer edges...
|
// If the user want to see the active layer edges...
|
||||||
m_docPref.show.layerEdges() ||
|
m_docPref.show.layerEdges() ||
|
||||||
// If there is a different opacity for nonactive-layers
|
// If there is a different opacity for nonactive-layers
|
||||||
Preferences::instance().experimental.nonactiveLayersOpacity() < 255 ||
|
otherLayersOpacity() < 255 ||
|
||||||
// If the automatic cel guides are visible...
|
// If the automatic cel guides are visible...
|
||||||
m_showGuidesThisCel ||
|
m_showGuidesThisCel ||
|
||||||
// If grid settings changed
|
// If grid settings changed
|
||||||
@ -672,10 +672,7 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
|
|||||||
m_renderEngine->setNewBlendMethod(pref.experimental.newBlend());
|
m_renderEngine->setNewBlendMethod(pref.experimental.newBlend());
|
||||||
m_renderEngine->setRefLayersVisiblity(true);
|
m_renderEngine->setRefLayersVisiblity(true);
|
||||||
m_renderEngine->setSelectedLayer(m_layer);
|
m_renderEngine->setSelectedLayer(m_layer);
|
||||||
if (m_flags & Editor::kUseNonactiveLayersOpacityWhenEnabled)
|
m_renderEngine->setNonactiveLayersOpacity(otherLayersOpacity());
|
||||||
m_renderEngine->setNonactiveLayersOpacity(pref.experimental.nonactiveLayersOpacity());
|
|
||||||
else
|
|
||||||
m_renderEngine->setNonactiveLayersOpacity(255);
|
|
||||||
m_renderEngine->setupBackground(m_document, IMAGE_RGB);
|
m_renderEngine->setupBackground(m_document, IMAGE_RGB);
|
||||||
m_renderEngine->disableOnionskin();
|
m_renderEngine->disableOnionskin();
|
||||||
|
|
||||||
@ -2978,9 +2975,18 @@ void Editor::updateAutoCelGuides(ui::Message* msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Editor::otherLayersOpacity() const
|
||||||
|
{
|
||||||
|
if (m_docView && m_docView->isPreview())
|
||||||
|
return Preferences::instance().experimental.nonactiveLayersOpacityPreview();
|
||||||
|
else
|
||||||
|
return Preferences::instance().experimental.nonactiveLayersOpacity();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Editor::registerCommands()
|
void Editor::registerCommands()
|
||||||
{
|
{
|
||||||
|
// TODO merge with ToggleOtherLayersOpacity
|
||||||
Commands::instance()
|
Commands::instance()
|
||||||
->add(
|
->add(
|
||||||
new QuickCommand(
|
new QuickCommand(
|
||||||
|
@ -90,15 +90,13 @@ namespace app {
|
|||||||
kShowDecorators = 16,
|
kShowDecorators = 16,
|
||||||
kShowSymmetryLine = 32,
|
kShowSymmetryLine = 32,
|
||||||
kShowSlices = 64,
|
kShowSlices = 64,
|
||||||
kUseNonactiveLayersOpacityWhenEnabled = 128,
|
|
||||||
kDefaultEditorFlags = (kShowGrid |
|
kDefaultEditorFlags = (kShowGrid |
|
||||||
kShowMask |
|
kShowMask |
|
||||||
kShowOnionskin |
|
kShowOnionskin |
|
||||||
kShowOutside |
|
kShowOutside |
|
||||||
kShowDecorators |
|
kShowDecorators |
|
||||||
kShowSymmetryLine |
|
kShowSymmetryLine |
|
||||||
kShowSlices |
|
kShowSlices)
|
||||||
kUseNonactiveLayersOpacityWhenEnabled)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ZoomBehavior {
|
enum class ZoomBehavior {
|
||||||
@ -398,6 +396,8 @@ namespace app {
|
|||||||
void invalidateIfActive();
|
void invalidateIfActive();
|
||||||
void updateAutoCelGuides(ui::Message* msg);
|
void updateAutoCelGuides(ui::Message* msg);
|
||||||
|
|
||||||
|
int otherLayersOpacity() const;
|
||||||
|
|
||||||
// Stack of states. The top element in the stack is the current state (m_state).
|
// Stack of states. The top element in the stack is the current state (m_state).
|
||||||
EditorStatesHistory m_statesHistory;
|
EditorStatesHistory m_statesHistory;
|
||||||
EditorStatesHistory m_deletedStates;
|
EditorStatesHistory m_deletedStates;
|
||||||
|
Loading…
Reference in New Issue
Block a user