From 8720d156e516880dfbc0eabc2c129a19d479e97b Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 30 Mar 2010 23:40:01 -0300 Subject: [PATCH] Added Editor::flashCurrentLayer() for when the current layer is changed. --- src/commands/cmd_goto_layer.cpp | 10 ++++++---- src/modules/gui.cpp | 5 +++++ src/modules/gui.h | 1 + src/widgets/editor.h | 2 ++ src/widgets/editor/editor.cpp | 32 ++++++++++++++++++++++++++++++++ src/widgets/statebar.cpp | 25 +++++++++++++++++-------- 6 files changed, 63 insertions(+), 12 deletions(-) diff --git a/src/commands/cmd_goto_layer.cpp b/src/commands/cmd_goto_layer.cpp index 25bcd0c39..5390d29c6 100644 --- a/src/commands/cmd_goto_layer.cpp +++ b/src/commands/cmd_goto_layer.cpp @@ -68,8 +68,9 @@ void GotoPreviousLayerCommand::execute(Context* context) sprite->setCurrentLayer(sprite->indexToLayer(i)); - update_screen_for_sprite(sprite); - current_editor->editor_update_statusbar_for_standby(); + // Flash the current layer + assert(current_editor != NULL); // Cannot be null when we have a current sprite + current_editor->flashCurrentLayer(); app_get_statusbar() ->showTip(1000, _("Layer `%s' selected"), @@ -116,8 +117,9 @@ void GotoNextLayerCommand::execute(Context* context) sprite->setCurrentLayer(sprite->indexToLayer(i)); - update_screen_for_sprite(sprite); - current_editor->editor_update_statusbar_for_standby(); + // Flash the current layer + assert(current_editor != NULL); // Cannot be null when we have a current sprite + current_editor->flashCurrentLayer(); app_get_statusbar() ->showTip(1000, _("Layer `%s' selected"), diff --git a/src/modules/gui.cpp b/src/modules/gui.cpp index bf913a4c9..b4ad54cfd 100644 --- a/src/modules/gui.cpp +++ b/src/modules/gui.cpp @@ -509,6 +509,11 @@ void gui_feedback() /* record file if is necessary */ rec_screen_poll(); + gui_flip_screen(); +} + +void gui_flip_screen() +{ /* double buffering? */ if (double_buffering && ji_screen) { jmouse_draw_cursor(); diff --git a/src/modules/gui.h b/src/modules/gui.h index 99021c622..a580ec0e2 100644 --- a/src/modules/gui.h +++ b/src/modules/gui.h @@ -71,6 +71,7 @@ void update_screen_for_sprite(const Sprite* sprite); void gui_run(); void gui_feedback(); +void gui_flip_screen(); void gui_setup_screen(bool reload_font); void load_window_pos(Widget* window, const char *section); diff --git a/src/widgets/editor.h b/src/widgets/editor.h index 4162768ef..09e5377d0 100644 --- a/src/widgets/editor.h +++ b/src/widgets/editor.h @@ -135,6 +135,8 @@ public: void editor_draw_mask(); void editor_draw_mask_safe(); + void flashCurrentLayer(); + void screen_to_editor(int xin, int yin, int *xout, int *yout); void editor_to_screen(int xin, int yin, int *xout, int *yout); diff --git a/src/widgets/editor/editor.cpp b/src/widgets/editor/editor.cpp index fde3590b6..47baf6ce6 100644 --- a/src/widgets/editor/editor.cpp +++ b/src/widgets/editor/editor.cpp @@ -532,6 +532,38 @@ void Editor::drawGrid() jrect_free(vp); } +void Editor::flashCurrentLayer() +{ + int x, y; + const Image* src_image = m_sprite->getCurrentImage(&x, &y); + if (src_image) { + m_sprite->prepareExtra(); + Image* flash_image = m_sprite->getExtras(); + int u, v; + + image_clear(flash_image, flash_image->mask_color); + for (v=0; vh; ++v) { + for (u=0; uw; ++u) { + if (u-x >= 0 && u-x < src_image->w && + v-y >= 0 && v-y < src_image->h) { + ase_uint32 color = image_getpixel(src_image, u-x, v-y); + if (color != src_image->mask_color) { + color_t ccc = color_rgb(255, 255, 255); + image_putpixel(flash_image, u, v, + get_color_for_image(flash_image->imgtype, ccc)); + } + } + } + } + + editor_draw_sprite(0, 0, m_sprite->getWidth()-1, m_sprite->getHeight()-1); + gui_flip_screen(); + + image_clear(flash_image, flash_image->mask_color); + editor_draw_sprite(0, 0, m_sprite->getWidth()-1, m_sprite->getHeight()-1); + } +} + void Editor::turnOnSelectionModifiers() { // TODO deleteDecorators() diff --git a/src/widgets/statebar.cpp b/src/widgets/statebar.cpp index 4bd880cba..cd52a0a68 100644 --- a/src/widgets/statebar.cpp +++ b/src/widgets/statebar.cpp @@ -19,9 +19,10 @@ #include "config.h" #include -#include -#include -#include +#include +#include +#include +#include #include "Vaca/Bind.h" #include "jinete/jinete.h" @@ -479,17 +480,25 @@ bool StatusBar::msg_proc(JMessage msg) } break; } - + case JM_BUTTONPRESSED: + // When the user press the mouse-button over a hot-layer-button... if (m_hot_layer >= 0) { try { CurrentSpriteWriter sprite(UIContext::instance()); if (sprite) { Layer* layer = sprite->indexToLayer(m_hot_layer); - if (layer && layer != sprite->getCurrentLayer()) { - sprite->setCurrentLayer(layer); - update_screen_for_sprite(sprite); - dirty(); // Redraw the status-bar + if (layer) { + // Set the current layer + if (layer != sprite->getCurrentLayer()) + sprite->setCurrentLayer(layer); + + // Flash the current layer + assert(current_editor != NULL); // Cannot be null when we have a current sprite + current_editor->flashCurrentLayer(); + + // Redraw the status-bar + dirty(); } } }