Rename Editor::m_cursorThick -> m_cursorOnScreen

This commit is contained in:
David Capello 2015-05-18 15:00:59 -03:00
parent 41ed14f036
commit 6c882e43d5
3 changed files with 27 additions and 29 deletions

View File

@ -117,7 +117,7 @@ void Editor::set_cursor_color(const app::Color& color)
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
static gfx::Rect lastBrushBounds; static gfx::Rect lastBrushBounds;
static int brush_size_thick = 0; static bool brush_on_screen = false;
static void on_palette_change_update_cursor_color() static void on_palette_change_update_cursor_color()
{ {
@ -127,8 +127,8 @@ static void on_palette_change_update_cursor_color()
static void on_brush_before_change() static void on_brush_before_change()
{ {
if (current_editor) { if (current_editor) {
brush_size_thick = current_editor->cursorThick(); brush_on_screen = current_editor->cursorOnScreen();
if (brush_size_thick) if (brush_on_screen)
current_editor->hideDrawingCursor(); current_editor->hideDrawingCursor();
} }
} }
@ -137,7 +137,7 @@ static void on_brush_after_change()
{ {
if (current_editor) { if (current_editor) {
// Show drawing cursor // Show drawing cursor
if (current_editor->sprite() && brush_size_thick > 0) if (current_editor->sprite() && brush_on_screen)
current_editor->showDrawingCursor(); current_editor->showDrawingCursor();
} }
} }
@ -167,7 +167,7 @@ void Editor::editor_cursor_exit()
{ {
set_config_color("Tools", "CursorColor", cursor_color); set_config_color("Tools", "CursorColor", cursor_color);
if (cursor_bound.seg != NULL) if (cursor_bound.seg)
base_free(cursor_bound.seg); base_free(cursor_bound.seg);
} }
@ -178,8 +178,8 @@ void Editor::editor_cursor_exit()
// Note: x and y params are absolute positions of the mouse. // Note: x and y params are absolute positions of the mouse.
void Editor::drawBrushPreview(const gfx::Point& pos, bool refresh) void Editor::drawBrushPreview(const gfx::Point& pos, bool refresh)
{ {
ASSERT(m_cursorThick == 0); ASSERT(!m_cursorOnScreen);
ASSERT(m_sprite != NULL); ASSERT(m_sprite);
// Get drawable region // Get drawable region
getDrawableRegion(clipping_region, kCutTopWindows); getDrawableRegion(clipping_region, kCutTopWindows);
@ -286,10 +286,8 @@ void Editor::drawBrushPreview(const gfx::Point& pos, bool refresh)
forEachBrushPixel(&g, m_cursorScreen, spritePos, ui_cursor_color, drawpixel); forEachBrushPixel(&g, m_cursorScreen, spritePos, ui_cursor_color, drawpixel);
} }
// Cursor thickness
m_cursorThick = 1;
// Cursor in the editor (model) // Cursor in the editor (model)
m_cursorOnScreen = true;
m_cursorEditor = spritePos; m_cursorEditor = spritePos;
// Save the clipping-region to know where to clean the pixels // Save the clipping-region to know where to clean the pixels
@ -350,8 +348,8 @@ void Editor::moveBrushPreview(const gfx::Point& pos, bool refresh)
*/ */
void Editor::clearBrushPreview(bool refresh) void Editor::clearBrushPreview(bool refresh)
{ {
ASSERT(m_cursorThick != 0); ASSERT(m_cursorOnScreen);
ASSERT(m_sprite != NULL); ASSERT(m_sprite);
getDrawableRegion(clipping_region, kCutTopWindows); getDrawableRegion(clipping_region, kCutTopWindows);
@ -374,7 +372,7 @@ void Editor::clearBrushPreview(bool refresh)
} }
} }
m_cursorThick = 0; m_cursorOnScreen = false;
clipping_region.clear(); clipping_region.clear();
old_clipping_region.clear(); old_clipping_region.clear();

View File

@ -152,7 +152,7 @@ Editor::Editor(Document* document, EditorFlags flags)
, m_layer(m_sprite->folder()->getFirstLayer()) , m_layer(m_sprite->folder()->getFirstLayer())
, m_frame(frame_t(0)) , m_frame(frame_t(0))
, m_zoom(1, 1) , m_zoom(1, 1)
, m_cursorThick(0) , m_cursorOnScreen(false)
, m_cursorScreen(0, 0) , m_cursorScreen(0, 0)
, m_cursorEditor(0, 0) , m_cursorEditor(0, 0)
, m_quicktool(NULL) , m_quicktool(NULL)
@ -325,9 +325,9 @@ void Editor::setEditorScroll(const gfx::Point& scroll, bool blit_valid_rgn)
View* view = View::getView(this); View* view = View::getView(this);
Point oldScroll; Point oldScroll;
Region region; Region region;
int thick = m_cursorThick; bool onScreen = m_cursorOnScreen;
if (thick) if (onScreen)
clearBrushPreview(); clearBrushPreview();
if (blit_valid_rgn) { if (blit_valid_rgn) {
@ -343,7 +343,7 @@ void Editor::setEditorScroll(const gfx::Point& scroll, bool blit_valid_rgn)
scrollRegion(region, oldScroll - newScroll); scrollRegion(region, oldScroll - newScroll);
} }
if (thick) if (onScreen)
drawBrushPreview(m_cursorScreen); drawBrushPreview(m_cursorScreen);
} }
@ -687,13 +687,13 @@ void Editor::drawMaskSafe()
if (isVisible() && if (isVisible() &&
m_document && m_document &&
m_document->getBoundariesSegments()) { m_document->getBoundariesSegments()) {
int thick = m_cursorThick; bool onScreen = m_cursorOnScreen;
Region region; Region region;
getDrawableRegion(region, kCutTopWindows); getDrawableRegion(region, kCutTopWindows);
region.offset(-getBounds().getOrigin()); region.offset(-getBounds().getOrigin());
if (thick) if (onScreen)
clearBrushPreview(); clearBrushPreview();
else else
ui::hide_mouse_cursor(); ui::hide_mouse_cursor();
@ -707,7 +707,7 @@ void Editor::drawMaskSafe()
} }
// Draw the cursor // Draw the cursor
if (thick) if (onScreen)
drawBrushPreview(m_cursorScreen); drawBrushPreview(m_cursorScreen);
else else
ui::show_mouse_cursor(); ui::show_mouse_cursor();
@ -1006,7 +1006,7 @@ void Editor::showDrawingCursor()
{ {
ASSERT(m_sprite != NULL); ASSERT(m_sprite != NULL);
if (!m_cursorThick && canDraw()) { if (!m_cursorOnScreen && canDraw()) {
ui::hide_mouse_cursor(); ui::hide_mouse_cursor();
drawBrushPreview(ui::get_mouse_position()); drawBrushPreview(ui::get_mouse_position());
ui::show_mouse_cursor(); ui::show_mouse_cursor();
@ -1015,7 +1015,7 @@ void Editor::showDrawingCursor()
void Editor::hideDrawingCursor() void Editor::hideDrawingCursor()
{ {
if (m_cursorThick) { if (m_cursorOnScreen) {
ui::hide_mouse_cursor(); ui::hide_mouse_cursor();
clearBrushPreview(); clearBrushPreview();
ui::show_mouse_cursor(); ui::show_mouse_cursor();
@ -1025,7 +1025,7 @@ void Editor::hideDrawingCursor()
void Editor::moveDrawingCursor() void Editor::moveDrawingCursor()
{ {
// Draw cursor // Draw cursor
if (m_cursorThick) { if (m_cursorOnScreen) {
gfx::Point mousePos = ui::get_mouse_position(); gfx::Point mousePos = ui::get_mouse_position();
// Redraw it only when the mouse change to other pixel (not // Redraw it only when the mouse change to other pixel (not
@ -1353,8 +1353,8 @@ void Editor::onPaint(ui::PaintEvent& ev)
gfx::Rect rc = getClientBounds(); gfx::Rect rc = getClientBounds();
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme()); SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
int old_cursor_thick = m_cursorThick; bool onScreen = m_cursorOnScreen;
if (m_cursorThick) if (onScreen)
clearBrushPreview(); clearBrushPreview();
// Editor without sprite // Editor without sprite
@ -1380,7 +1380,7 @@ void Editor::onPaint(ui::PaintEvent& ev)
} }
// Draw the cursor again // Draw the cursor again
if (old_cursor_thick != 0) { if (onScreen) {
drawBrushPreview(ui::get_mouse_position()); drawBrushPreview(ui::get_mouse_position());
} }
} }
@ -1401,7 +1401,7 @@ void Editor::onCurrentToolChange()
void Editor::onFgColorChange() void Editor::onFgColorChange()
{ {
if (m_cursorThick) { if (m_cursorOnScreen) {
hideDrawingCursor(); hideDrawingCursor();
showDrawingCursor(); showDrawingCursor();
} }

View File

@ -116,7 +116,7 @@ namespace app {
const render::Zoom& zoom() const { return m_zoom; } const render::Zoom& zoom() const { return m_zoom; }
int offsetX() const { return m_offset_x; } int offsetX() const { return m_offset_x; }
int offsetY() const { return m_offset_y; } int offsetY() const { return m_offset_y; }
int cursorThick() { return m_cursorThick; } bool cursorOnScreen() const { return m_cursorOnScreen; }
void setZoom(render::Zoom zoom) { m_zoom = zoom; } void setZoom(render::Zoom zoom) { m_zoom = zoom; }
void setOffsetX(int x) { m_offset_x = x; } void setOffsetX(int x) { m_offset_x = x; }
@ -269,7 +269,7 @@ namespace app {
render::Zoom m_zoom; // Zoom in the editor render::Zoom m_zoom; // Zoom in the editor
// Drawing cursor // Drawing cursor
int m_cursorThick; bool m_cursorOnScreen;
gfx::Point m_cursorScreen; // Position in the screen (view) gfx::Point m_cursorScreen; // Position in the screen (view)
gfx::Point m_cursorEditor; // Position in the editor (model) gfx::Point m_cursorEditor; // Position in the editor (model)