Merge branch 'main' into beta

This commit is contained in:
David Capello 2021-06-29 21:15:57 -03:00
commit 66e77a7e49
3 changed files with 41 additions and 30 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -45,6 +45,8 @@ namespace app {
using namespace ui;
static const char* ConfigSection = "MaskColor";
class MaskByColorCommand : public Command {
public:
MaskByColorCommand();
@ -113,13 +115,12 @@ void MaskByColorCommand::onExecute(Context* context)
auto box3 = new Box(HORIZONTAL);
auto box4 = new Box(HORIZONTAL | HOMOGENEOUS);
auto label_color = new Label("Color:");
m_buttonColor = new ColorButton
(get_config_color("MaskColor", "Color",
ColorBar::instance()->getFgColor()),
sprite->pixelFormat(),
ColorButtonOptions());
m_buttonColor = new ColorButton(
ColorBar::instance()->getFgColor(),
sprite->pixelFormat(),
ColorButtonOptions());
auto label_tolerance = new Label("Tolerance:");
m_sliderTolerance = new Slider(0, 255, get_config_int("MaskColor", "Tolerance", 0));
m_sliderTolerance = new Slider(0, 255, get_config_int(ConfigSection, "Tolerance", 0));
m_selMode = new SelModeField;
m_selMode->setupTooltips(tooltipManager);
@ -132,7 +133,7 @@ void MaskByColorCommand::onExecute(Context* context)
button_ok->processMnemonicFromText();
button_cancel->processMnemonicFromText();
if (get_config_bool("MaskColor", "Preview", true))
if (get_config_bool(ConfigSection, "Preview", true))
m_checkPreview->setSelected(true);
button_ok->Click.connect([this, button_ok]{ m_window->closeWindow(button_ok); });
@ -169,7 +170,7 @@ void MaskByColorCommand::onExecute(Context* context)
maskPreview(reader);
// Load window configuration
load_window_pos(m_window, "MaskColor");
load_window_pos(m_window, ConfigSection);
// Open the window
m_window->openWindowInForeground();
@ -187,9 +188,8 @@ void MaskByColorCommand::onExecute(Context* context)
tx(new cmd::SetMask(document, mask.get()));
tx.commit();
set_config_color("MaskColor", "Color", m_buttonColor->getColor());
set_config_int("MaskColor", "Tolerance", m_sliderTolerance->getValue());
set_config_bool("MaskColor", "Preview", m_checkPreview->isSelected());
set_config_int(ConfigSection, "Tolerance", m_sliderTolerance->getValue());
set_config_bool(ConfigSection, "Preview", m_checkPreview->isSelected());
}
else {
document->generateMaskBoundaries();
@ -199,7 +199,7 @@ void MaskByColorCommand::onExecute(Context* context)
update_screen_for_document(document);
// Save window configuration.
save_window_pos(m_window, "MaskColor");
save_window_pos(m_window, ConfigSection);
}
Mask* MaskByColorCommand::generateMask(const Mask& origMask,

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2020-2021 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -34,6 +34,9 @@ public:
protected:
void onExecute(Context* context) override;
private:
void postCancelMenuLoop();
};
RefreshCommand::RefreshCommand()
@ -42,9 +45,27 @@ RefreshCommand::RefreshCommand()
}
void RefreshCommand::onExecute(Context* context)
{
if (!context->isUIAvailable())
return;
// Close the current menu loop just in case if there is a menu popup
// open, and then enqueue the postReload() function after all menus
// are closed.
App::instance()->mainWindow()->getMenuBar()->cancelMenuLoop();
// Now that all menus are going to be closed (the final close
// messages are enqueued in the UI message queue), we can queue a
// function call that will reload all menus.
ui::execute_from_ui_thread(
[this]{
postCancelMenuLoop();
});
}
void RefreshCommand::postCancelMenuLoop()
{
// Reload menus (mainly to reload the File > Scripts menu)
//AppMenus::instance()->reload();
App::instance()->mainWindow()->getMenuBar()->reload();
// Reload theme

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -180,19 +180,12 @@ void ReplaceColorCommand::onExecute(Context* context)
TARGET_GRAY_CHANNEL |
TARGET_ALPHA_CHANNEL);
filter.setFrom(Preferences::instance().colorBar.fgColor());
filter.setTo(Preferences::instance().colorBar.bgColor());
#ifdef ENABLE_UI
if (ui) {
filter.setFrom(get_config_color(ConfigSection, "Color1", Preferences::instance().colorBar.fgColor()));
filter.setTo(get_config_color(ConfigSection, "Color2", Preferences::instance().colorBar.bgColor()));
if (ui)
filter.setTolerance(get_config_int(ConfigSection, "Tolerance", 0));
}
else
#endif // ENABLE_UI
{
filter.setFrom(Preferences::instance().colorBar.fgColor());
filter.setTo(Preferences::instance().colorBar.bgColor());
filter.setTolerance(params().tolerance());
}
if (params().from.isSet()) filter.setFrom(params().from());
if (params().to.isSet()) filter.setTo(params().to());
@ -202,11 +195,8 @@ void ReplaceColorCommand::onExecute(Context* context)
#ifdef ENABLE_UI
if (ui) {
ReplaceColorWindow window(filter, filterMgr);
if (window.doModal()) {
set_config_color(ConfigSection, "From", filter.getFrom());
set_config_color(ConfigSection, "To", filter.getTo());
if (window.doModal())
set_config_int(ConfigSection, "Tolerance", filter.getTolerance());
}
}
else
#endif // ENABLE_UI