mirror of https://github.com/aseprite/aseprite.git
Compare commits
5 Commits
2ffdf04ecc
...
e3942527a7
Author | SHA1 | Date |
---|---|---|
|
e3942527a7 | |
|
1f9c153ae7 | |
|
6d89a6bc15 | |
|
d4e97b5a96 | |
|
205b18dc0f |
|
@ -6,19 +6,18 @@ find_library(QUICKLOOK_LIBRARY QuickLookThumbnailing)
|
|||
set(extension_target AsepriteThumbnailer)
|
||||
|
||||
add_executable(${extension_target}
|
||||
appex/thumbnails.mm)
|
||||
appex/thumbnail.mm)
|
||||
|
||||
target_link_libraries(${extension_target}
|
||||
dio-lib
|
||||
render-lib
|
||||
${QUICKLOOK_LIBRARY}
|
||||
)
|
||||
${QUICKLOOK_LIBRARY})
|
||||
|
||||
set_target_properties(${extension_target} PROPERTIES
|
||||
BUNDLE TRUE
|
||||
BUNDLE_EXTENSION appex
|
||||
MACOSX_BUNDLE TRUE
|
||||
LINK_FLAGS "-Wl,-e,_NSExtensionMain"
|
||||
MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/appex/Info.plist")
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/appex/Info.plist")
|
||||
|
||||
add_dependencies(${main_target} ${extension_target})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Aseprite
|
||||
// Copyright (c) 2025 Igara Studio S.A.
|
||||
// Desktop Integration
|
||||
// Copyright (c) 2022-2025 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#include "app/file_system.h"
|
||||
#include "dio/decode_delegate.h"
|
||||
|
@ -16,6 +16,8 @@
|
|||
|
||||
namespace desktop {
|
||||
|
||||
namespace {
|
||||
|
||||
class DecodeDelegate : public dio::DecodeDelegate {
|
||||
public:
|
||||
DecodeDelegate() : m_sprite(nullptr) {}
|
||||
|
@ -34,13 +36,13 @@ class StreamAdaptor : public dio::FileInterface {
|
|||
public:
|
||||
StreamAdaptor(NSData* data) : m_data(data), m_ok(m_data != nullptr), m_pos(0) {}
|
||||
|
||||
bool ok() const override { return m_ok; }
|
||||
bool ok() const { return m_ok; }
|
||||
|
||||
size_t tell() override { return m_pos; }
|
||||
size_t tell() { return m_pos; }
|
||||
|
||||
void seek(size_t absPos) override { m_pos = absPos; }
|
||||
void seek(size_t absPos) { m_pos = absPos; }
|
||||
|
||||
uint8_t read8() override
|
||||
uint8_t read8()
|
||||
{
|
||||
if (!m_ok)
|
||||
return 0;
|
||||
|
@ -53,7 +55,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
size_t readBytes(uint8_t* buf, size_t n) override
|
||||
size_t readBytes(uint8_t* buf, size_t n)
|
||||
{
|
||||
if (!m_ok)
|
||||
return 0;
|
||||
|
@ -71,16 +73,21 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void write8(uint8_t value) override {};
|
||||
void write8(uint8_t value)
|
||||
{
|
||||
// Do nothing, we don't write in the file
|
||||
}
|
||||
|
||||
NSData* m_data;
|
||||
bool m_ok;
|
||||
size_t m_pos;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
CGImageRef get_thumbnail(CFURLRef url, CGSize maxSize)
|
||||
{
|
||||
auto data = [[NSData alloc] initWithContentsOfURL:(__bridge NSURL*)url];
|
||||
auto data = [[NSData alloc] initWithContentsOfURL:(NSURL*)url];
|
||||
if (!data)
|
||||
return nullptr;
|
||||
|
|
@ -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