Add SwitchNonactiveLayersOpacity command (fix #1515)

This is a temporal solution but it's good enough for an experimental
feature.
This commit is contained in:
David Capello 2017-12-06 14:44:40 -03:00
parent b0b3818267
commit 7dcc0072f1
4 changed files with 33 additions and 0 deletions

View File

@ -370,6 +370,7 @@ SnapToGrid = Snap to Grid
SpriteProperties = Sprite Properties
SpriteSize = Sprite Size
SwitchColors = Switch Colors
SwitchNonactiveLayersOpacity = Switch Nonactive Layers Opacity
SymmetryMode = Symmetry Mode
TiledMode = Tiled Mode
Timeline = Switch Timeline

View File

@ -16,7 +16,9 @@
#include "app/color_utils.h"
#include "app/commands/commands.h"
#include "app/commands/params.h"
#include "app/commands/quick_command.h"
#include "app/console.h"
#include "app/i18n/strings.h"
#include "app/ini_file.h"
#include "app/modules/editors.h"
#include "app/modules/gfx.h"
@ -2485,4 +2487,30 @@ void Editor::updateAutoCelGuides(ui::Message* msg)
invalidate();
}
// static
void Editor::registerCommands()
{
Commands::instance()
->add(
new QuickCommand(
CommandId::SwitchNonactiveLayersOpacity(),
[]{
static int oldValue = -1;
auto& option = Preferences::instance().experimental.nonactiveLayersOpacity;
if (oldValue == -1) {
oldValue = option();
if (option() == 255)
option(128);
else
option(255);
}
else {
const int newValue = oldValue;
oldValue = option();
option(newValue);
}
app_refresh_screen();
}));
}
} // namespace app

View File

@ -269,6 +269,8 @@ namespace app {
// freehand tool is pressed.
bool startStraightLineWithFreehandTool(const ui::MouseMessage* msg);
static void registerCommands();
protected:
bool onProcessMessage(ui::Message* msg) override;
void onSizeHint(ui::SizeHintEvent& ev) override;

View File

@ -101,6 +101,8 @@ MainWindow::MainWindow()
m_previewEditor = new PreviewEditorWindow();
m_timeline = new Timeline();
Editor::registerCommands();
m_workspace->setTabsBar(m_tabsBar);
m_workspace->ActiveViewChanged.connect(&MainWindow::onActiveViewChange, this);