mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-01 18:00:26 +00:00
Put back a simpler vesion of the target button for cels
Now we have a button to apply filters to the selected region
in the timeline, or to all cels. Regression introduced in 245285f84e
Discussion:
http://steamcommunity.com/app/431730/discussions/0/343785574514723475/
This commit is contained in:
parent
9729f7aec8
commit
58252946ea
@ -288,6 +288,9 @@
|
||||
<section id="hue_saturation">
|
||||
<option id="mode" type="HueSaturationMode" default="HueSaturationMode::HSL" />
|
||||
</section>
|
||||
<section id="filters">
|
||||
<option id="cels_target" type="CelsTarget" default="CelsTarget::Selected" />
|
||||
</section>
|
||||
</global>
|
||||
|
||||
<tool>
|
||||
|
@ -507,6 +507,12 @@ new_folder_button_tooltip = New folder
|
||||
file_name = File name:
|
||||
file_type = File type:
|
||||
|
||||
[filters]
|
||||
selected_cels = Selected
|
||||
selected_cels_tooltip = Apply to the active selection in the timeline
|
||||
all_cels = All
|
||||
all_cels_tooltip = Apply to all cels in the sprite
|
||||
|
||||
[font_popup]
|
||||
load = Load
|
||||
|
||||
|
20
src/app/commands/filters/cels_target.h
Normal file
20
src/app/commands/filters/cels_target.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef APP_COMMANDS_FILTERS_CELS_TARGET_H_INCLUDED
|
||||
#define APP_COMMANDS_FILTERS_CELS_TARGET_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace app {
|
||||
|
||||
enum class CelsTarget {
|
||||
Selected, // Selected cels in the timeline
|
||||
All // All cels in the sprite
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -28,7 +28,7 @@
|
||||
#include "app/util/range_utils.h"
|
||||
#include "doc/algorithm/shrink_bounds.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/cels_range.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/mask.h"
|
||||
@ -55,15 +55,15 @@ FilterManagerImpl::FilterManagerImpl(Context* context, Filter* filter)
|
||||
, m_cel(nullptr)
|
||||
, m_src(nullptr)
|
||||
, m_dst(nullptr)
|
||||
, m_row(0)
|
||||
, m_mask(nullptr)
|
||||
, m_previewMask(nullptr)
|
||||
, m_targetOrig(TARGET_ALL_CHANNELS)
|
||||
, m_target(TARGET_ALL_CHANNELS)
|
||||
, m_celsTarget(CelsTarget::Selected)
|
||||
, m_oldPalette(nullptr)
|
||||
, m_progressDelegate(NULL)
|
||||
{
|
||||
m_row = 0;
|
||||
m_targetOrig = TARGET_ALL_CHANNELS;
|
||||
m_target = TARGET_ALL_CHANNELS;
|
||||
|
||||
int x, y;
|
||||
Image* image = m_site.image(&x, &y);
|
||||
if (!image)
|
||||
@ -106,6 +106,11 @@ void FilterManagerImpl::setTarget(int target)
|
||||
m_target &= ~TARGET_ALPHA_CHANNEL;
|
||||
}
|
||||
|
||||
void FilterManagerImpl::setCelsTarget(CelsTarget celsTarget)
|
||||
{
|
||||
m_celsTarget = celsTarget;
|
||||
}
|
||||
|
||||
void FilterManagerImpl::begin()
|
||||
{
|
||||
Document* document = static_cast<app::Document*>(m_site.document());
|
||||
@ -232,13 +237,28 @@ void FilterManagerImpl::applyToTarget()
|
||||
bool cancelled = false;
|
||||
|
||||
CelList cels;
|
||||
auto range = App::instance()->timeline()->range();
|
||||
if (range.enabled())
|
||||
cels = get_unlocked_unique_cels(m_site.sprite(), range);
|
||||
else if (m_site.cel() &&
|
||||
m_site.layer() &&
|
||||
m_site.layer()->isEditable()) {
|
||||
cels.push_back(m_site.cel());
|
||||
|
||||
switch (m_celsTarget) {
|
||||
|
||||
case CelsTarget::Selected: {
|
||||
auto range = App::instance()->timeline()->range();
|
||||
if (range.enabled())
|
||||
cels = get_unlocked_unique_cels(m_site.sprite(), range);
|
||||
else if (m_site.cel() &&
|
||||
m_site.layer() &&
|
||||
m_site.layer()->isEditable()) {
|
||||
cels.push_back(m_site.cel());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CelsTarget::All: {
|
||||
for (Cel* cel : m_site.sprite()->uniqueCels()) {
|
||||
if (cel->layer()->isEditable())
|
||||
cels.push_back(cel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cels.empty() && !paletteChange) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define APP_COMMANDS_FILTERS_FILTER_MANAGER_IMPL_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/commands/filters/cels_target.h"
|
||||
#include "base/exception.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/image_impl.h"
|
||||
@ -77,6 +78,7 @@ namespace app {
|
||||
doc::PixelFormat pixelFormat() const;
|
||||
|
||||
void setTarget(Target target);
|
||||
void setCelsTarget(CelsTarget celsTarget);
|
||||
|
||||
void begin();
|
||||
void beginForPreview();
|
||||
@ -144,6 +146,7 @@ namespace app {
|
||||
doc::ImageBits<doc::BitmapTraits>::iterator m_maskIterator;
|
||||
Target m_targetOrig; // Original targets
|
||||
Target m_target; // Filtered targets
|
||||
CelsTarget m_celsTarget;
|
||||
base::UniquePtr<doc::Palette> m_oldPalette;
|
||||
std::unique_ptr<Transaction> m_transaction;
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "app/commands/filters/filter_target_buttons.h"
|
||||
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/modules/gfx.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
@ -31,12 +32,14 @@ using namespace ui;
|
||||
FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
|
||||
: ButtonSet(4)
|
||||
, m_target(0)
|
||||
, m_celsTarget(CelsTarget::Selected)
|
||||
, m_red(nullptr)
|
||||
, m_green(nullptr)
|
||||
, m_blue(nullptr)
|
||||
, m_alpha(nullptr)
|
||||
, m_gray(nullptr)
|
||||
, m_index(nullptr)
|
||||
, m_cels(nullptr)
|
||||
{
|
||||
setMultipleSelection(true);
|
||||
addChild(&m_tooltips);
|
||||
@ -61,9 +64,13 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the button to select which cels will be modified by the
|
||||
// filter.
|
||||
m_cels = addItem(getCelsTargetText(), 4, 1);
|
||||
}
|
||||
|
||||
void FilterTargetButtons::setTarget(int target)
|
||||
void FilterTargetButtons::setTarget(const int target)
|
||||
{
|
||||
selectTargetButton(m_red, TARGET_RED_CHANNEL);
|
||||
selectTargetButton(m_green, TARGET_GREEN_CHANNEL);
|
||||
@ -71,10 +78,15 @@ void FilterTargetButtons::setTarget(int target)
|
||||
selectTargetButton(m_alpha, TARGET_ALPHA_CHANNEL);
|
||||
selectTargetButton(m_gray, TARGET_GRAY_CHANNEL);
|
||||
selectTargetButton(m_index, TARGET_INDEX_CHANNEL);
|
||||
|
||||
updateFromTarget();
|
||||
}
|
||||
|
||||
void FilterTargetButtons::setCelsTarget(const CelsTarget celsTarget)
|
||||
{
|
||||
m_celsTarget = celsTarget;
|
||||
updateFromCelsTarget();
|
||||
}
|
||||
|
||||
void FilterTargetButtons::selectTargetButton(Item* item, Target specificTarget)
|
||||
{
|
||||
if (item)
|
||||
@ -91,6 +103,12 @@ void FilterTargetButtons::updateFromTarget()
|
||||
updateComponentTooltip(m_index, "Index", LEFT);
|
||||
}
|
||||
|
||||
void FilterTargetButtons::updateFromCelsTarget()
|
||||
{
|
||||
m_cels->setText(getCelsTargetText());
|
||||
m_tooltips.addTooltipFor(m_cels, getCelsTargetTooltip(), LEFT);
|
||||
}
|
||||
|
||||
void FilterTargetButtons::updateComponentTooltip(Item* item, const char* channelName, int align)
|
||||
{
|
||||
if (item) {
|
||||
@ -105,7 +123,8 @@ void FilterTargetButtons::updateComponentTooltip(Item* item, const char* channel
|
||||
void FilterTargetButtons::onItemChange(Item* item)
|
||||
{
|
||||
ButtonSet::onItemChange(item);
|
||||
Target flags = m_target;
|
||||
Target target = m_target;
|
||||
CelsTarget celsTarget = m_celsTarget;
|
||||
|
||||
if (m_index && item && item->isSelected()) {
|
||||
if (item == m_index) {
|
||||
@ -122,18 +141,51 @@ void FilterTargetButtons::onItemChange(Item* item)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_red && m_red->isSelected()) flags |= TARGET_RED_CHANNEL;
|
||||
if (m_green && m_green->isSelected()) flags |= TARGET_GREEN_CHANNEL;
|
||||
if (m_blue && m_blue->isSelected()) flags |= TARGET_BLUE_CHANNEL;
|
||||
if (m_gray && m_gray->isSelected()) flags |= TARGET_GRAY_CHANNEL;
|
||||
if (m_index && m_index->isSelected()) flags |= TARGET_INDEX_CHANNEL;
|
||||
if (m_alpha && m_alpha->isSelected()) flags |= TARGET_ALPHA_CHANNEL;
|
||||
if (m_red && m_red->isSelected()) target |= TARGET_RED_CHANNEL;
|
||||
if (m_green && m_green->isSelected()) target |= TARGET_GREEN_CHANNEL;
|
||||
if (m_blue && m_blue->isSelected()) target |= TARGET_BLUE_CHANNEL;
|
||||
if (m_gray && m_gray->isSelected()) target |= TARGET_GRAY_CHANNEL;
|
||||
if (m_index && m_index->isSelected()) target |= TARGET_INDEX_CHANNEL;
|
||||
if (m_alpha && m_alpha->isSelected()) target |= TARGET_ALPHA_CHANNEL;
|
||||
|
||||
if (m_target != flags) {
|
||||
m_target = flags;
|
||||
updateFromTarget();
|
||||
if (m_cels->isSelected()) {
|
||||
m_cels->setSelected(false);
|
||||
celsTarget = // Switch cels target
|
||||
(m_celsTarget == CelsTarget::Selected ?
|
||||
CelsTarget::All:
|
||||
CelsTarget::Selected);
|
||||
}
|
||||
|
||||
if (m_target != target ||
|
||||
m_celsTarget != celsTarget) {
|
||||
if (m_target != target) {
|
||||
m_target = target;
|
||||
updateFromTarget();
|
||||
}
|
||||
if (m_celsTarget != celsTarget) {
|
||||
m_celsTarget = celsTarget;
|
||||
updateFromCelsTarget();
|
||||
}
|
||||
TargetChange();
|
||||
}
|
||||
}
|
||||
|
||||
std::string FilterTargetButtons::getCelsTargetText() const
|
||||
{
|
||||
switch (m_celsTarget) {
|
||||
case CelsTarget::Selected: return Strings::filters_selected_cels();
|
||||
case CelsTarget::All: return Strings::filters_all_cels();
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string FilterTargetButtons::getCelsTargetTooltip() const
|
||||
{
|
||||
switch (m_celsTarget) {
|
||||
case CelsTarget::Selected: return Strings::filters_selected_cels_tooltip();
|
||||
case CelsTarget::All: return Strings::filters_all_cels_tooltip();
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016, 2018 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -8,6 +8,7 @@
|
||||
#define APP_COMMANDS_FILTERS_FILTER_TARGET_BUTTONS_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/commands/filters/cels_target.h"
|
||||
#include "app/ui/button_set.h"
|
||||
#include "app/ui/skin/skin_part.h"
|
||||
#include "filters/target.h"
|
||||
@ -27,8 +28,11 @@ namespace app {
|
||||
// the a sprite.
|
||||
FilterTargetButtons(int imgtype, bool withChannels);
|
||||
|
||||
Target getTarget() const { return m_target; }
|
||||
void setTarget(Target target);
|
||||
Target target() const { return m_target; }
|
||||
CelsTarget celsTarget() const { return m_celsTarget; }
|
||||
|
||||
void setTarget(const Target target);
|
||||
void setCelsTarget(const CelsTarget celsTarget);
|
||||
|
||||
obs::signal<void()> TargetChange;
|
||||
|
||||
@ -40,15 +44,20 @@ namespace app {
|
||||
private:
|
||||
void selectTargetButton(Item* item, Target specificTarget);
|
||||
void updateFromTarget();
|
||||
void updateFromCelsTarget();
|
||||
void updateComponentTooltip(Item* item, const char* channelName, int align);
|
||||
std::string getCelsTargetText() const;
|
||||
std::string getCelsTargetTooltip() const;
|
||||
|
||||
Target m_target;
|
||||
CelsTarget m_celsTarget;
|
||||
Item* m_red;
|
||||
Item* m_green;
|
||||
Item* m_blue;
|
||||
Item* m_alpha;
|
||||
Item* m_gray;
|
||||
Item* m_index;
|
||||
Item* m_cels;
|
||||
ui::TooltipManager m_tooltips;
|
||||
};
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "app/ini_file.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "base/bind.h"
|
||||
|
||||
@ -47,7 +48,11 @@ FilterWindow::FilterWindow(const char* title, const char* cfgSection,
|
||||
if (m_tiledCheck)
|
||||
m_tiledCheck->processMnemonicFromText();
|
||||
|
||||
CelsTarget celsTarget = Preferences::instance().filters.celsTarget();
|
||||
filterMgr->setCelsTarget(celsTarget);
|
||||
|
||||
m_targetButton.setTarget(filterMgr->getTarget());
|
||||
m_targetButton.setCelsTarget(celsTarget);
|
||||
m_targetButton.TargetChange.connect(&FilterWindow::onTargetButtonChange, this);
|
||||
m_okButton.Click.connect(&FilterWindow::onOk, this);
|
||||
m_cancelButton.Click.connect(&FilterWindow::onCancel, this);
|
||||
@ -87,6 +92,9 @@ FilterWindow::~FilterWindow()
|
||||
|
||||
// Save "Preview" check status.
|
||||
set_config_bool(m_cfgSection, "Preview", m_showPreview.isSelected());
|
||||
|
||||
// Save cels target button
|
||||
Preferences::instance().filters.celsTarget(m_targetButton.celsTarget());
|
||||
}
|
||||
|
||||
bool FilterWindow::doModal()
|
||||
@ -166,7 +174,8 @@ void FilterWindow::onTargetButtonChange()
|
||||
stopPreview();
|
||||
|
||||
// Change the targets in the filter manager and restart the filter preview.
|
||||
m_filterMgr->setTarget(m_targetButton.getTarget());
|
||||
m_filterMgr->setTarget(m_targetButton.target());
|
||||
m_filterMgr->setCelsTarget(m_targetButton.celsTarget());
|
||||
restartPreview();
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/color.h"
|
||||
#include "app/commands/filters/cels_target.h"
|
||||
#include "app/document_exporter.h"
|
||||
#include "app/pref/option.h"
|
||||
#include "app/sprite_sheet_type.h"
|
||||
|
Loading…
Reference in New Issue
Block a user