mirror of https://github.com/aseprite/aseprite.git
Compare commits
8 Commits
b637f315c0
...
8cabd61286
Author | SHA1 | Date |
---|---|---|
|
8cabd61286 | |
|
2ba051b59b | |
|
3fcb000eb1 | |
|
af9dc3c817 | |
|
250dfdc86a | |
|
f04678e407 | |
|
7218e49529 | |
|
8b353c3b81 |
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2024 Igara Studio S.A.
|
// Copyright (C) 2019-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
|
@ -457,6 +457,8 @@ void BrushPreview::show(const gfx::Point& screenPos)
|
||||||
|
|
||||||
// Here we re-use the cached surface
|
// Here we re-use the cached surface
|
||||||
if (!cached && m_uiLayer->surface()) {
|
if (!cached && m_uiLayer->surface()) {
|
||||||
|
m_uiLayer->surface()->clear();
|
||||||
|
|
||||||
gfx::Rect layerBounds = m_uiLayer->surface()->bounds();
|
gfx::Rect layerBounds = m_uiLayer->surface()->bounds();
|
||||||
ui::Graphics g(display, m_uiLayer->surface(), 0, 0);
|
ui::Graphics g(display, m_uiLayer->surface(), 0, 0);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#include "app/util/tile_flags_utils.h"
|
#include "app/util/tile_flags_utils.h"
|
||||||
#include "base/chrono.h"
|
#include "base/chrono.h"
|
||||||
#include "base/convert_to.h"
|
#include "base/convert_to.h"
|
||||||
|
#include "base/scoped_value.h"
|
||||||
#include "doc/doc.h"
|
#include "doc/doc.h"
|
||||||
#include "doc/mask_boundaries.h"
|
#include "doc/mask_boundaries.h"
|
||||||
#include "doc/slice.h"
|
#include "doc/slice.h"
|
||||||
|
@ -266,6 +267,23 @@ void Editor::setStateInternal(const EditorStatePtr& newState)
|
||||||
{
|
{
|
||||||
m_brushPreview.hide();
|
m_brushPreview.hide();
|
||||||
|
|
||||||
|
// Some onLeaveState impls (like the ones from MovingPixelsState,
|
||||||
|
// WritingTextState, MovingSelectionState) might generate a
|
||||||
|
// Tx/Transaction::commit(), which will add a new undo state,
|
||||||
|
// triggering a sprite change scripting event
|
||||||
|
// (SpriteEvents::onAddUndoState). This event could be handled by an
|
||||||
|
// extension and that extension might want to save the current
|
||||||
|
// sprite (e.g. calling Sprite_saveCopyAs, the kind of extension
|
||||||
|
// that takes snapshots after each sprite change). That will be a
|
||||||
|
// new Context::executeCommand() for the save command, generating a
|
||||||
|
// BeforeCommandExecution signal, getting back to onLeaveState
|
||||||
|
// again. In that case, we just ignore the reentry as the first
|
||||||
|
// onLeaveState should handle everything (to avoid an stack
|
||||||
|
// overflow/infinite recursion).
|
||||||
|
if (m_leavingState)
|
||||||
|
return;
|
||||||
|
base::ScopedValue leaving(m_leavingState, true);
|
||||||
|
|
||||||
// Fire before change state event, set the state, and fire after
|
// Fire before change state event, set the state, and fire after
|
||||||
// change state event.
|
// change state event.
|
||||||
EditorState::LeaveAction leaveAction = m_state->onLeaveState(this, newState.get());
|
EditorState::LeaveAction leaveAction = m_state->onLeaveState(this, newState.get());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018-2024 Igara Studio S.A.
|
// Copyright (C) 2018-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
|
@ -458,6 +458,13 @@ private:
|
||||||
|
|
||||||
DocView* m_docView;
|
DocView* m_docView;
|
||||||
|
|
||||||
|
// Special flag to avoid re-entering a new state when we are leaving
|
||||||
|
// the current one. This avoids an infinite onLeaveState() recursion
|
||||||
|
// in some special cases when an extension (third-party code)
|
||||||
|
// creates a new sprite change in the same sprite change scripting
|
||||||
|
// event.
|
||||||
|
bool m_leavingState = false;
|
||||||
|
|
||||||
// Last known mouse position received by this editor when the
|
// Last known mouse position received by this editor when the
|
||||||
// mouse button was pressed. Used for auto-scrolling. To get the
|
// mouse button was pressed. Used for auto-scrolling. To get the
|
||||||
// current mouse position on the editor you can use
|
// current mouse position on the editor you can use
|
||||||
|
|
|
@ -428,8 +428,8 @@ bool MovingSliceState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||||
if (editor->slicesTransforms())
|
if (editor->slicesTransforms())
|
||||||
drawExtraCel();
|
drawExtraCel();
|
||||||
|
|
||||||
// Redraw the editor.
|
// Notify changes
|
||||||
editor->invalidate();
|
m_site.document()->notifyGeneralUpdate();
|
||||||
|
|
||||||
// Use StandbyState implementation
|
// Use StandbyState implementation
|
||||||
return StandbyState::onMouseMove(editor, msg);
|
return StandbyState::onMouseMove(editor, msg);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite Document Library
|
// Aseprite Document Library
|
||||||
// Copyright (C) 2019-2024 Igara Studio S.A.
|
// Copyright (C) 2019-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
|
@ -20,11 +20,12 @@
|
||||||
#include "doc/primitives.h"
|
#include "doc/primitives.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <atomic>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace doc {
|
namespace doc {
|
||||||
|
|
||||||
static int generation = 0;
|
static std::atomic<int> g_generation = 0;
|
||||||
|
|
||||||
Brush::Brush()
|
Brush::Brush()
|
||||||
{
|
{
|
||||||
|
@ -300,7 +301,7 @@ void Brush::setCenter(const gfx::Point& center)
|
||||||
// Cleans the brush's data (image and region).
|
// Cleans the brush's data (image and region).
|
||||||
void Brush::clean()
|
void Brush::clean()
|
||||||
{
|
{
|
||||||
m_gen = ++generation;
|
m_gen = ++g_generation;
|
||||||
m_image.reset();
|
m_image.reset();
|
||||||
m_maskBitmap.reset();
|
m_maskBitmap.reset();
|
||||||
m_backupImage.reset();
|
m_backupImage.reset();
|
||||||
|
|
|
@ -128,6 +128,15 @@ int Entry::lastCaretPos() const
|
||||||
return int(m_boxes.size() - 1);
|
return int(m_boxes.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfx::Point Entry::caretPosOnScreen() const
|
||||||
|
{
|
||||||
|
const gfx::Point caretPos = getCharBoxBounds(m_caret).point2();
|
||||||
|
const os::Window* nativeWindow = display()->nativeWindow();
|
||||||
|
const gfx::Point pos = nativeWindow->pointToScreen(caretPos + bounds().origin());
|
||||||
|
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
void Entry::setCaretPos(const int pos)
|
void Entry::setCaretPos(const int pos)
|
||||||
{
|
{
|
||||||
gfx::Size caretSize = theme()->getEntryCaretSize(this);
|
gfx::Size caretSize = theme()->getEntryCaretSize(this);
|
||||||
|
@ -160,6 +169,8 @@ void Entry::setCaretPos(const int pos)
|
||||||
startTimer();
|
startTimer();
|
||||||
m_state = true;
|
m_state = true;
|
||||||
|
|
||||||
|
os::System::instance()->setTextInput(true, caretPosOnScreen());
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +262,7 @@ gfx::Rect Entry::getEntryTextBounds() const
|
||||||
return onGetEntryTextBounds();
|
return onGetEntryTextBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect Entry::getCharBoxBounds(const int i)
|
gfx::Rect Entry::getCharBoxBounds(const int i) const
|
||||||
{
|
{
|
||||||
ASSERT(i >= 0 && i < int(m_boxes.size()));
|
ASSERT(i >= 0 && i < int(m_boxes.size()));
|
||||||
if (i >= 0 && i < int(m_boxes.size()))
|
if (i >= 0 && i < int(m_boxes.size()))
|
||||||
|
@ -288,8 +299,9 @@ bool Entry::onProcessMessage(Message* msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start processing dead keys
|
// Start processing dead keys
|
||||||
if (m_translate_dead_keys)
|
if (m_translate_dead_keys) {
|
||||||
os::System::instance()->setTextInput(true);
|
os::System::instance()->setTextInput(true, caretPosOnScreen());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kFocusLeaveMessage:
|
case kFocusLeaveMessage:
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
|
|
||||||
int caretPos() const { return m_caret; }
|
int caretPos() const { return m_caret; }
|
||||||
int lastCaretPos() const;
|
int lastCaretPos() const;
|
||||||
|
gfx::Point caretPosOnScreen() const;
|
||||||
|
|
||||||
void setCaretPos(int pos);
|
void setCaretPos(int pos);
|
||||||
void setCaretToEnd();
|
void setCaretToEnd();
|
||||||
|
@ -76,7 +77,7 @@ public:
|
||||||
obs::signal<void()> Change;
|
obs::signal<void()> Change;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
gfx::Rect getCharBoxBounds(int i);
|
gfx::Rect getCharBoxBounds(int i) const;
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
bool onProcessMessage(Message* msg) override;
|
bool onProcessMessage(Message* msg) override;
|
||||||
|
|
Loading…
Reference in New Issue