mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 13:21:34 +00:00
Refresh editors when blend mode is changed in LayerProperties combobox
This commit is contained in:
parent
21ca87862c
commit
415995183d
@ -19,8 +19,10 @@
|
||||
#include "app/context_access.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/transaction.h"
|
||||
#include "doc/document.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
#include "generated_layer_properties.h"
|
||||
|
||||
@ -38,6 +40,71 @@ protected:
|
||||
void onExecute(Context* context);
|
||||
};
|
||||
|
||||
class LayerPropertiesWindow : public app::gen::LayerProperties {
|
||||
public:
|
||||
|
||||
LayerPropertiesWindow(const LayerImage* layer)
|
||||
: m_layer(const_cast<LayerImage*>(layer))
|
||||
, m_oldBlendMode(layer->blendMode()) {
|
||||
name()->setText(layer->name().c_str());
|
||||
name()->setMinSize(gfx::Size(128, 0));
|
||||
name()->setExpansive(true);
|
||||
|
||||
mode()->addItem("Normal");
|
||||
mode()->addItem("Multiply");
|
||||
mode()->addItem("Screen");
|
||||
mode()->addItem("Overlay");
|
||||
mode()->addItem("Darken");
|
||||
mode()->addItem("Lighten");
|
||||
mode()->addItem("Color Dodge");
|
||||
mode()->addItem("Color Burn");
|
||||
mode()->addItem("Hard Light");
|
||||
mode()->addItem("Soft Light");
|
||||
mode()->addItem("Difference");
|
||||
mode()->addItem("Exclusion");
|
||||
mode()->addItem("Hue");
|
||||
mode()->addItem("Saturation");
|
||||
mode()->addItem("Color");
|
||||
mode()->addItem("Luminosity");
|
||||
mode()->setSelectedItemIndex((int)layer->blendMode());
|
||||
mode()->setEnabled(!layer->isBackground());
|
||||
mode()->Change.connect(Bind<void>(&LayerPropertiesWindow::onBlendModeChange, this));
|
||||
|
||||
remapWindow();
|
||||
centerWindow();
|
||||
load_window_pos(this, "LayerProperties");
|
||||
}
|
||||
|
||||
std::string nameValue() const {
|
||||
return name()->getText();
|
||||
}
|
||||
|
||||
BlendMode blendModeValue() const {
|
||||
return (BlendMode)mode()->getSelectedItemIndex();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
bool onProcessMessage(ui::Message* msg) override {
|
||||
switch (msg->type()) {
|
||||
case kCloseMessage:
|
||||
m_layer->setBlendMode(m_oldBlendMode);
|
||||
save_window_pos(this, "LayerProperties");
|
||||
break;
|
||||
}
|
||||
return Window::onProcessMessage(msg);
|
||||
}
|
||||
|
||||
void onBlendModeChange() {
|
||||
m_layer->setBlendMode(blendModeValue());
|
||||
update_screen_for_document(
|
||||
static_cast<app::Document*>(m_layer->sprite()->document()));
|
||||
}
|
||||
|
||||
LayerImage* m_layer;
|
||||
BlendMode m_oldBlendMode;
|
||||
};
|
||||
|
||||
LayerPropertiesCommand::LayerPropertiesCommand()
|
||||
: Command("LayerProperties",
|
||||
"Layer Properties",
|
||||
@ -56,36 +123,13 @@ void LayerPropertiesCommand::onExecute(Context* context)
|
||||
const ContextReader reader(context);
|
||||
const LayerImage* layer = static_cast<const LayerImage*>(reader.layer());
|
||||
|
||||
app::gen::LayerProperties window;
|
||||
|
||||
window.name()->setText(layer->name().c_str());
|
||||
window.name()->setMinSize(gfx::Size(128, 0));
|
||||
window.name()->setExpansive(true);
|
||||
|
||||
window.mode()->addItem("Normal");
|
||||
window.mode()->addItem("Multiply");
|
||||
window.mode()->addItem("Screen");
|
||||
window.mode()->addItem("Overlay");
|
||||
window.mode()->addItem("Darken");
|
||||
window.mode()->addItem("Lighten");
|
||||
window.mode()->addItem("Color Dodge");
|
||||
window.mode()->addItem("Color Burn");
|
||||
window.mode()->addItem("Hard Light");
|
||||
window.mode()->addItem("Soft Light");
|
||||
window.mode()->addItem("Difference");
|
||||
window.mode()->addItem("Exclusion");
|
||||
window.mode()->addItem("Hue");
|
||||
window.mode()->addItem("Saturation");
|
||||
window.mode()->addItem("Color");
|
||||
window.mode()->addItem("Luminosity");
|
||||
window.mode()->setSelectedItemIndex((int)layer->blendMode());
|
||||
window.mode()->setEnabled(!layer->isBackground());
|
||||
LayerPropertiesWindow window(layer);
|
||||
|
||||
window.openWindowInForeground();
|
||||
|
||||
if (window.getKiller() == window.ok()) {
|
||||
std::string newName = window.name()->getText();
|
||||
BlendMode newBlendMode = (BlendMode)window.mode()->getSelectedItemIndex();
|
||||
std::string newName = window.nameValue();
|
||||
BlendMode newBlendMode = window.blendModeValue();
|
||||
|
||||
if (newName != layer->name() ||
|
||||
newBlendMode != layer->blendMode()) {
|
||||
@ -101,9 +145,10 @@ void LayerPropertiesCommand::onExecute(Context* context)
|
||||
|
||||
transaction.commit();
|
||||
}
|
||||
update_screen_for_document(writer.document());
|
||||
}
|
||||
}
|
||||
|
||||
update_screen_for_document(reader.document());
|
||||
}
|
||||
|
||||
Command* CommandFactory::createLayerPropertiesCommand()
|
||||
|
Loading…
x
Reference in New Issue
Block a user