mirror of https://github.com/aseprite/aseprite.git
Compare commits
5 Commits
b11960efe2
...
747858587b
Author | SHA1 | Date |
---|---|---|
|
747858587b | |
|
6d89a6bc15 | |
|
d4e97b5a96 | |
|
205b18dc0f | |
|
1e556678ba |
|
@ -168,6 +168,21 @@ SelectLayerBoundariesOp get_select_layer_in_canvas_op(ui::Message* msg)
|
|||
return SelectLayerBoundariesOp::REPLACE;
|
||||
}
|
||||
|
||||
bool get_layer_index(LayerGroup* parent, const Layer* layer, layer_t& index)
|
||||
{
|
||||
for (Layer* child : parent->layers()) {
|
||||
if (child->isGroup() && get_layer_index(static_cast<LayerGroup*>(child), layer, index)) {
|
||||
return index;
|
||||
}
|
||||
|
||||
if (child == layer) {
|
||||
return true;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
Timeline::Hit::Hit(int part, layer_t layer, col_t frame, ObjectId tag, int band)
|
||||
|
@ -4055,6 +4070,12 @@ layer_t Timeline::getLayerIndex(const Layer* layer) const
|
|||
return -1;
|
||||
}
|
||||
|
||||
layer_t Timeline::getLayerIndexFromSprite(const Layer* layer) const
|
||||
{
|
||||
layer_t index = 0;
|
||||
return get_layer_index(m_sprite->root(), layer, index) ? index : -1;
|
||||
}
|
||||
|
||||
bool Timeline::isLayerActive(const layer_t layerIndex) const
|
||||
{
|
||||
Layer* layer = getLayer(layerIndex);
|
||||
|
@ -4576,7 +4597,7 @@ void Timeline::onDrop(ui::DragEvent& e)
|
|||
|
||||
// Determine at which frame and layer the content was dropped on.
|
||||
frame_t frame = m_frame;
|
||||
layer_t layerIndex = getLayerIndex(m_layer);
|
||||
layer_t layerIndex = getLayerIndexFromSprite(m_layer);
|
||||
InsertionPoint insert = InsertionPoint::BeforeLayer;
|
||||
DroppedOn droppedOn = DroppedOn::Unspecified;
|
||||
TRACE("m_dropRange.type() %d\n", m_dropRange.type());
|
||||
|
@ -4602,7 +4623,7 @@ void Timeline::onDrop(ui::DragEvent& e)
|
|||
break;
|
||||
case Range::kLayers:
|
||||
droppedOn = DroppedOn::Layer;
|
||||
if (m_dropTarget.vhit != DropTarget::VeryBottom) {
|
||||
if (m_dropTarget.vhit != DropTarget::VeryBottom && !m_dropRange.selectedLayers().empty()) {
|
||||
auto* selectedLayer = *m_dropRange.selectedLayers().begin();
|
||||
layerIndex = getLayerIndex(selectedLayer);
|
||||
}
|
||||
|
|
|
@ -355,6 +355,8 @@ private:
|
|||
gfx::Point getMaxScrollablePos() const;
|
||||
doc::Layer* getLayer(int layerIndex) const;
|
||||
layer_t getLayerIndex(const Layer* layer) const;
|
||||
// Get layer index regardless of visibility in the UI.
|
||||
layer_t getLayerIndexFromSprite(const Layer* layer) const;
|
||||
bool isLayerActive(const layer_t layerIdx) const;
|
||||
bool isFrameActive(const col_t frame) const;
|
||||
bool isCelActive(const layer_t layerIdx, const col_t frame) const;
|
||||
|
|
|
@ -128,6 +128,15 @@ int Entry::lastCaretPos() const
|
|||
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)
|
||||
{
|
||||
gfx::Size caretSize = theme()->getEntryCaretSize(this);
|
||||
|
@ -160,6 +169,8 @@ void Entry::setCaretPos(const int pos)
|
|||
startTimer();
|
||||
m_state = true;
|
||||
|
||||
os::System::instance()->setTextInput(true, caretPosOnScreen());
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
@ -251,7 +262,7 @@ gfx::Rect Entry::getEntryTextBounds() const
|
|||
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()));
|
||||
if (i >= 0 && i < int(m_boxes.size()))
|
||||
|
@ -288,8 +299,9 @@ bool Entry::onProcessMessage(Message* msg)
|
|||
}
|
||||
|
||||
// Start processing dead keys
|
||||
if (m_translate_dead_keys)
|
||||
os::System::instance()->setTextInput(true);
|
||||
if (m_translate_dead_keys) {
|
||||
os::System::instance()->setTextInput(true, caretPosOnScreen());
|
||||
}
|
||||
break;
|
||||
|
||||
case kFocusLeaveMessage:
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
|
||||
int caretPos() const { return m_caret; }
|
||||
int lastCaretPos() const;
|
||||
gfx::Point caretPosOnScreen() const;
|
||||
|
||||
void setCaretPos(int pos);
|
||||
void setCaretToEnd();
|
||||
|
@ -76,7 +77,7 @@ public:
|
|||
obs::signal<void()> Change;
|
||||
|
||||
protected:
|
||||
gfx::Rect getCharBoxBounds(int i);
|
||||
gfx::Rect getCharBoxBounds(int i) const;
|
||||
|
||||
// Events
|
||||
bool onProcessMessage(Message* msg) override;
|
||||
|
|
Loading…
Reference in New Issue