Compare commits

..

5 Commits

Author SHA1 Message Date
Gaspar Capello e3942527a7
Merge 1f9c153ae7 into 6d89a6bc15 2025-07-24 15:56:15 +00:00
Gaspar Capello 1f9c153ae7 Fix thumbnails for macOS Sequoia (fix #5009) 2025-07-24 12:53:23 -03:00
Cerallin 6d89a6bc15 fix entry
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
build / build (Debug, macos-latest, lua, cli) (push) Has been cancelled Details
build / build (Debug, macos-latest, noscripts, cli) (push) Has been cancelled Details
build / build (Debug, ubuntu-latest, lua, cli) (push) Has been cancelled Details
build / build (Debug, ubuntu-latest, noscripts, cli) (push) Has been cancelled Details
build / build (Debug, windows-latest, lua, cli) (push) Has been cancelled Details
build / build (Debug, windows-latest, noscripts, cli) (push) Has been cancelled Details
build / build (RelWithDebInfo, macos-latest, lua, gui) (push) Has been cancelled Details
build / build (RelWithDebInfo, ubuntu-latest, lua, gui) (push) Has been cancelled Details
build / build (RelWithDebInfo, windows-latest, lua, gui) (push) Has been cancelled Details
2025-07-24 12:50:32 -03:00
Cerallin d4e97b5a96 Add const method Entry::caretPosOnScreen()
This method is for Entry::setTextInput() and IME positioning.
2025-07-24 12:50:32 -03:00
Cerallin 205b18dc0f Make Entry::getCharBoxBounds() a const method 2025-07-24 12:50:32 -03:00
5 changed files with 38 additions and 19 deletions

View File

@ -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})

View File

@ -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;

View File

@ -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:

View File

@ -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;