Skip to content

Commit

Permalink
Rename Editor::m_cursorThick -> m_cursorOnScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed May 18, 2015
1 parent 41ed14f commit 6c882e4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
24 changes: 11 additions & 13 deletions src/app/ui/editor/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void Editor::set_cursor_color(const app::Color& color)
//////////////////////////////////////////////////////////////////////

static gfx::Rect lastBrushBounds;
static int brush_size_thick = 0;
static bool brush_on_screen = false;

static void on_palette_change_update_cursor_color()
{
Expand All @@ -127,8 +127,8 @@ static void on_palette_change_update_cursor_color()
static void on_brush_before_change()
{
if (current_editor) {
brush_size_thick = current_editor->cursorThick();
if (brush_size_thick)
brush_on_screen = current_editor->cursorOnScreen();
if (brush_on_screen)
current_editor->hideDrawingCursor();
}
}
Expand All @@ -137,7 +137,7 @@ static void on_brush_after_change()
{
if (current_editor) {
// Show drawing cursor
if (current_editor->sprite() && brush_size_thick > 0)
if (current_editor->sprite() && brush_on_screen)
current_editor->showDrawingCursor();
}
}
Expand Down Expand Up @@ -167,7 +167,7 @@ void Editor::editor_cursor_exit()
{
set_config_color("Tools", "CursorColor", cursor_color);

if (cursor_bound.seg != NULL)
if (cursor_bound.seg)
base_free(cursor_bound.seg);
}

Expand All @@ -178,8 +178,8 @@ void Editor::editor_cursor_exit()
// Note: x and y params are absolute positions of the mouse.
void Editor::drawBrushPreview(const gfx::Point& pos, bool refresh)
{
ASSERT(m_cursorThick == 0);
ASSERT(m_sprite != NULL);
ASSERT(!m_cursorOnScreen);
ASSERT(m_sprite);

// Get drawable region
getDrawableRegion(clipping_region, kCutTopWindows);
Expand Down Expand Up @@ -286,10 +286,8 @@ void Editor::drawBrushPreview(const gfx::Point& pos, bool refresh)
forEachBrushPixel(&g, m_cursorScreen, spritePos, ui_cursor_color, drawpixel);
}

// Cursor thickness
m_cursorThick = 1;

// Cursor in the editor (model)
m_cursorOnScreen = true;
m_cursorEditor = spritePos;

// Save the clipping-region to know where to clean the pixels
Expand Down Expand Up @@ -350,8 +348,8 @@ void Editor::moveBrushPreview(const gfx::Point& pos, bool refresh)
*/
void Editor::clearBrushPreview(bool refresh)
{
ASSERT(m_cursorThick != 0);
ASSERT(m_sprite != NULL);
ASSERT(m_cursorOnScreen);
ASSERT(m_sprite);

getDrawableRegion(clipping_region, kCutTopWindows);

Expand All @@ -374,7 +372,7 @@ void Editor::clearBrushPreview(bool refresh)
}
}

m_cursorThick = 0;
m_cursorOnScreen = false;

clipping_region.clear();
old_clipping_region.clear();
Expand Down
28 changes: 14 additions & 14 deletions src/app/ui/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Editor::Editor(Document* document, EditorFlags flags)
, m_layer(m_sprite->folder()->getFirstLayer())
, m_frame(frame_t(0))
, m_zoom(1, 1)
, m_cursorThick(0)
, m_cursorOnScreen(false)
, m_cursorScreen(0, 0)
, m_cursorEditor(0, 0)
, m_quicktool(NULL)
Expand Down Expand Up @@ -325,9 +325,9 @@ void Editor::setEditorScroll(const gfx::Point& scroll, bool blit_valid_rgn)
View* view = View::getView(this);
Point oldScroll;
Region region;
int thick = m_cursorThick;
bool onScreen = m_cursorOnScreen;

if (thick)
if (onScreen)
clearBrushPreview();

if (blit_valid_rgn) {
Expand All @@ -343,7 +343,7 @@ void Editor::setEditorScroll(const gfx::Point& scroll, bool blit_valid_rgn)
scrollRegion(region, oldScroll - newScroll);
}

if (thick)
if (onScreen)
drawBrushPreview(m_cursorScreen);
}

Expand Down Expand Up @@ -687,13 +687,13 @@ void Editor::drawMaskSafe()
if (isVisible() &&
m_document &&
m_document->getBoundariesSegments()) {
int thick = m_cursorThick;
bool onScreen = m_cursorOnScreen;

Region region;
getDrawableRegion(region, kCutTopWindows);
region.offset(-getBounds().getOrigin());

if (thick)
if (onScreen)
clearBrushPreview();
else
ui::hide_mouse_cursor();
Expand All @@ -707,7 +707,7 @@ void Editor::drawMaskSafe()
}

// Draw the cursor
if (thick)
if (onScreen)
drawBrushPreview(m_cursorScreen);
else
ui::show_mouse_cursor();
Expand Down Expand Up @@ -1006,7 +1006,7 @@ void Editor::showDrawingCursor()
{
ASSERT(m_sprite != NULL);

if (!m_cursorThick && canDraw()) {
if (!m_cursorOnScreen && canDraw()) {
ui::hide_mouse_cursor();
drawBrushPreview(ui::get_mouse_position());
ui::show_mouse_cursor();
Expand All @@ -1015,7 +1015,7 @@ void Editor::showDrawingCursor()

void Editor::hideDrawingCursor()
{
if (m_cursorThick) {
if (m_cursorOnScreen) {
ui::hide_mouse_cursor();
clearBrushPreview();
ui::show_mouse_cursor();
Expand All @@ -1025,7 +1025,7 @@ void Editor::hideDrawingCursor()
void Editor::moveDrawingCursor()
{
// Draw cursor
if (m_cursorThick) {
if (m_cursorOnScreen) {
gfx::Point mousePos = ui::get_mouse_position();

// Redraw it only when the mouse change to other pixel (not
Expand Down Expand Up @@ -1353,8 +1353,8 @@ void Editor::onPaint(ui::PaintEvent& ev)
gfx::Rect rc = getClientBounds();
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());

int old_cursor_thick = m_cursorThick;
if (m_cursorThick)
bool onScreen = m_cursorOnScreen;
if (onScreen)
clearBrushPreview();

// Editor without sprite
Expand All @@ -1380,7 +1380,7 @@ void Editor::onPaint(ui::PaintEvent& ev)
}

// Draw the cursor again
if (old_cursor_thick != 0) {
if (onScreen) {
drawBrushPreview(ui::get_mouse_position());
}
}
Expand All @@ -1401,7 +1401,7 @@ void Editor::onCurrentToolChange()

void Editor::onFgColorChange()
{
if (m_cursorThick) {
if (m_cursorOnScreen) {
hideDrawingCursor();
showDrawingCursor();
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/ui/editor/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace app {
const render::Zoom& zoom() const { return m_zoom; }
int offsetX() const { return m_offset_x; }
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 setOffsetX(int x) { m_offset_x = x; }
Expand Down Expand Up @@ -269,7 +269,7 @@ namespace app {
render::Zoom m_zoom; // Zoom in the editor

// Drawing cursor
int m_cursorThick;
bool m_cursorOnScreen;
gfx::Point m_cursorScreen; // Position in the screen (view)
gfx::Point m_cursorEditor; // Position in the editor (model)

Expand Down

0 comments on commit 6c882e4

Please sign in to comment.