mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-23 00:40:04 +00:00
Fix crosshair glitches on Editor when brush size popup is open
This commit is contained in:
parent
48fc0cbcb4
commit
2ccbf44a55
@ -294,10 +294,6 @@ void BrushPreview::hide()
|
||||
if (!m_onScreen)
|
||||
return;
|
||||
|
||||
app::Document* document = m_editor->document();
|
||||
Sprite* sprite = m_editor->sprite();
|
||||
ASSERT(sprite);
|
||||
|
||||
// Get drawable region
|
||||
m_editor->getDrawableRegion(m_clippingRegion, ui::Widget::kCutTopWindows);
|
||||
|
||||
@ -315,9 +311,17 @@ void BrushPreview::hide()
|
||||
|
||||
// Clean pixel/brush preview
|
||||
if (m_withRealPreview) {
|
||||
document->setExtraCel(ExtraCelRef(nullptr));
|
||||
document->notifySpritePixelsModified(
|
||||
sprite, gfx::Region(m_lastBounds), m_lastFrame);
|
||||
app::Document* document = m_editor->document();
|
||||
doc::Sprite* sprite = m_editor->sprite();
|
||||
|
||||
ASSERT(document);
|
||||
ASSERT(sprite);
|
||||
|
||||
if (document && sprite) {
|
||||
document->setExtraCel(ExtraCelRef(nullptr));
|
||||
document->notifySpritePixelsModified(
|
||||
sprite, gfx::Region(m_lastBounds), m_lastFrame);
|
||||
}
|
||||
|
||||
m_withRealPreview = false;
|
||||
}
|
||||
@ -327,6 +331,16 @@ void BrushPreview::hide()
|
||||
m_oldClippingRegion.clear();
|
||||
}
|
||||
|
||||
void BrushPreview::discardBrushPreview()
|
||||
{
|
||||
app::Document* document = m_editor->document();
|
||||
ASSERT(document);
|
||||
|
||||
if (document && m_onScreen && m_withRealPreview) {
|
||||
document->setExtraCel(ExtraCelRef(nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
void BrushPreview::redraw()
|
||||
{
|
||||
if (m_onScreen) {
|
||||
|
@ -52,6 +52,7 @@ namespace app {
|
||||
void show(const gfx::Point& screenPos);
|
||||
void hide();
|
||||
void redraw();
|
||||
void discardBrushPreview();
|
||||
|
||||
void invalidateRegion(const gfx::Region& region);
|
||||
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -1601,6 +1602,7 @@ bool Editor::onProcessMessage(Message* msg)
|
||||
break;
|
||||
|
||||
case kMouseEnterMessage:
|
||||
m_brushPreview.hide();
|
||||
updateToolLoopModifiersIndicators();
|
||||
updateQuicktool();
|
||||
break;
|
||||
@ -1772,7 +1774,18 @@ void Editor::onResize(ui::ResizeEvent& ev)
|
||||
|
||||
void Editor::onPaint(ui::PaintEvent& ev)
|
||||
{
|
||||
HideBrushPreview hide(m_brushPreview);
|
||||
std::unique_ptr<HideBrushPreview> hide;
|
||||
// If we are drawing the editor for a tooltip background or any
|
||||
// other semi-transparent widget (e.g. popups), we destroy the brush
|
||||
// preview/extra cel to avoid drawing a part of the brush in the
|
||||
// transparent widget background.
|
||||
if (ev.isTransparentBg()) {
|
||||
m_brushPreview.discardBrushPreview();
|
||||
}
|
||||
else {
|
||||
hide.reset(new HideBrushPreview(m_brushPreview));
|
||||
}
|
||||
|
||||
Graphics* g = ev.graphics();
|
||||
gfx::Rect rc = clientBounds();
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2013, 2015 David Capello
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -17,6 +17,7 @@ PaintEvent::PaintEvent(Widget* source, Graphics* graphics)
|
||||
: Event(source)
|
||||
, m_graphics(graphics)
|
||||
, m_painted(false)
|
||||
, m_transparentBg(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -32,9 +33,4 @@ Graphics* PaintEvent::graphics()
|
||||
return m_graphics;
|
||||
}
|
||||
|
||||
bool PaintEvent::isPainted() const
|
||||
{
|
||||
return m_painted;
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2013, 2015 David Capello
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -22,11 +22,17 @@ namespace ui {
|
||||
|
||||
Graphics* graphics();
|
||||
|
||||
bool isPainted() const;
|
||||
bool isPainted() const { return m_painted; }
|
||||
bool isTransparentBg() const { return m_transparentBg; }
|
||||
|
||||
void setTransparentBg(bool state) {
|
||||
m_transparentBg = state;
|
||||
}
|
||||
|
||||
private:
|
||||
Graphics* m_graphics;
|
||||
bool m_painted;
|
||||
bool m_transparentBg;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
@ -959,7 +959,9 @@ void Widget::flushRedraw()
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::paint(Graphics* graphics, const gfx::Region& drawRegion)
|
||||
void Widget::paint(Graphics* graphics,
|
||||
const gfx::Region& drawRegion,
|
||||
const bool isBg)
|
||||
{
|
||||
if (drawRegion.isEmpty())
|
||||
return;
|
||||
@ -997,12 +999,13 @@ void Widget::paint(Graphics* graphics, const gfx::Region& drawRegion)
|
||||
IntersectClip clip(&graphics2, Rect(*it).offset(
|
||||
-widget->bounds().x,
|
||||
-widget->bounds().y));
|
||||
widget->paintEvent(&graphics2);
|
||||
widget->paintEvent(&graphics2, isBg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Widget::paintEvent(Graphics* graphics)
|
||||
bool Widget::paintEvent(Graphics* graphics,
|
||||
const bool isBg)
|
||||
{
|
||||
// For transparent widgets we have to draw the parent first.
|
||||
if (isTransparent()) {
|
||||
@ -1022,13 +1025,14 @@ bool Widget::paintEvent(Graphics* graphics)
|
||||
graphics->getClipBounds().offset(
|
||||
graphics->getInternalDeltaX(),
|
||||
graphics->getInternalDeltaY())));
|
||||
parent()->paint(graphics, rgn);
|
||||
parent()->paint(graphics, rgn, true);
|
||||
}
|
||||
|
||||
disableFlags(HIDDEN);
|
||||
}
|
||||
|
||||
PaintEvent ev(this, graphics);
|
||||
ev.setTransparentBg(isBg);
|
||||
onPaint(ev); // Fire onPaint event
|
||||
return ev.isPainted();
|
||||
}
|
||||
@ -1372,7 +1376,7 @@ bool Widget::onProcessMessage(Message* msg)
|
||||
ASSERT(ptmsg->rect().h > 0);
|
||||
|
||||
GraphicsPtr graphics = getGraphics(toClient(ptmsg->rect()));
|
||||
return paintEvent(graphics.get());
|
||||
return paintEvent(graphics.get(), false);
|
||||
}
|
||||
|
||||
case kKeyDownMessage:
|
||||
|
@ -392,8 +392,11 @@ namespace ui {
|
||||
|
||||
private:
|
||||
void removeChild(WidgetsList::iterator& it);
|
||||
void paint(Graphics* graphics, const gfx::Region& drawRegion);
|
||||
bool paintEvent(Graphics* graphics);
|
||||
void paint(Graphics* graphics,
|
||||
const gfx::Region& drawRegion,
|
||||
const bool isBg);
|
||||
bool paintEvent(Graphics* graphics,
|
||||
const bool isBg);
|
||||
|
||||
WidgetType m_type; // Widget's type
|
||||
std::string m_id; // Widget's id
|
||||
|
Loading…
x
Reference in New Issue
Block a user