Compare commits

...

4 Commits

Author SHA1 Message Date
دانتي باولا 7e65915c5a
Merge 27f19959bd into de1ccb24dd 2025-07-25 14:30:26 +02:00
David Capello de1ccb24dd [win] Don't drop text when IME dialog composition is accepted w/Enter
build / build (Debug, macos-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, macos-latest, noscripts, cli) (push) Waiting to run Details
build / build (Debug, ubuntu-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, ubuntu-latest, noscripts, cli) (push) Waiting to run Details
build / build (Debug, windows-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, windows-latest, noscripts, cli) (push) Waiting to run Details
build / build (RelWithDebInfo, macos-latest, lua, gui) (push) Waiting to run Details
build / build (RelWithDebInfo, ubuntu-latest, lua, gui) (push) Waiting to run Details
build / build (RelWithDebInfo, windows-latest, lua, gui) (push) Waiting to run Details
build-auto / build-auto (Debug, macos-latest) (push) Has been cancelled Details
build-auto / build-auto (Debug, ubuntu-latest) (push) Has been cancelled Details
build-auto / build-auto (Debug, windows-latest) (push) Has been cancelled Details
build-auto / build-auto (RelWithDebInfo, macos-latest) (push) Has been cancelled Details
build-auto / build-auto (RelWithDebInfo, ubuntu-latest) (push) Has been cancelled Details
build-auto / build-auto (RelWithDebInfo, windows-latest) (push) Has been cancelled Details
With #5230, now that we can show the IME dialog on Windows, when we
are selecting a specific word/composition in the IME dialog, if we
press Enter we'll receive that Enter onKeyUp(). It's better if we
process the Enter key onKeyDown() (as the IME enter key is not
received in that case).
2025-07-25 09:19:50 -03:00
David Capello 7d91c4b9d9 [win] Fix dead keys on Windows 2025-07-24 17:45:46 -03:00
Liebranca 27f19959bd Fix tilemap layer copy/paste 2025-07-24 00:01:20 -03:00
7 changed files with 72 additions and 11 deletions

2
laf

@ -1 +1 @@
Subproject commit a2bb9ec7fb98354279a2c49870a4a47a67a8e86e
Subproject commit 8ec4b553f1618f7a4b47cdcf4cfc2663266111ac

View File

@ -2748,7 +2748,10 @@ void Editor::setZoomAndCenterInMouse(const Zoom& zoom,
}
}
void Editor::pasteImage(const Image* image, const Mask* mask, const gfx::Point* position)
void Editor::pasteImage(const Image* image,
const Mask* mask,
const gfx::Point* position,
const Tileset* srcTileset)
{
ASSERT(image);
@ -2840,6 +2843,10 @@ void Editor::pasteImage(const Image* image, const Mask* mask, const gfx::Point*
PixelsMovementPtr pixelsMovement(
new PixelsMovement(UIContext::instance(), site, image, &mask2, "Paste"));
// Adjust image when copying between tilemap layers
if (site.tilemapMode() == TilemapMode::Tiles && srcTileset != nullptr)
pixelsMovement->remapTilesForPaste(srcTileset);
setState(EditorStatePtr(new MovingPixelsState(this, NULL, pixelsMovement, NoHandle)));
}

View File

@ -244,7 +244,8 @@ public:
void pasteImage(const Image* image,
const Mask* mask = nullptr,
const gfx::Point* position = nullptr);
const gfx::Point* position = nullptr,
const Tileset* srcTileset = nullptr);
void startSelectionTransformation(const gfx::Point& move, double angle);
void startFlipTransformation(doc::algorithm::FlipType flipType);

View File

@ -12,6 +12,7 @@
#include "app/ui/editor/pixels_movement.h"
#include "app/app.h"
#include "app/cmd/add_tile.h"
#include "app/cmd/clear_mask.h"
#include "app/cmd/deselect_mask.h"
#include "app/cmd/set_mask.h"
@ -1356,6 +1357,39 @@ void PixelsMovement::drawTransformedTilemap(const Transformation& transformation
draw_row(dst->height() - 1, src->height() - 1, 1);
}
void PixelsMovement::remapTilesForPaste(const Tileset* srcTileset)
{
// Check that tile size matches before doing anything
LayerTilemap* dstLayer = static_cast<LayerTilemap*>(m_site.layer());
Tileset* dstTileset = dstLayer->tileset();
const doc::Grid& srcGrid = srcTileset->grid();
const doc::Grid& dstGrid = dstTileset->grid();
if (srcGrid.tileSize() != dstGrid.tileSize())
throw base::Exception("Tile size does not match.");
// Map source to destination
tile_index dstSz = dstTileset->size();
for (int y = 0; y < m_originalImage->height(); ++y) {
for (int x = 0; x < m_originalImage->width(); ++x) {
// Blank tile can be skipped
const color_t srcTi = m_originalImage->getPixel(x, y);
if (!srcTi)
continue;
// Add tile to destination if missing
tile_index dstTi;
const ImageRef t = srcTileset->get(srcTi);
if (!dstTileset->findTileIndex(t, dstTi)) {
m_tx(new cmd::AddTile(dstTileset, t, srcTileset->getTileData(srcTi)));
dstTi = dstSz++;
}
// Update tile index in image
m_originalImage->putPixel(x, y, dstTi);
}
}
}
void PixelsMovement::onPivotChange()
{
set_pivot_from_preferences(m_currentData);

View File

@ -130,6 +130,9 @@ public:
const Transformation& getTransformation() const { return m_currentData; }
void setTransformation(const Transformation& t);
// For copy/paste between tilemap layers
void remapTilesForPaste(const Tileset* srcTileset);
private:
void setTransformationBase(const Transformation& t);
void adjustPivot();

View File

@ -443,12 +443,7 @@ bool WritingTextState::onSetCursor(Editor* editor, const gfx::Point& mouseScreen
return true;
}
bool WritingTextState::onKeyDown(Editor*, KeyMessage*)
{
return false;
}
bool WritingTextState::onKeyUp(Editor*, KeyMessage* msg)
bool WritingTextState::onKeyDown(Editor*, KeyMessage* msg)
{
// Cancel loop pressing Esc key
if (msg->scancode() == ui::kKeyEsc) {
@ -457,7 +452,17 @@ bool WritingTextState::onKeyUp(Editor*, KeyMessage* msg)
// Drop text pressing Enter key
else if (msg->scancode() == ui::kKeyEnter) {
drop();
return true;
}
return false;
}
bool WritingTextState::onKeyUp(Editor*, KeyMessage* msg)
{
// Note: We cannot process kKeyEnter key here to drop the text as it
// could be received after the Enter key is pressed in the IME
// dialog to accept the composition (not to accept the text). So we
// process kKeyEnter in onKeyDown().
return true;
}

View File

@ -10,6 +10,7 @@
#endif
#include "app/app.h"
#include "app/cmd/add_tileset.h"
#include "app/cmd/clear_mask.h"
#include "app/cmd/deselect_mask.h"
#include "app/cmd/set_mask.h"
@ -584,7 +585,10 @@ void Clipboard::paste(Context* ctx, const bool interactive, const gfx::Point* po
// TODO add post-command parameters (issue #2324)
// Change to MovingTilemapState
editor->pasteImage(m_data->tilemap.get(), m_data->mask.get(), position);
editor->pasteImage(m_data->tilemap.get(),
m_data->mask.get(),
position,
m_data->tileset.get());
}
else {
// TODO non-interactive version (for scripts)
@ -763,7 +767,14 @@ void Clipboard::paste(Context* ctx, const bool interactive, const gfx::Point* po
afterThis = dstSpr->root()->lastLayer();
Layer* newLayer = nullptr;
if (srcLayer->isImage())
if (srcLayer->isTilemap()) {
Tileset* srcTileset = static_cast<LayerTilemap*>(srcLayer)->tileset();
Tileset* tilesetCopy = Tileset::MakeCopyCopyingImagesForSprite(srcTileset, dstSpr);
const tileset_index tsi = dstSpr->tilesets()->size();
tx(new cmd::AddTileset(dstSpr, tilesetCopy));
newLayer = new LayerTilemap(dstSpr, tsi);
}
else if (srcLayer->isImage())
newLayer = new LayerImage(dstSpr);
else if (srcLayer->isGroup())
newLayer = new LayerGroup(dstSpr);