From 91b6233b484362a0633b9b86249c04630f2d7229 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 24 Jun 2010 23:25:30 -0300 Subject: [PATCH] Now the user can select mask color as foreground or background colors (e.g. now you can erase with right button using brush tool). --- src/commands/cmd_eyedropper.cpp | 14 ++++++-------- src/modules/gfx.cpp | 6 +++++- src/widgets/editor/cursor.cpp | 12 ++++++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/commands/cmd_eyedropper.cpp b/src/commands/cmd_eyedropper.cpp index af159341d..76bd4ea28 100644 --- a/src/commands/cmd_eyedropper.cpp +++ b/src/commands/cmd_eyedropper.cpp @@ -84,15 +84,13 @@ void EyedropperCommand::execute(Context* context) color_t color = color_from_image(sprite->getImgType(), sprite->getPixel(x, y)); - if (color_type(color) != COLOR_TYPE_MASK) { - // TODO replace the color in the "context", not directly from the color-bar + // TODO replace the color in the "context", not directly from the color-bar - // set the color of the color-bar - if (m_background) - app_get_colorbar()->setBgColor(color); - else - app_get_colorbar()->setFgColor(color); - } + // set the color of the color-bar + if (m_background) + app_get_colorbar()->setBgColor(color); + else + app_get_colorbar()->setFgColor(color); } ////////////////////////////////////////////////////////////////////// diff --git a/src/modules/gfx.cpp b/src/modules/gfx.cpp index 0d58986cd..facb16a0f 100644 --- a/src/modules/gfx.cpp +++ b/src/modules/gfx.cpp @@ -430,7 +430,11 @@ void draw_color(BITMAP* bmp, const Rect& rc, int imgtype, color_t color) int data; BITMAP* graph; - if (type == COLOR_TYPE_INDEX) { + if (type == COLOR_TYPE_MASK) { + rectgrid(bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, rc.w/4, rc.h/2); + return; + } + else if (type == COLOR_TYPE_INDEX) { int index = color_get_index(color); if (index >= 0 && index < get_current_palette()->size()) { diff --git a/src/widgets/editor/cursor.cpp b/src/widgets/editor/cursor.cpp index 54c5dc531..78181c8c4 100644 --- a/src/widgets/editor/cursor.cpp +++ b/src/widgets/editor/cursor.cpp @@ -33,6 +33,7 @@ #include "core/color.h" #include "modules/editors.h" #include "raster/image.h" +#include "raster/layer.h" #include "raster/pen.h" #include "raster/sprite.h" #include "tools/tool.h" @@ -230,6 +231,7 @@ void Editor::editor_cursor_exit() void Editor::editor_draw_cursor(int x, int y, bool refresh) { assert(m_cursor_thick == 0); + assert(m_sprite != NULL); /* get drawable region */ clipping_region = jwidget_get_drawable_region(this, JI_GDR_CUTTOPWINDOWS); @@ -254,11 +256,17 @@ void Editor::editor_draw_cursor(int x, int y, bool refresh) if (current_tool->getInk(0)->isSelection()) { cursor_type = CURSOR_CROSS_ONE; } - else if (current_tool->getInk(0)->isEffect()) { + else if (// Use cursor bounds for inks that are effects (eraser, blur, etc.) + current_tool->getInk(0)->isEffect() || + // or when the FG color is mask and we are not in the background layer + (color_type(UIContext::instance()->getSettings()->getFgColor()) == COLOR_TYPE_MASK && + (m_sprite->getCurrentLayer() != NULL && + !m_sprite->getCurrentLayer()->is_background()))) { cursor_type = CURSOR_BOUNDS; } - else + else { cursor_type = CURSOR_PENCIL; + } // For cursor type 'bounds' we have to generate cursor boundaries if (cursor_type & CURSOR_BOUNDS)