Merge branch 'main' into beta

This commit is contained in:
David Capello 2024-10-23 23:10:45 -03:00
commit aed7c6a3b1
4 changed files with 45 additions and 22 deletions

View File

@ -51,6 +51,26 @@ public:
m_proc->prepareUForPointShapeSlicedScanline(loop, leftSlice, x1);
}
// Common to both SelectionInk and SliceInk
gfx::Rect tileSelectionToCanvas(int x1, int y, int x2, ToolLoop* loop, bool offset) {
gfx::Rect rc(x1, y, x2-x1+1, 1);
// For tile point shape, the point shape is done in "tiles"
// coordinates, but we want the selection in canvas/pixels
// coordinates.
if (loop->getPointShape()->isTile()) {
const Grid& grid = loop->getGrid();
rc = grid.tileToCanvas(rc);
if (offset) {
// For feedback purposes, the coordinates must be relative to
// the getDstImage() and not in absolute sprite canvas
// coordinates.
rc.offset(-grid.origin());
}
}
return rc;
}
protected:
void setProc(BaseInkProcessing* proc) {
m_proc.reset(proc);
@ -293,10 +313,17 @@ public:
}
void inkHline(int x1, int y, int x2, ToolLoop* loop) override {
// Map tile coords to canvas if needed
gfx::Rect rc(BaseInk::tileSelectionToCanvas(
x1, y, x2, loop, !m_createSlice));
if (m_createSlice)
m_maxBounds |= gfx::Rect(x1, y, x2-x1+1, 1);
else
BaseInk::inkHline(x1, y, x2, loop);
m_maxBounds |= rc;
else {
rc &= loop->getDstImage()->bounds();
for (int v=rc.y; v<rc.y2(); ++v)
BaseInk::inkHline(rc.x, v, rc.x2()-1, loop);
}
}
void setFinalStep(ToolLoop* loop, bool state) override {
@ -305,6 +332,7 @@ public:
m_maxBounds = gfx::Rect(0, 0, 0, 0);
}
else {
m_maxBounds &= loop->getDstImage()->bounds();
loop->onSliceRect(m_maxBounds);
}
}
@ -448,21 +476,9 @@ public:
}
void inkHline(int x1, int y, int x2, ToolLoop* loop) override {
gfx::Rect rc(x1, y, x2-x1+1, 1);
// For tile point shape, the point shape is done in "tiles"
// coordinates, but we want the selection in canvas/pixels
// coordinates.
if (loop->getPointShape()->isTile()) {
const Grid& grid = loop->getGrid();
rc = grid.tileToCanvas(rc);
if (!m_modify_selection) {
// For feedback purposes, the coordinates must be relative to
// the getDstImage() and not in absolute sprite canvas
// coordinates.
rc.offset(-grid.origin());
}
}
// Map tile coords to canvas if needed
gfx::Rect rc(BaseInk::tileSelectionToCanvas(
x1, y, x2, loop, !m_modify_selection));
if (m_modify_selection) {
int modifiers = int(loop->getModifiers());

View File

@ -226,7 +226,7 @@ public:
// tilemap layer to preview the selection, or 2) using a
// path to show the selection (so there is no preview layer
// at all and nor ExpandCelCanvas)
if (m_ink->isSelection())
if (m_ink->isSelection() || m_ink->isSlice())
site.tilemapMode(TilemapMode::Pixels);
}
@ -529,7 +529,7 @@ public:
ExpandCelCanvas::NeedsSource |
(m_layer->isTilemap() &&
(!m_tilesMode ||
m_ink->isSelection()) ? ExpandCelCanvas::PixelsBounds:
isSelectionPreview) ? ExpandCelCanvas::PixelsBounds:
ExpandCelCanvas::None) |
(m_layer->isTilemap() &&
site.tilemapMode() == TilemapMode::Pixels &&
@ -762,7 +762,8 @@ static void adjust_ink_for_tilemaps(const Site& site,
ToolLoopParams& params)
{
if (!params.ink->isSelection() &&
!params.ink->isEraser()) {
!params.ink->isEraser() &&
!params.ink->isSlice()) {
params.ink = App::instance()->toolBox()->getInkById(tools::WellKnownInks::PaintCopy);
}
}

View File

@ -498,6 +498,7 @@ void Manager::generateMessagesFromOSEvents()
set_mouse_cursor(kArrowCursor);
mouse_display = display;
});
msg->setRecipient(this);
enqueueMessage(msg);
lastMouseMoveEvent = osEvent;
break;
@ -513,7 +514,7 @@ void Manager::generateMessagesFromOSEvents()
mouse_display = nullptr;
}
});
msg->setRecipient(this);
enqueueMessage(msg);
// To avoid calling kSetCursorMessage when the mouse leaves

View File

@ -1629,6 +1629,11 @@ bool Widget::onProcessMessage(Message* msg)
return true;
}
break;
case kCallbackMessage: {
CallbackMessage* callback = static_cast<CallbackMessage*>(msg);
callback->call();
return true;
}
}