mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-27 06:35:16 +00:00
Add experimental option to flash the selected layer when Up/down array keys are used (fix #111)
This commit is contained in:
parent
bfe7a637da
commit
d68f1fa1b8
@ -87,6 +87,7 @@
|
||||
<vbox id="section_experimental">
|
||||
<separator text="User Interface" horizontal="true" />
|
||||
<check id="native_cursor" text="Use native mouse cursor" />
|
||||
<check id="flash_layer" text="Flash layer when it is selected" />
|
||||
</vbox>
|
||||
|
||||
</panel>
|
||||
|
@ -81,6 +81,9 @@ public:
|
||||
if (m_settings->experimental()->useNativeCursor())
|
||||
nativeCursor()->setSelected(true);
|
||||
|
||||
if (m_settings->experimental()->flashLayer())
|
||||
flashLayer()->setSelected(true);
|
||||
|
||||
if (m_settings->getShowSpriteEditorScrollbars())
|
||||
showScrollbars()->setSelected(true);
|
||||
|
||||
@ -167,8 +170,9 @@ public:
|
||||
m_settings->setUndoSizeLimit(undo_size_limit_value);
|
||||
m_settings->setUndoGotoModified(undoGotoModified()->isSelected());
|
||||
|
||||
// Native cursor
|
||||
// Experimental features
|
||||
m_settings->experimental()->setUseNativeCursor(nativeCursor()->isSelected());
|
||||
m_settings->experimental()->setFlashLayer(flashLayer()->isSelected());
|
||||
|
||||
int new_screen_scaling = screenScale()->getSelectedItemIndex()+1;
|
||||
if (new_screen_scaling != get_screen_scaling()) {
|
||||
|
@ -176,8 +176,12 @@ namespace app {
|
||||
class IExperimentalSettings {
|
||||
public:
|
||||
virtual ~IExperimentalSettings() { }
|
||||
|
||||
virtual bool useNativeCursor() const = 0;
|
||||
virtual void setUseNativeCursor(bool state) = 0;
|
||||
|
||||
virtual bool flashLayer() const = 0;
|
||||
virtual void setFlashLayer(bool state) = 0;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
@ -513,6 +513,16 @@ void UISettingsImpl::setUseNativeCursor(bool state)
|
||||
ui::set_use_native_cursors(state);
|
||||
}
|
||||
|
||||
bool UISettingsImpl::flashLayer() const
|
||||
{
|
||||
return get_config_bool("Options", "FlashLayer", false);
|
||||
}
|
||||
|
||||
void UISettingsImpl::setFlashLayer(bool state)
|
||||
{
|
||||
set_config_bool("Options", "FlashLayer", state);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// IDocumentSettings implementation
|
||||
|
||||
|
@ -83,6 +83,9 @@ namespace app {
|
||||
bool useNativeCursor() const override;
|
||||
void setUseNativeCursor(bool state) override;
|
||||
|
||||
bool flashLayer() const override;
|
||||
void setFlashLayer(bool state) override;
|
||||
|
||||
// IColorSwatchesStore implementation
|
||||
|
||||
void addColorSwatches(app::ColorSwatches* colorSwatches) override;
|
||||
|
@ -674,39 +674,29 @@ void Editor::drawGrid(Graphics* g, const gfx::Rect& spriteBounds, const Rect& gr
|
||||
|
||||
void Editor::flashCurrentLayer()
|
||||
{
|
||||
#if 0 // TODO this flash effect can be done
|
||||
// only with hardware acceleration.
|
||||
// Finish it when the
|
||||
// Allegro 5 port is ready.
|
||||
if (!UIContext::instance()->settings()->experimental()->flashLayer())
|
||||
return;
|
||||
|
||||
DocumentLocation loc = getDocumentLocation();
|
||||
|
||||
int x, y;
|
||||
const Image* src_image = m_sprite->getCurrentImage(&x, &y);
|
||||
const Image* src_image = loc.image(&x, &y);
|
||||
if (src_image) {
|
||||
m_document->prepareExtraCel(0, 0, m_sprite->width(), m_sprite->height(), 255);
|
||||
Image* flash_image = m_document->getExtraCelImage();
|
||||
int u, v;
|
||||
|
||||
clear_image(flash_image, flash_image->mask_color);
|
||||
for (v=0; v<flash_image->height(); ++v) {
|
||||
for (u=0; u<flash_image->width(); ++u) {
|
||||
if (u-x >= 0 && u-x < src_image->width() &&
|
||||
v-y >= 0 && v-y < src_image->height()) {
|
||||
uint32_t color = get_pixel(src_image, u-x, v-y);
|
||||
if (color != src_image->mask_color) {
|
||||
Color ccc = Color::fromRgb(255, 255, 255);
|
||||
put_pixel(flash_image, u, v,
|
||||
color_utils::color_for_image(ccc, flash_image->imgtype));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
clear_image(flash_image, flash_image->maskColor());
|
||||
copy_image(flash_image, src_image, x, y);
|
||||
m_document->setExtraCelBlendMode(BLEND_MODE_BLACKANDWHITE);
|
||||
|
||||
drawSpriteSafe(0, 0, m_sprite->width()-1, m_sprite->height()-1);
|
||||
gui_flip_screen();
|
||||
drawSpriteClipped(gfx::Region(
|
||||
gfx::Rect(0, 0, m_sprite->width(), m_sprite->height())));
|
||||
gui_feedback();
|
||||
|
||||
clear_image(flash_image, flash_image->mask_color);
|
||||
drawSpriteSafe(0, 0, m_sprite->width()-1, m_sprite->height()-1);
|
||||
m_document->setExtraCelBlendMode(BLEND_MODE_NORMAL);
|
||||
m_document->destroyExtraCel();
|
||||
invalidate();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
gfx::Point Editor::autoScroll(MouseMessage* msg, AutoScroll dir, bool blit_valid_rgn)
|
||||
|
Loading…
x
Reference in New Issue
Block a user