[nostalgia/core/studio] Add acceptsClipboardPayload to TileSheetEditor
This commit is contained in:
parent
a138f60fea
commit
97dc027498
@ -105,6 +105,10 @@ void TileSheetEditorImGui::paste() {
|
||||
m_model.paste();
|
||||
}
|
||||
|
||||
bool TileSheetEditorImGui::acceptsClipboardPayload() const noexcept {
|
||||
return m_model.acceptsClipboardPayload();
|
||||
}
|
||||
|
||||
void TileSheetEditorImGui::keyStateChanged(turbine::Key key, bool down) {
|
||||
if (!down) {
|
||||
return;
|
||||
|
@ -79,6 +79,9 @@ class TileSheetEditorImGui: public studio::Editor {
|
||||
|
||||
void paste() override;
|
||||
|
||||
[[nodiscard]]
|
||||
bool acceptsClipboardPayload() const noexcept override;
|
||||
|
||||
void keyStateChanged(turbine::Key key, bool down) override;
|
||||
|
||||
void draw(studio::StudioContext&) noexcept override;
|
||||
|
@ -107,6 +107,11 @@ void TileSheetEditorModel::paste() {
|
||||
pushCommand(ox::make<CutPasteCommand>(CommandId::Paste, m_img, m_activeSubsSheetIdx, pt1, pt2, *cb));
|
||||
}
|
||||
|
||||
bool TileSheetEditorModel::acceptsClipboardPayload() const noexcept {
|
||||
auto const cb = getClipboardObject<TileSheetClipboard>(m_tctx);
|
||||
return cb.ok();
|
||||
}
|
||||
|
||||
ox::StringView TileSheetEditorModel::palPath() const noexcept {
|
||||
auto [path, err] = m_img.defaultPalette.getPath();
|
||||
if (err) {
|
||||
@ -216,12 +221,14 @@ void TileSheetEditorModel::select(ox::Point const&pt) noexcept {
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::completeSelection() noexcept {
|
||||
auto &s = activeSubSheet();
|
||||
m_selTracker.finishSelection();
|
||||
m_selection.emplace(m_selTracker.selection());
|
||||
auto &pt = m_selection->b;
|
||||
pt.x = ox::min(s.columns * TileWidth - 1, pt.x);
|
||||
pt.y = ox::min(s.rows * TileHeight - 1, pt.y);
|
||||
if (m_selTracker.selectionOngoing()) {
|
||||
m_selTracker.finishSelection();
|
||||
m_selection.emplace(m_selTracker.selection());
|
||||
auto&pt = m_selection->b;
|
||||
auto&s = activeSubSheet();
|
||||
pt.x = ox::min(s.columns * TileWidth - 1, pt.x);
|
||||
pt.y = ox::min(s.rows * TileHeight - 1, pt.y);
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::clearSelection() noexcept {
|
||||
|
@ -48,6 +48,9 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
|
||||
void paste();
|
||||
|
||||
[[nodiscard]]
|
||||
bool acceptsClipboardPayload() const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr TileSheet const&img() const noexcept;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user