Update last row and column of pixels in the editor's viewport when the sprite is zoomed in and the color mode or FX dialog are used. (also fix #2803)

This commit is contained in:
Martín Capello 2021-08-13 11:11:55 -03:00
parent fc79146c56
commit 1eb740482e
5 changed files with 30 additions and 2 deletions

View File

@ -1381,6 +1381,17 @@ gfx::Point Editor::screenToEditor(const gfx::Point& pt)
m_proj.removeY(pt.y - vp.y + scroll.y - m_padding.y));
}
gfx::Point Editor::screenToEditorCeiling(const gfx::Point& pt)
{
View* view = View::getView(this);
Rect vp = view->viewportBounds();
Point scroll = view->viewScroll();
return gfx::Point(
m_proj.removeXCeiling(pt.x - vp.x + scroll.x - m_padding.x),
m_proj.removeYCeiling(pt.y - vp.y + scroll.y - m_padding.y));
}
gfx::PointF Editor::screenToEditorF(const gfx::Point& pt)
{
View* view = View::getView(this);
@ -1415,7 +1426,7 @@ Rect Editor::screenToEditor(const Rect& rc)
{
return gfx::Rect(
screenToEditor(rc.origin()),
screenToEditor(rc.point2()));
screenToEditorCeiling(rc.point2()));
}
Rect Editor::editorToScreen(const Rect& rc)

View File

@ -169,6 +169,7 @@ namespace app {
void flashCurrentLayer();
gfx::Point screenToEditor(const gfx::Point& pt);
gfx::Point screenToEditorCeiling(const gfx::Point& pt);
gfx::PointF screenToEditorF(const gfx::Point& pt);
gfx::Point editorToScreen(const gfx::Point& pt);
gfx::PointF editorToScreenF(const gfx::PointF& pt);

View File

@ -325,7 +325,7 @@ public:
gfx::Region viewportRegion;
e->getDrawableRegion(viewportRegion, Widget::kCutTopWindows);
for (auto rc : viewportRegion) {
gfx::Region subrgn(e->screenToEditor(rc).inflate(1, 1));
gfx::Region subrgn(e->screenToEditor(rc));
e->collapseRegionByTiledMode(subrgn);
allVisibleRgn |= subrgn;
}

View File

@ -49,6 +49,12 @@ namespace render {
template<typename T>
T removeY(T y) const { return m_zoom.remove<T>(y) / T(m_pixelRatio.h); }
template<typename T>
T removeXCeiling(T x) const { return T(m_zoom.removeCeiling(x)) / T(m_pixelRatio.w); }
template<typename T>
T removeYCeiling(T y) const { return T(m_zoom.removeCeiling(y)) / T(m_pixelRatio.h); }
gfx::Rect apply(const gfx::Rect& r) const {
int u = applyX(r.x);
int v = applyY(r.y);

View File

@ -32,6 +32,8 @@ namespace render {
template<typename T>
T remove(T x) const { return (x * m_den / m_num); }
int removeCeiling(int x) const;
gfx::Rect apply(const gfx::Rect& r) const;
gfx::Rect remove(const gfx::Rect& r) const;
@ -78,6 +80,14 @@ namespace render {
return (x * m_den / m_num);
}
inline int Zoom::removeCeiling(int x) const {
int v = x * m_den;
if (x < 0)
return (v / m_num);
else
return (v / m_num) + (v % m_num != 0);
}
inline gfx::Rect Zoom::apply(const gfx::Rect& r) const {
return gfx::Rect(
apply(r.x), apply(r.y),