mirror of https://github.com/aseprite/aseprite.git
Compare commits
27 Commits
598665447f
...
ca1e99bf70
Author | SHA1 | Date |
---|---|---|
|
ca1e99bf70 | |
|
6d89a6bc15 | |
|
d4e97b5a96 | |
|
205b18dc0f | |
|
2ba051b59b | |
|
3fcb000eb1 | |
|
af9dc3c817 | |
|
250dfdc86a | |
|
c904c41b39 | |
|
9e941e9a8b | |
|
bbab4d5875 | |
|
5c4daff128 | |
|
11a7b061ff | |
|
283bedf77e | |
|
2eeb6f04a7 | |
|
706d0b8a7a | |
|
2f3a7f5dec | |
|
d5de74b715 | |
|
2d87a7b184 | |
|
2f22804fe8 | |
|
bf1b4c6f50 | |
|
250244c777 | |
|
b4555fc098 | |
|
8783135bf7 | |
|
1a6a39700e | |
|
ce742bcbc1 | |
|
3c350c3e67 |
|
@ -4,7 +4,7 @@ Aseprite is being developed and maintained currently by [Igara Studio](https://i
|
||||||
The active team of developers is:
|
The active team of developers is:
|
||||||
|
|
||||||
* [David Capello](https://github.com/dacap)
|
* [David Capello](https://github.com/dacap)
|
||||||
* [Gaspar Capello](https://github.com/Gsparoken)
|
* [Gaspar Capello](https://github.com/Gasparoken)
|
||||||
* [Martín Capello](https://github.com/martincapello)
|
* [Martín Capello](https://github.com/martincapello)
|
||||||
* [Christian Kaiser](https://github.com/ckaiser)
|
* [Christian Kaiser](https://github.com/ckaiser)
|
||||||
* [Dante Paola](https://github.com/Liebranca)
|
* [Dante Paola](https://github.com/Liebranca)
|
||||||
|
|
|
@ -356,6 +356,7 @@
|
||||||
<section id="file_selector">
|
<section id="file_selector">
|
||||||
<option id="current_folder" type="std::string" default=""<empty>"" />
|
<option id="current_folder" type="std::string" default=""<empty>"" />
|
||||||
<option id="zoom" type="double" default="1.0" />
|
<option id="zoom" type="double" default="1.0" />
|
||||||
|
<option id="show_hidden" type="bool" default="false" />
|
||||||
</section>
|
</section>
|
||||||
<section id="text_tool">
|
<section id="text_tool">
|
||||||
<option id="font_face" type="std::string" />
|
<option id="font_face" type="std::string" />
|
||||||
|
|
|
@ -765,6 +765,7 @@ pinned_folders = Pinned Folders
|
||||||
recent_folders = Recent Folders
|
recent_folders = Recent Folders
|
||||||
all_formats = All formats
|
all_formats = All formats
|
||||||
all_files = All files
|
all_files = All files
|
||||||
|
show_hidden = Show hidden
|
||||||
|
|
||||||
[filters]
|
[filters]
|
||||||
selected_cels = Selected
|
selected_cels = Selected
|
||||||
|
@ -1834,6 +1835,18 @@ pixel_scale = Pixel Scale
|
||||||
with_vars = Use CSS3 Variables
|
with_vars = Use CSS3 Variables
|
||||||
generate_html = Generate Sample HTML File
|
generate_html = Generate Sample HTML File
|
||||||
|
|
||||||
|
[shape]
|
||||||
|
fill = Fill
|
||||||
|
stroke = Stroke
|
||||||
|
stroke_width = Stroke Width
|
||||||
|
|
||||||
|
[text_tool]
|
||||||
|
font_family = Font Family
|
||||||
|
font_size = Font Size
|
||||||
|
bold = Bold
|
||||||
|
italic = Italic
|
||||||
|
more_options = More Options
|
||||||
|
|
||||||
[timeline_conf]
|
[timeline_conf]
|
||||||
position = Position:
|
position = Position:
|
||||||
left = &Left
|
left = &Left
|
||||||
|
@ -1896,6 +1909,7 @@ timeline_show = Show Timeline
|
||||||
|
|
||||||
[undo_history]
|
[undo_history]
|
||||||
title = Undo History
|
title = Undo History
|
||||||
|
initial_state = Initial State
|
||||||
|
|
||||||
[user_data]
|
[user_data]
|
||||||
user_data = User Data:
|
user_data = User Data:
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<combobox id="location" expansive="true" />
|
<combobox id="location" expansive="true" />
|
||||||
<button text="" id="refresh_button" style="refresh_button"
|
<button text="" id="refresh_button" style="refresh_button"
|
||||||
tooltip="@.refresh_button_tooltip" tooltip_dir="bottom" />
|
tooltip="@.refresh_button_tooltip" tooltip_dir="bottom" />
|
||||||
|
<check id="show_hidden_check" text="@.show_hidden" />
|
||||||
</box>
|
</box>
|
||||||
<vbox id="file_view_placeholder" expansive="true" />
|
<vbox id="file_view_placeholder" expansive="true" />
|
||||||
<grid columns="2">
|
<grid columns="2">
|
||||||
|
|
2
laf
2
laf
|
@ -1 +1 @@
|
||||||
Subproject commit 7873e82be7828d1c22255a4b06d1d3d34586f12f
|
Subproject commit a2bb9ec7fb98354279a2c49870a4a47a67a8e86e
|
|
@ -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
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/color_utils.h"
|
||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
#include "app/console.h"
|
#include "app/console.h"
|
||||||
#include "app/context.h"
|
#include "app/context.h"
|
||||||
|
@ -88,10 +89,10 @@ void PasteTextCommand::onExecute(Context* ctx)
|
||||||
std::string text = window.userText()->text();
|
std::string text = window.userText()->text();
|
||||||
app::Color color = window.fontColor()->getColor();
|
app::Color color = window.fontColor()->getColor();
|
||||||
|
|
||||||
doc::ImageRef image = render_text(
|
ui::Paint paint = window.fontFace()->paint();
|
||||||
fontInfo,
|
paint.color(color_utils::color_for_ui(color));
|
||||||
text,
|
|
||||||
gfx::rgba(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()));
|
doc::ImageRef image = render_text(fontInfo, text, paint);
|
||||||
if (image) {
|
if (image) {
|
||||||
Sprite* sprite = editor->sprite();
|
Sprite* sprite = editor->sprite();
|
||||||
if (image->pixelFormat() != sprite->pixelFormat()) {
|
if (image->pixelFormat() != sprite->pixelFormat()) {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "app/doc_undo.h"
|
#include "app/doc_undo.h"
|
||||||
#include "app/doc_undo_observer.h"
|
#include "app/doc_undo_observer.h"
|
||||||
#include "app/docs_observer.h"
|
#include "app/docs_observer.h"
|
||||||
|
#include "app/i18n/strings.h"
|
||||||
#include "app/modules/gui.h"
|
#include "app/modules/gui.h"
|
||||||
#include "app/modules/palettes.h"
|
#include "app/modules/palettes.h"
|
||||||
#include "app/site.h"
|
#include "app/site.h"
|
||||||
|
@ -292,7 +293,7 @@ public:
|
||||||
base::get_pretty_memory_size(static_cast<Cmd*>(state->cmd())->memSize())
|
base::get_pretty_memory_size(static_cast<Cmd*>(state->cmd())->memSize())
|
||||||
#endif
|
#endif
|
||||||
:
|
:
|
||||||
std::string("Initial State"));
|
Strings::undo_history_initial_state());
|
||||||
|
|
||||||
if ((g->getClipBounds() & itemBounds).isEmpty())
|
if ((g->getClipBounds() & itemBounds).isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2023 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
|
||||||
|
@ -139,6 +139,13 @@ DataRecovery::Sessions DataRecovery::sessions()
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DataRecovery::isRunningSession(const SessionPtr& session) const
|
||||||
|
{
|
||||||
|
ASSERT(session);
|
||||||
|
ASSERT(m_inProgress);
|
||||||
|
return session->path() == m_inProgress->path();
|
||||||
|
}
|
||||||
|
|
||||||
void DataRecovery::searchForSessions()
|
void DataRecovery::searchForSessions()
|
||||||
{
|
{
|
||||||
Sessions sessions;
|
Sessions sessions;
|
||||||
|
@ -150,7 +157,7 @@ void DataRecovery::searchForSessions()
|
||||||
RECO_TRACE("RECO: Session '%s' ", itempath.c_str());
|
RECO_TRACE("RECO: Session '%s' ", itempath.c_str());
|
||||||
|
|
||||||
SessionPtr session(new Session(&m_config, itempath));
|
SessionPtr session(new Session(&m_config, itempath));
|
||||||
if (!session->isRunning()) {
|
if (!isRunningSession(session)) {
|
||||||
if ((session->isEmpty()) || (!session->isCrashedSession() && session->isOldSession())) {
|
if ((session->isEmpty()) || (!session->isCrashedSession() && session->isOldSession())) {
|
||||||
RECO_TRACE("to be deleted (%s)\n",
|
RECO_TRACE("to be deleted (%s)\n",
|
||||||
session->isEmpty() ? "is empty" :
|
session->isEmpty() ? "is empty" :
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2021 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
|
||||||
|
@ -45,6 +45,8 @@ public:
|
||||||
// Returns a copy of the list of sessions that can be recovered.
|
// Returns a copy of the list of sessions that can be recovered.
|
||||||
Sessions sessions();
|
Sessions sessions();
|
||||||
|
|
||||||
|
bool isRunningSession(const SessionPtr& session) const;
|
||||||
|
|
||||||
// Triggered in the UI-thread from the m_thread using an
|
// Triggered in the UI-thread from the m_thread using an
|
||||||
// ui::execute_from_ui_thread() when the list of sessions is ready
|
// ui::execute_from_ui_thread() when the list of sessions is ready
|
||||||
// to be used.
|
// to be used.
|
||||||
|
|
|
@ -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
|
||||||
|
@ -19,12 +19,10 @@
|
||||||
#include "app/crash/write_document.h"
|
#include "app/crash/write_document.h"
|
||||||
#include "app/doc.h"
|
#include "app/doc.h"
|
||||||
#include "app/doc_access.h"
|
#include "app/doc_access.h"
|
||||||
#include "app/file/file.h"
|
|
||||||
#include "app/ui_context.h"
|
#include "app/ui_context.h"
|
||||||
#include "base/convert_to.h"
|
#include "base/convert_to.h"
|
||||||
#include "base/fs.h"
|
#include "base/fs.h"
|
||||||
#include "base/fstream_path.h"
|
#include "base/fstream_path.h"
|
||||||
#include "base/process.h"
|
|
||||||
#include "base/split_string.h"
|
#include "base/split_string.h"
|
||||||
#include "base/string.h"
|
#include "base/string.h"
|
||||||
#include "base/thread.h"
|
#include "base/thread.h"
|
||||||
|
@ -128,12 +126,6 @@ const Session::Backups& Session::backups()
|
||||||
return m_backups;
|
return m_backups;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Session::isRunning()
|
|
||||||
{
|
|
||||||
loadPid();
|
|
||||||
return base::get_process_name(m_pid) == base::get_process_name(base::get_current_process_id());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Session::isCrashedSession()
|
bool Session::isCrashedSession()
|
||||||
{
|
{
|
||||||
loadPid();
|
loadPid();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2022 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
|
||||||
|
@ -47,9 +47,9 @@ public:
|
||||||
|
|
||||||
std::string name() const;
|
std::string name() const;
|
||||||
std::string version();
|
std::string version();
|
||||||
|
std::string& path() { return m_path; }
|
||||||
const Backups& backups();
|
const Backups& backups();
|
||||||
|
|
||||||
bool isRunning();
|
|
||||||
bool isCrashedSession();
|
bool isCrashedSession();
|
||||||
bool isOldSession();
|
bool isOldSession();
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018-2023 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
|
||||||
|
@ -1401,7 +1401,7 @@ private:
|
||||||
color_t color = *srcIt;
|
color_t color = *srcIt;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (rgba_geta(color) >= 128) {
|
if (rgba_geta(color) > 0) {
|
||||||
i = framePalette.findExactMatch(rgba_getr(color),
|
i = framePalette.findExactMatch(rgba_getr(color),
|
||||||
rgba_getg(color),
|
rgba_getg(color),
|
||||||
rgba_getb(color),
|
rgba_getb(color),
|
||||||
|
|
|
@ -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
|
||||||
|
@ -82,6 +82,9 @@ public:
|
||||||
unsigned int m_version;
|
unsigned int m_version;
|
||||||
bool m_removed;
|
bool m_removed;
|
||||||
mutable bool m_is_folder;
|
mutable bool m_is_folder;
|
||||||
|
#ifdef _WIN32
|
||||||
|
bool m_isHidden = false;
|
||||||
|
#endif
|
||||||
std::atomic<double> m_thumbnailProgress;
|
std::atomic<double> m_thumbnailProgress;
|
||||||
std::atomic<os::Surface*> m_thumbnail;
|
std::atomic<os::Surface*> m_thumbnail;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -266,7 +269,7 @@ IFileItem* FileSystemModule::getRootFileItem()
|
||||||
fileitem->m_pidl = pidl;
|
fileitem->m_pidl = pidl;
|
||||||
fileitem->m_fullpidl = pidl;
|
fileitem->m_fullpidl = pidl;
|
||||||
|
|
||||||
SFGAOF attrib = SFGAO_FOLDER;
|
SFGAOF attrib = SFGAO_FOLDER | SFGAO_HIDDEN;
|
||||||
shl_idesktop->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &attrib);
|
shl_idesktop->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &attrib);
|
||||||
|
|
||||||
update_by_pidl(fileitem, attrib);
|
update_by_pidl(fileitem, attrib);
|
||||||
|
@ -357,7 +360,7 @@ bool FileItem::isHidden() const
|
||||||
ASSERT(m_displayname != NOTINITIALIZED);
|
ASSERT(m_displayname != NOTINITIALIZED);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return false;
|
return m_isHidden;
|
||||||
#else
|
#else
|
||||||
return m_displayname[0] == '.';
|
return m_displayname[0] == '.';
|
||||||
#endif
|
#endif
|
||||||
|
@ -462,7 +465,7 @@ const FileItemList& FileItem::children()
|
||||||
// Get the interface to enumerate subitems
|
// Get the interface to enumerate subitems
|
||||||
hr = pFolder->EnumObjects(
|
hr = pFolder->EnumObjects(
|
||||||
reinterpret_cast<HWND>(os::System::instance()->defaultWindow()->nativeHandle()),
|
reinterpret_cast<HWND>(os::System::instance()->defaultWindow()->nativeHandle()),
|
||||||
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS,
|
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN,
|
||||||
&pEnum);
|
&pEnum);
|
||||||
|
|
||||||
if (hr == S_OK && pEnum) {
|
if (hr == S_OK && pEnum) {
|
||||||
|
@ -473,10 +476,9 @@ const FileItemList& FileItem::children()
|
||||||
while (pEnum->Next(256, itempidl, &fetched) == S_OK && fetched > 0) {
|
while (pEnum->Next(256, itempidl, &fetched) == S_OK && fetched > 0) {
|
||||||
// Request the SFGAO_FOLDER attribute to know what of the
|
// Request the SFGAO_FOLDER attribute to know what of the
|
||||||
// item is file or a folder
|
// item is file or a folder
|
||||||
for (c = 0; c < fetched; ++c) {
|
for (c = 0; c < fetched; ++c)
|
||||||
attribs[c] = SFGAO_FOLDER;
|
attribs[c] = SFGAO_FOLDER | SFGAO_HIDDEN;
|
||||||
pFolder->GetAttributesOf(1, (LPCITEMIDLIST*)itempidl, attribs + c);
|
pFolder->GetAttributesOf(fetched, (LPCITEMIDLIST*)itempidl, attribs);
|
||||||
}
|
|
||||||
|
|
||||||
// Generate the FileItems
|
// Generate the FileItems
|
||||||
for (c = 0; c < fetched; ++c) {
|
for (c = 0; c < fetched; ++c) {
|
||||||
|
@ -755,6 +757,9 @@ static void update_by_pidl(FileItem* fileitem, SFGAOF attrib)
|
||||||
// Is it a folder?
|
// Is it a folder?
|
||||||
|
|
||||||
fileitem->m_is_folder = calc_is_folder(fileitem->m_filename, attrib);
|
fileitem->m_is_folder = calc_is_folder(fileitem->m_filename, attrib);
|
||||||
|
#if _WIN32
|
||||||
|
fileitem->m_isHidden = (attrib & SFGAO_HIDDEN ? true : false);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Get the name to display
|
// Get the name to display
|
||||||
|
|
||||||
|
|
|
@ -1857,7 +1857,7 @@ private:
|
||||||
|
|
||||||
class ContextBar::FontSelector : public FontEntry {
|
class ContextBar::FontSelector : public FontEntry {
|
||||||
public:
|
public:
|
||||||
FontSelector(ContextBar* contextBar)
|
FontSelector(ContextBar* contextBar) : FontEntry(true) // With stroke and fill options
|
||||||
{
|
{
|
||||||
// Load the font from the preferences
|
// Load the font from the preferences
|
||||||
setInfo(FontInfo::getFromPreferences(), FontEntry::From::Init);
|
setInfo(FontInfo::getFromPreferences(), FontEntry::From::Init);
|
||||||
|
@ -2559,6 +2559,11 @@ FontInfo ContextBar::fontInfo() const
|
||||||
return m_fontSelector->info();
|
return m_fontSelector->info();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FontEntry* ContextBar::fontEntry()
|
||||||
|
{
|
||||||
|
return m_fontSelector;
|
||||||
|
}
|
||||||
|
|
||||||
render::DitheringMatrix ContextBar::ditheringMatrix()
|
render::DitheringMatrix ContextBar::ditheringMatrix()
|
||||||
{
|
{
|
||||||
return m_ditheringSelector->ditheringMatrix();
|
return m_ditheringSelector->ditheringMatrix();
|
||||||
|
|
|
@ -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-2017 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
|
@ -90,6 +90,7 @@ public:
|
||||||
|
|
||||||
// For text tool
|
// For text tool
|
||||||
FontInfo fontInfo() const;
|
FontInfo fontInfo() const;
|
||||||
|
FontEntry* fontEntry();
|
||||||
|
|
||||||
// For gradients
|
// For gradients
|
||||||
render::DitheringMatrix ditheringMatrix();
|
render::DitheringMatrix ditheringMatrix();
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
#include "app/extra_cel.h"
|
#include "app/extra_cel.h"
|
||||||
#include "app/fonts/font_info.h"
|
#include "app/fonts/font_info.h"
|
||||||
|
#include "app/i18n/strings.h"
|
||||||
#include "app/pref/preferences.h"
|
#include "app/pref/preferences.h"
|
||||||
#include "app/site.h"
|
#include "app/site.h"
|
||||||
#include "app/tx.h"
|
#include "app/tx.h"
|
||||||
|
@ -43,12 +44,42 @@
|
||||||
#include "os/skia/skia_surface.h"
|
#include "os/skia/skia_surface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
|
// Get ui::Paint to render text from context bar options / preferences
|
||||||
|
static ui::Paint get_paint_for_text()
|
||||||
|
{
|
||||||
|
ui::Paint paint;
|
||||||
|
if (auto* app = App::instance()) {
|
||||||
|
if (auto* ctxBar = app->contextBar())
|
||||||
|
paint = ctxBar->fontEntry()->paint();
|
||||||
|
}
|
||||||
|
paint.color(color_utils::color_for_ui(Preferences::instance().colorBar.fgColor()));
|
||||||
|
return paint;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gfx::RectF calc_blob_bounds(const text::TextBlobRef& blob)
|
||||||
|
{
|
||||||
|
gfx::RectF bounds = get_text_blob_required_bounds(blob);
|
||||||
|
ui::Paint paint = get_paint_for_text();
|
||||||
|
if (paint.style() == ui::Paint::Style::Stroke ||
|
||||||
|
paint.style() == ui::Paint::Style::StrokeAndFill) {
|
||||||
|
bounds.enlarge(std::ceil(paint.strokeWidth()));
|
||||||
|
}
|
||||||
|
return bounds;
|
||||||
|
}
|
||||||
|
|
||||||
class WritingTextState::TextEditor : public Entry {
|
class WritingTextState::TextEditor : public Entry {
|
||||||
public:
|
public:
|
||||||
|
enum TextPreview {
|
||||||
|
Intermediate, // With selection preview / user interface
|
||||||
|
Final, // Final to be rendered in the cel
|
||||||
|
};
|
||||||
|
|
||||||
TextEditor(Editor* editor, const Site& site, const gfx::Rect& bounds)
|
TextEditor(Editor* editor, const Site& site, const gfx::Rect& bounds)
|
||||||
: Entry(4096, "")
|
: Entry(4096, "")
|
||||||
, m_editor(editor)
|
, m_editor(editor)
|
||||||
|
@ -61,7 +92,7 @@ public:
|
||||||
setPersistSelection(true);
|
setPersistSelection(true);
|
||||||
|
|
||||||
createExtraCel(site, bounds);
|
createExtraCel(site, bounds);
|
||||||
renderExtraCelBase();
|
renderExtraCel(TextPreview::Intermediate);
|
||||||
|
|
||||||
FontInfo fontInfo = App::instance()->contextBar()->fontInfo();
|
FontInfo fontInfo = App::instance()->contextBar()->fontInfo();
|
||||||
if (auto font = Fonts::instance()->fontFromInfo(fontInfo))
|
if (auto font = Fonts::instance()->fontFromInfo(fontInfo))
|
||||||
|
@ -76,36 +107,37 @@ public:
|
||||||
|
|
||||||
// Returns the extra cel with the text rendered (but without the
|
// Returns the extra cel with the text rendered (but without the
|
||||||
// selected text highlighted).
|
// selected text highlighted).
|
||||||
ExtraCelRef extraCel()
|
ExtraCelRef extraCel(const TextPreview textPreview)
|
||||||
{
|
{
|
||||||
renderExtraCelBase();
|
renderExtraCel(textPreview);
|
||||||
renderExtraCelText(false);
|
|
||||||
return m_extraCel;
|
return m_extraCel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setExtraCelBounds(const gfx::Rect& bounds)
|
void setExtraCelBounds(const gfx::RectF& bounds)
|
||||||
{
|
{
|
||||||
doc::Image* extraImg = m_extraCel->image();
|
doc::Image* extraImg = m_extraCel->image();
|
||||||
if (!extraImg || bounds.w != extraImg->width() || bounds.h != extraImg->height()) {
|
if (!extraImg || std::ceil(bounds.w) != extraImg->width() ||
|
||||||
|
std::ceil(bounds.h) != extraImg->height()) {
|
||||||
createExtraCel(m_editor->getSite(), bounds);
|
createExtraCel(m_editor->getSite(), bounds);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
m_baseBounds = bounds;
|
||||||
m_extraCel->cel()->setBounds(bounds);
|
m_extraCel->cel()->setBounds(bounds);
|
||||||
}
|
}
|
||||||
renderExtraCelBase();
|
renderExtraCel(TextPreview::Intermediate);
|
||||||
renderExtraCelText(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obs::signal<void(const gfx::Size&)> NewRequiredBounds;
|
obs::signal<void(const gfx::RectF&)> NewRequiredBounds;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createExtraCel(const Site& site, const gfx::Rect& bounds)
|
void createExtraCel(const Site& site, const gfx::Rect& bounds)
|
||||||
{
|
{
|
||||||
|
m_baseBounds = bounds;
|
||||||
m_extraCel->create(ExtraCel::Purpose::TextPreview,
|
m_extraCel->create(ExtraCel::Purpose::TextPreview,
|
||||||
site.tilemapMode(),
|
site.tilemapMode(),
|
||||||
site.sprite(),
|
site.sprite(),
|
||||||
bounds,
|
bounds,
|
||||||
bounds.size(),
|
gfx::Size(std::ceil(bounds.w), std::ceil(bounds.h)),
|
||||||
site.frame(),
|
site.frame(),
|
||||||
255);
|
255);
|
||||||
|
|
||||||
|
@ -176,7 +208,7 @@ private:
|
||||||
|
|
||||||
// Notify that we could make the text editor bigger to show this
|
// Notify that we could make the text editor bigger to show this
|
||||||
// text blob.
|
// text blob.
|
||||||
NewRequiredBounds(get_text_blob_required_size(blob));
|
NewRequiredBounds(calc_blob_bounds(blob));
|
||||||
}
|
}
|
||||||
|
|
||||||
void onPaint(PaintEvent& ev) override
|
void onPaint(PaintEvent& ev) override
|
||||||
|
@ -205,8 +237,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render extra cel with text + selected text
|
// Render extra cel with text + selected text
|
||||||
renderExtraCelBase();
|
renderExtraCel(TextPreview::Intermediate);
|
||||||
renderExtraCelText(true);
|
|
||||||
m_doc->setExtraCel(m_extraCel);
|
m_doc->setExtraCel(m_extraCel);
|
||||||
|
|
||||||
// Paint caret
|
// Paint caret
|
||||||
|
@ -227,76 +258,80 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderExtraCelBase()
|
void renderExtraCel(const TextPreview textPreview)
|
||||||
{
|
{
|
||||||
doc::Image* extraImg = m_extraCel->image();
|
doc::Image* extraImg = m_extraCel->image();
|
||||||
ASSERT(extraImg);
|
ASSERT(extraImg);
|
||||||
if (!extraImg)
|
if (!extraImg)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const doc::Cel* extraCel = m_extraCel->cel();
|
extraImg->clear(extraImg->maskColor());
|
||||||
|
|
||||||
|
text::TextBlobRef blob = textBlob();
|
||||||
|
doc::ImageRef blobImage;
|
||||||
|
gfx::RectF bounds;
|
||||||
|
if (blob) {
|
||||||
|
const ui::Paint paint = get_paint_for_text();
|
||||||
|
bounds = calc_blob_bounds(blob);
|
||||||
|
blobImage = render_text_blob(blob, bounds, get_paint_for_text());
|
||||||
|
if (!blobImage)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Invert selected range in the image
|
||||||
|
if (textPreview == TextPreview::Intermediate) {
|
||||||
|
Range range;
|
||||||
|
getEntryThemeInfo(nullptr, nullptr, nullptr, &range);
|
||||||
|
if (!range.isEmpty()) {
|
||||||
|
gfx::RectF selectedBounds = getCharBoxBounds(range.from) | getCharBoxBounds(range.to - 1);
|
||||||
|
|
||||||
|
if (!selectedBounds.isEmpty()) {
|
||||||
|
selectedBounds.offset(-bounds.origin());
|
||||||
|
|
||||||
|
#ifdef LAF_SKIA
|
||||||
|
sk_sp<SkSurface> skSurface = wrap_docimage_in_sksurface(blobImage.get());
|
||||||
|
os::SurfaceRef surface = base::make_ref<os::SkiaSurface>(skSurface);
|
||||||
|
|
||||||
|
os::Paint paint2 = paint;
|
||||||
|
paint2.blendMode(os::BlendMode::Xor);
|
||||||
|
paint2.style(os::Paint::Style::Fill);
|
||||||
|
surface->drawRect(selectedBounds, paint2);
|
||||||
|
#endif // LAF_SKIA
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doc::Cel* extraCel = m_extraCel->cel();
|
||||||
ASSERT(extraCel);
|
ASSERT(extraCel);
|
||||||
if (!extraCel)
|
if (!extraCel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
extraImg->clear(extraImg->maskColor());
|
extraCel->setPosition(m_baseBounds.x + bounds.x, m_baseBounds.y + bounds.y);
|
||||||
|
|
||||||
render::Render().renderLayer(extraImg,
|
render::Render().renderLayer(extraImg,
|
||||||
m_editor->layer(),
|
m_editor->layer(),
|
||||||
m_editor->frame(),
|
m_editor->frame(),
|
||||||
gfx::Clip(0, 0, extraCel->bounds()),
|
gfx::Clip(0, 0, extraCel->bounds()),
|
||||||
doc::BlendMode::SRC);
|
doc::BlendMode::SRC);
|
||||||
}
|
|
||||||
|
|
||||||
void renderExtraCelText(const bool withSelection)
|
if (blobImage) {
|
||||||
{
|
doc::blend_image(extraImg,
|
||||||
const auto textColor = color_utils::color_for_image(Preferences::instance().colorBar.fgColor(),
|
blobImage.get(),
|
||||||
IMAGE_RGB);
|
gfx::Clip(blobImage->bounds().size()),
|
||||||
|
m_doc->sprite()->palette(m_editor->frame()),
|
||||||
text::TextBlobRef blob = textBlob();
|
255,
|
||||||
if (!blob)
|
doc::BlendMode::NORMAL);
|
||||||
return;
|
|
||||||
|
|
||||||
doc::ImageRef image = render_text_blob(blob, textColor);
|
|
||||||
if (!image)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Invert selected range in the image
|
|
||||||
if (withSelection) {
|
|
||||||
Range range;
|
|
||||||
getEntryThemeInfo(nullptr, nullptr, nullptr, &range);
|
|
||||||
if (!range.isEmpty()) {
|
|
||||||
gfx::RectF selectedBounds = getCharBoxBounds(range.from) | getCharBoxBounds(range.to - 1);
|
|
||||||
|
|
||||||
if (!selectedBounds.isEmpty()) {
|
|
||||||
#ifdef LAF_SKIA
|
|
||||||
sk_sp<SkSurface> skSurface = wrap_docimage_in_sksurface(image.get());
|
|
||||||
os::SurfaceRef surface = base::make_ref<os::SkiaSurface>(skSurface);
|
|
||||||
|
|
||||||
os::Paint paint;
|
|
||||||
paint.blendMode(os::BlendMode::Xor);
|
|
||||||
paint.color(textColor);
|
|
||||||
surface->drawRect(selectedBounds, paint);
|
|
||||||
#endif // LAF_SKIA
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
doc::Image* extraImg = m_extraCel->image();
|
|
||||||
ASSERT(extraImg);
|
|
||||||
if (!extraImg)
|
|
||||||
return;
|
|
||||||
|
|
||||||
doc::blend_image(extraImg,
|
|
||||||
image.get(),
|
|
||||||
gfx::Clip(image->bounds().size()),
|
|
||||||
m_doc->sprite()->palette(m_editor->frame()),
|
|
||||||
255,
|
|
||||||
doc::BlendMode::NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor* m_editor;
|
Editor* m_editor;
|
||||||
Doc* m_doc;
|
Doc* m_doc;
|
||||||
ExtraCelRef m_extraCel;
|
ExtraCelRef m_extraCel;
|
||||||
|
|
||||||
|
// Initial bounds for the entry field. This can be modified later to
|
||||||
|
// render the text in case some initial letter/glyph needs some
|
||||||
|
// extra room at the left side.
|
||||||
|
gfx::Rect m_baseBounds;
|
||||||
};
|
};
|
||||||
|
|
||||||
WritingTextState::WritingTextState(Editor* editor, const gfx::Rect& bounds)
|
WritingTextState::WritingTextState(Editor* editor, const gfx::Rect& bounds)
|
||||||
|
@ -312,10 +347,10 @@ WritingTextState::WritingTextState(Editor* editor, const gfx::Rect& bounds)
|
||||||
m_fontChangeConn =
|
m_fontChangeConn =
|
||||||
App::instance()->contextBar()->FontChange.connect(&WritingTextState::onFontChange, this);
|
App::instance()->contextBar()->FontChange.connect(&WritingTextState::onFontChange, this);
|
||||||
|
|
||||||
m_entry->NewRequiredBounds.connect([this](const gfx::Size& blobSize) {
|
m_entry->NewRequiredBounds.connect([this](const gfx::RectF& blobBounds) {
|
||||||
if (m_bounds.w < blobSize.w || m_bounds.h < blobSize.h) {
|
if (m_bounds.w < blobBounds.w || m_bounds.h < blobBounds.h) {
|
||||||
m_bounds.w = std::max(m_bounds.w, blobSize.w);
|
m_bounds.w = std::max(m_bounds.w, blobBounds.w);
|
||||||
m_bounds.h = std::max(m_bounds.h, blobSize.h);
|
m_bounds.h = std::max(m_bounds.h, blobBounds.h);
|
||||||
m_entry->setExtraCelBounds(m_bounds);
|
m_entry->setExtraCelBounds(m_bounds);
|
||||||
m_entry->setBounds(calcEntryBounds());
|
m_entry->setBounds(calcEntryBounds());
|
||||||
}
|
}
|
||||||
|
@ -388,11 +423,11 @@ void WritingTextState::onCommitMouseMove(Editor* editor, const gfx::PointF& spri
|
||||||
if (!m_movingBounds)
|
if (!m_movingBounds)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gfx::Point delta(spritePos - m_cursorStart);
|
gfx::PointF delta(spritePos - m_cursorStart);
|
||||||
if (delta.x == 0 && delta.y == 0)
|
if (delta.x == 0 && delta.y == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_bounds.setOrigin(gfx::Point(delta + m_boundsOrigin));
|
m_bounds.setOrigin(delta + m_boundsOrigin);
|
||||||
m_entry->setExtraCelBounds(m_bounds);
|
m_entry->setExtraCelBounds(m_bounds);
|
||||||
m_entry->setBounds(calcEntryBounds());
|
m_entry->setBounds(calcEntryBounds());
|
||||||
}
|
}
|
||||||
|
@ -475,8 +510,8 @@ EditorState::LeaveAction WritingTextState::onLeaveState(Editor* editor, EditorSt
|
||||||
// Paints the text in the active layer/sprite creating an
|
// Paints the text in the active layer/sprite creating an
|
||||||
// undoable transaction.
|
// undoable transaction.
|
||||||
Site site = m_editor->getSite();
|
Site site = m_editor->getSite();
|
||||||
ExtraCelRef extraCel = m_entry->extraCel();
|
ExtraCelRef extraCel = m_entry->extraCel(TextEditor::Final);
|
||||||
Tx tx(site.document(), "Text Tool");
|
Tx tx(site.document(), Strings::tools_text());
|
||||||
ExpandCelCanvas expand(site, site.layer(), TiledMode::NONE, tx, ExpandCelCanvas::None);
|
ExpandCelCanvas expand(site, site.layer(), TiledMode::NONE, tx, ExpandCelCanvas::None);
|
||||||
|
|
||||||
expand.validateDestCanvas(gfx::Region(extraCel->cel()->bounds()));
|
expand.validateDestCanvas(gfx::Region(extraCel->cel()->bounds()));
|
||||||
|
@ -527,7 +562,7 @@ void WritingTextState::onFontChange(const FontInfo& fontInfo, FontEntry::From fr
|
||||||
|
|
||||||
// This is useful to show changes to the anti-alias option
|
// This is useful to show changes to the anti-alias option
|
||||||
// immediately.
|
// immediately.
|
||||||
auto dummy = m_entry->extraCel();
|
auto dummy = m_entry->extraCel(TextEditor::Intermediate);
|
||||||
|
|
||||||
if (fromField == FontEntry::From::Popup) {
|
if (fromField == FontEntry::From::Popup) {
|
||||||
if (m_entry)
|
if (m_entry)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (c) 2022-2024 Igara Studio S.A.
|
// Copyright (c) 2022-2025 Igara Studio S.A.
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
|
@ -59,7 +59,7 @@ private:
|
||||||
|
|
||||||
DelayedMouseMove m_delayedMouseMove;
|
DelayedMouseMove m_delayedMouseMove;
|
||||||
Editor* m_editor;
|
Editor* m_editor;
|
||||||
gfx::Rect m_bounds;
|
gfx::RectF m_bounds;
|
||||||
std::unique_ptr<TextEditor> m_entry;
|
std::unique_ptr<TextEditor> m_entry;
|
||||||
|
|
||||||
// True if the text was discarded.
|
// True if the text was discarded.
|
||||||
|
@ -71,7 +71,7 @@ private:
|
||||||
bool m_mouseMoveReceived = false;
|
bool m_mouseMoveReceived = false;
|
||||||
bool m_movingBounds = false;
|
bool m_movingBounds = false;
|
||||||
gfx::PointF m_cursorStart;
|
gfx::PointF m_cursorStart;
|
||||||
gfx::Point m_boundsOrigin;
|
gfx::PointF m_boundsOrigin;
|
||||||
|
|
||||||
obs::scoped_connection m_beforeCmdConn;
|
obs::scoped_connection m_beforeCmdConn;
|
||||||
obs::scoped_connection m_fontChangeConn;
|
obs::scoped_connection m_fontChangeConn;
|
||||||
|
|
|
@ -45,6 +45,7 @@ FileList::FileList()
|
||||||
, m_multiselect(false)
|
, m_multiselect(false)
|
||||||
, m_zoom(1.0)
|
, m_zoom(1.0)
|
||||||
, m_itemsPerRow(0)
|
, m_itemsPerRow(0)
|
||||||
|
, m_showHidden(Preferences::instance().fileSelector.showHidden())
|
||||||
{
|
{
|
||||||
setFocusStop(true);
|
setFocusStop(true);
|
||||||
setDoubleBuffered(true);
|
setDoubleBuffered(true);
|
||||||
|
@ -173,6 +174,14 @@ void FileList::animateToZoom(const double zoom)
|
||||||
startAnimation(ANI_ZOOM, 10);
|
startAnimation(ANI_ZOOM, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileList::setShowHidden(const bool show)
|
||||||
|
{
|
||||||
|
m_showHidden = show;
|
||||||
|
m_req_valid = false;
|
||||||
|
m_selected = nullptr;
|
||||||
|
regenerateList();
|
||||||
|
}
|
||||||
|
|
||||||
bool FileList::onProcessMessage(Message* msg)
|
bool FileList::onProcessMessage(Message* msg)
|
||||||
{
|
{
|
||||||
switch (msg->type()) {
|
switch (msg->type()) {
|
||||||
|
@ -825,7 +834,7 @@ void FileList::regenerateList()
|
||||||
for (FileItemList::iterator it = m_list.begin(); it != m_list.end();) {
|
for (FileItemList::iterator it = m_list.begin(); it != m_list.end();) {
|
||||||
IFileItem* fileitem = *it;
|
IFileItem* fileitem = *it;
|
||||||
|
|
||||||
if (fileitem->isHidden())
|
if (fileitem->isHidden() && !m_showHidden)
|
||||||
it = m_list.erase(it);
|
it = m_list.erase(it);
|
||||||
else if (!fileitem->isFolder() && !fileitem->hasExtension(m_exts)) {
|
else if (!fileitem->isFolder() && !fileitem->hasExtension(m_exts)) {
|
||||||
it = m_list.erase(it);
|
it = m_list.erase(it);
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
double zoom() const { return m_zoom; }
|
double zoom() const { return m_zoom; }
|
||||||
void setZoom(const double zoom);
|
void setZoom(const double zoom);
|
||||||
void animateToZoom(const double zoom);
|
void animateToZoom(const double zoom);
|
||||||
|
void setShowHidden(const bool show);
|
||||||
|
|
||||||
obs::signal<void()> FileSelected;
|
obs::signal<void()> FileSelected;
|
||||||
obs::signal<void()> FileAccepted;
|
obs::signal<void()> FileAccepted;
|
||||||
|
@ -137,6 +138,7 @@ private:
|
||||||
double m_toZoom;
|
double m_toZoom;
|
||||||
|
|
||||||
int m_itemsPerRow;
|
int m_itemsPerRow;
|
||||||
|
bool m_showHidden;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
|
@ -316,6 +316,7 @@ FileSelector::FileSelector(FileSelectorType type) : m_type(type), m_navigationLo
|
||||||
for (auto child : viewType()->children())
|
for (auto child : viewType()->children())
|
||||||
child->setFocusStop(false);
|
child->setFocusStop(false);
|
||||||
|
|
||||||
|
showHiddenCheck()->setSelected(Preferences::instance().fileSelector.showHidden());
|
||||||
m_fileList = new FileList();
|
m_fileList = new FileList();
|
||||||
m_fileList->setId("fileview");
|
m_fileList->setId("fileview");
|
||||||
m_fileName->setAssociatedFileList(m_fileList);
|
m_fileName->setAssociatedFileList(m_fileList);
|
||||||
|
@ -334,6 +335,10 @@ FileSelector::FileSelector(FileSelectorType type) : m_type(type), m_navigationLo
|
||||||
viewType()->ItemChange.connect([this] { onChangeViewType(); });
|
viewType()->ItemChange.connect([this] { onChangeViewType(); });
|
||||||
location()->CloseListBox.connect([this] { onLocationCloseListBox(); });
|
location()->CloseListBox.connect([this] { onLocationCloseListBox(); });
|
||||||
fileType()->Change.connect([this] { onFileTypeChange(); });
|
fileType()->Change.connect([this] { onFileTypeChange(); });
|
||||||
|
showHiddenCheck()->Click.connect([this] {
|
||||||
|
Preferences::instance().fileSelector.showHidden(showHiddenCheck()->isSelected());
|
||||||
|
m_fileList->setShowHidden(showHiddenCheck()->isSelected());
|
||||||
|
});
|
||||||
m_fileList->FileSelected.connect([this] { onFileListFileSelected(); });
|
m_fileList->FileSelected.connect([this] { onFileListFileSelected(); });
|
||||||
m_fileList->FileAccepted.connect([this] { onFileListFileAccepted(); });
|
m_fileList->FileAccepted.connect([this] { onFileListFileAccepted(); });
|
||||||
m_fileList->CurrentFolderChanged.connect([this] { onFileListCurrentFolderChanged(); });
|
m_fileList->CurrentFolderChanged.connect([this] { onFileListCurrentFolderChanged(); });
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
// Copyright (C) 2019-2025 Igara Studio S.A.
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
|
@ -10,8 +10,10 @@
|
||||||
|
|
||||||
#include "app/ui/filename_field.h"
|
#include "app/ui/filename_field.h"
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
#include "app/i18n/strings.h"
|
#include "app/i18n/strings.h"
|
||||||
#include "app/pref/preferences.h"
|
#include "app/pref/preferences.h"
|
||||||
|
#include "app/recent_files.h"
|
||||||
#include "app/ui/skin/skin_theme.h"
|
#include "app/ui/skin/skin_theme.h"
|
||||||
#include "base/fs.h"
|
#include "base/fs.h"
|
||||||
#include "ui/box.h"
|
#include "ui/box.h"
|
||||||
|
@ -24,6 +26,11 @@ namespace app {
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
|
FilenameField::FilenameButton::FilenameButton(const std::string& text) : ButtonSet(1)
|
||||||
|
{
|
||||||
|
addItem(text);
|
||||||
|
}
|
||||||
|
|
||||||
FilenameField::FilenameField(const Type type, const std::string& pathAndFilename)
|
FilenameField::FilenameField(const Type type, const std::string& pathAndFilename)
|
||||||
: m_entry(type == EntryAndButton ? new ui::Entry(1024, "") : nullptr)
|
: m_entry(type == EntryAndButton ? new ui::Entry(1024, "") : nullptr)
|
||||||
, m_button(type == EntryAndButton ? Strings::select_file_browse() : Strings::select_file_text())
|
, m_button(type == EntryAndButton ? Strings::select_file_browse() : Strings::select_file_text())
|
||||||
|
@ -46,7 +53,10 @@ FilenameField::FilenameField(const Type type, const std::string& pathAndFilename
|
||||||
if (m_entry)
|
if (m_entry)
|
||||||
m_entry->Change.connect([this] { setFilename(updatedFilename()); });
|
m_entry->Change.connect([this] { setFilename(updatedFilename()); });
|
||||||
|
|
||||||
m_button.Click.connect([this] { onBrowse(); });
|
m_button.ItemChange.connect([this](ButtonSet::Item* item) {
|
||||||
|
m_button.setSelectedItem(nullptr);
|
||||||
|
onBrowse();
|
||||||
|
});
|
||||||
initTheme();
|
initTheme();
|
||||||
|
|
||||||
m_editFullPathChangeConn = Preferences::instance().general.editFullPath.AfterChange.connect(
|
m_editFullPathChangeConn = Preferences::instance().general.editFullPath.AfterChange.connect(
|
||||||
|
@ -94,7 +104,6 @@ void FilenameField::onSetEditFullPath()
|
||||||
void FilenameField::onBrowse()
|
void FilenameField::onBrowse()
|
||||||
{
|
{
|
||||||
const gfx::Rect bounds = m_button.bounds();
|
const gfx::Rect bounds = m_button.bounds();
|
||||||
m_button.setSelected(false);
|
|
||||||
|
|
||||||
ui::Menu menu;
|
ui::Menu menu;
|
||||||
ui::MenuItem choose(Strings::select_file_choose());
|
ui::MenuItem choose(Strings::select_file_choose());
|
||||||
|
@ -107,6 +116,11 @@ void FilenameField::onBrowse()
|
||||||
menu.addChild(&relative);
|
menu.addChild(&relative);
|
||||||
menu.addChild(&absolute);
|
menu.addChild(&absolute);
|
||||||
|
|
||||||
|
if (auto* recent = App::instance()->recentFiles()) {
|
||||||
|
addFoldersToMenu(&menu, recent->pinnedFolders(), Strings::file_selector_pinned_folders());
|
||||||
|
addFoldersToMenu(&menu, recent->recentFolders(), Strings::file_selector_recent_folders());
|
||||||
|
}
|
||||||
|
|
||||||
choose.Click.connect([this] {
|
choose.Click.connect([this] {
|
||||||
std::string fn = SelectOutputFile();
|
std::string fn = SelectOutputFile();
|
||||||
if (!fn.empty()) {
|
if (!fn.empty()) {
|
||||||
|
@ -120,6 +134,21 @@ void FilenameField::onBrowse()
|
||||||
menu.showPopup(gfx::Point(bounds.x, bounds.y2()), display());
|
menu.showPopup(gfx::Point(bounds.x, bounds.y2()), display());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FilenameField::addFoldersToMenu(ui::Menu* menu,
|
||||||
|
const base::paths& folders,
|
||||||
|
const std::string& separatorTitle)
|
||||||
|
{
|
||||||
|
if (folders.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
menu->addChild(new ui::Separator(separatorTitle, ui::HORIZONTAL));
|
||||||
|
for (const std::string& folder : folders) {
|
||||||
|
MenuItem* folderItem = new MenuItem(folder);
|
||||||
|
folderItem->Click.connect([this, folder] { setFilename(base::join_path(folder, m_file)); });
|
||||||
|
menu->addChild(folderItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FilenameField::setFilename(const std::string& pathAndFilename)
|
void FilenameField::setFilename(const std::string& pathAndFilename)
|
||||||
{
|
{
|
||||||
const std::string spritePath = base::get_file_path(m_docFilename);
|
const std::string spritePath = base::get_file_path(m_docFilename);
|
||||||
|
@ -164,11 +193,6 @@ void FilenameField::onInitTheme(ui::InitThemeEvent& ev)
|
||||||
{
|
{
|
||||||
HBox::onInitTheme(ev);
|
HBox::onInitTheme(ev);
|
||||||
setChildSpacing(0);
|
setChildSpacing(0);
|
||||||
|
|
||||||
auto theme = skin::SkinTheme::get(this);
|
|
||||||
ui::Style* style = theme->styles.miniButton();
|
|
||||||
if (style)
|
|
||||||
m_button.setStyle(style);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilenameField::onUpdateText()
|
void FilenameField::onUpdateText()
|
||||||
|
@ -181,9 +205,9 @@ void FilenameField::updateWidgets()
|
||||||
if (m_entry)
|
if (m_entry)
|
||||||
m_entry->setText(displayedFilename());
|
m_entry->setText(displayedFilename());
|
||||||
else if (m_file.empty())
|
else if (m_file.empty())
|
||||||
m_button.setText(Strings::select_file_text());
|
m_button.getItem(0)->setText(Strings::select_file_text());
|
||||||
else
|
else
|
||||||
m_button.setText(displayedFilename());
|
m_button.getItem(0)->setText(displayedFilename());
|
||||||
|
|
||||||
Change();
|
Change();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019 Igara Studio S.A.
|
// Copyright (C) 2019-2025 Igara Studio S.A.
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
|
@ -8,14 +8,19 @@
|
||||||
#define APP_UI_FILENAME_FIELD_H_INCLUDED
|
#define APP_UI_FILENAME_FIELD_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "app/ui/button_set.h"
|
||||||
|
#include "base/paths.h"
|
||||||
#include "obs/connection.h"
|
#include "obs/connection.h"
|
||||||
#include "obs/signal.h"
|
#include "obs/signal.h"
|
||||||
#include "ui/box.h"
|
#include "ui/box.h"
|
||||||
#include "ui/button.h"
|
|
||||||
#include "ui/entry.h"
|
#include "ui/entry.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace ui {
|
||||||
|
class Menu;
|
||||||
|
}
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class FilenameField : public ui::HBox {
|
class FilenameField : public ui::HBox {
|
||||||
|
@ -44,17 +49,25 @@ protected:
|
||||||
void onSetEditFullPath();
|
void onSetEditFullPath();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class FilenameButton : public ButtonSet {
|
||||||
|
public:
|
||||||
|
FilenameButton(const std::string& text);
|
||||||
|
};
|
||||||
|
|
||||||
void setEditFullPath(const bool on);
|
void setEditFullPath(const bool on);
|
||||||
void updateWidgets();
|
void updateWidgets();
|
||||||
void onBrowse();
|
void onBrowse();
|
||||||
std::string updatedFilename() const;
|
std::string updatedFilename() const;
|
||||||
|
void addFoldersToMenu(ui::Menu* menu,
|
||||||
|
const base::paths& folders,
|
||||||
|
const std::string& separatorTitle);
|
||||||
|
|
||||||
std::string m_path;
|
std::string m_path;
|
||||||
std::string m_pathBase;
|
std::string m_pathBase;
|
||||||
std::string m_file;
|
std::string m_file;
|
||||||
std::string m_docFilename;
|
std::string m_docFilename;
|
||||||
ui::Entry* m_entry;
|
ui::Entry* m_entry;
|
||||||
ui::Button m_button;
|
FilenameButton m_button;
|
||||||
bool m_editFullPath;
|
bool m_editFullPath;
|
||||||
bool m_askOverwrite;
|
bool m_askOverwrite;
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/console.h"
|
#include "app/console.h"
|
||||||
|
#include "app/i18n/strings.h"
|
||||||
#include "app/recent_files.h"
|
#include "app/recent_files.h"
|
||||||
#include "app/ui/font_popup.h"
|
#include "app/ui/font_popup.h"
|
||||||
#include "app/ui/skin/skin_theme.h"
|
#include "app/ui/skin/skin_theme.h"
|
||||||
#include "base/contains.h"
|
#include "base/contains.h"
|
||||||
|
#include "base/convert_to.h"
|
||||||
#include "base/scoped_value.h"
|
#include "base/scoped_value.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include "ui/display.h"
|
#include "ui/display.h"
|
||||||
|
@ -262,22 +264,91 @@ void FontEntry::FontSize::onEntryChange()
|
||||||
Change();
|
Change();
|
||||||
}
|
}
|
||||||
|
|
||||||
FontEntry::FontStyle::FontStyle() : ButtonSet(3, true)
|
FontEntry::FontStyle::FontStyle(ui::TooltipManager* tooltips) : ButtonSet(3, true)
|
||||||
{
|
{
|
||||||
addItem("B");
|
addItem("B");
|
||||||
addItem("I");
|
addItem("I");
|
||||||
addItem("...");
|
addItem("...");
|
||||||
setMultiMode(MultiMode::Set);
|
setMultiMode(MultiMode::Set);
|
||||||
|
|
||||||
|
tooltips->addTooltipFor(getItem(0), Strings::text_tool_bold(), BOTTOM);
|
||||||
|
tooltips->addTooltipFor(getItem(1), Strings::text_tool_italic(), BOTTOM);
|
||||||
|
tooltips->addTooltipFor(getItem(2), Strings::text_tool_more_options(), BOTTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontEntry::FontEntry()
|
FontEntry::FontStroke::FontStroke(ui::TooltipManager* tooltips) : m_fill(2)
|
||||||
|
{
|
||||||
|
auto* theme = skin::SkinTheme::get(this);
|
||||||
|
|
||||||
|
m_fill.addItem(theme->parts.toolFilledRectangle(), theme->styles.contextBarButton());
|
||||||
|
m_fill.addItem(theme->parts.toolRectangle(), theme->styles.contextBarButton());
|
||||||
|
m_fill.setSelectedItem(0);
|
||||||
|
m_fill.ItemChange.connect([this] { Change(); });
|
||||||
|
|
||||||
|
m_stroke.setText("0");
|
||||||
|
m_stroke.setSuffix("pt");
|
||||||
|
m_stroke.ValueChange.connect([this] { Change(); });
|
||||||
|
|
||||||
|
addChild(&m_fill);
|
||||||
|
addChild(&m_stroke);
|
||||||
|
|
||||||
|
tooltips->addTooltipFor(m_fill.getItem(0), Strings::shape_fill(), BOTTOM);
|
||||||
|
tooltips->addTooltipFor(m_fill.getItem(1), Strings::shape_stroke(), BOTTOM);
|
||||||
|
tooltips->addTooltipFor(&m_stroke, Strings::shape_stroke_width(), BOTTOM);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FontEntry::FontStroke::fill() const
|
||||||
|
{
|
||||||
|
return const_cast<FontStroke*>(this)->m_fill.getItem(0)->isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
float FontEntry::FontStroke::stroke() const
|
||||||
|
{
|
||||||
|
return m_stroke.textDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
FontEntry::FontStroke::WidthEntry::WidthEntry() : ui::IntEntry(0, 100, this)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontEntry::FontStroke::WidthEntry::onValueChange()
|
||||||
|
{
|
||||||
|
ui::IntEntry::onValueChange();
|
||||||
|
ValueChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FontEntry::FontStroke::WidthEntry::onAcceptUnicodeChar(int unicodeChar)
|
||||||
|
{
|
||||||
|
return (IntEntry::onAcceptUnicodeChar(unicodeChar) || unicodeChar == '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string FontEntry::FontStroke::WidthEntry::onGetTextFromValue(int value)
|
||||||
|
{
|
||||||
|
return fmt::format("{:.1f}", value / 10.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int FontEntry::FontStroke::WidthEntry::onGetValueFromText(const std::string& text)
|
||||||
|
{
|
||||||
|
return int(10.0 * base::convert_to<double>(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
FontEntry::FontEntry(const bool withStrokeAndFill)
|
||||||
|
: m_style(&m_tooltips)
|
||||||
|
, m_stroke(withStrokeAndFill ? std::make_unique<FontStroke>(&m_tooltips) : nullptr)
|
||||||
{
|
{
|
||||||
m_face.setExpansive(true);
|
m_face.setExpansive(true);
|
||||||
m_size.setExpansive(false);
|
m_size.setExpansive(false);
|
||||||
m_style.setExpansive(false);
|
m_style.setExpansive(false);
|
||||||
|
|
||||||
|
addChild(&m_tooltips);
|
||||||
addChild(&m_face);
|
addChild(&m_face);
|
||||||
addChild(&m_size);
|
addChild(&m_size);
|
||||||
addChild(&m_style);
|
addChild(&m_style);
|
||||||
|
if (m_stroke)
|
||||||
|
addChild(m_stroke.get());
|
||||||
|
|
||||||
|
m_tooltips.addTooltipFor(&m_face, Strings::text_tool_font_family(), BOTTOM);
|
||||||
|
m_tooltips.addTooltipFor(m_size.getEntryWidget(), Strings::text_tool_font_size(), BOTTOM);
|
||||||
|
|
||||||
m_face.setMinSize(gfx::Size(128 * guiscale(), 0));
|
m_face.setMinSize(gfx::Size(128 * guiscale(), 0));
|
||||||
|
|
||||||
|
@ -299,6 +370,8 @@ FontEntry::FontEntry()
|
||||||
});
|
});
|
||||||
|
|
||||||
m_style.ItemChange.connect(&FontEntry::onStyleItemClick, this);
|
m_style.ItemChange.connect(&FontEntry::onStyleItemClick, this);
|
||||||
|
if (m_stroke)
|
||||||
|
m_stroke->Change.connect(&FontEntry::onStrokeChange, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defined here as FontPopup type is not fully defined in the header
|
// Defined here as FontPopup type is not fully defined in the header
|
||||||
|
@ -327,6 +400,29 @@ void FontEntry::setInfo(const FontInfo& info, const From fromField)
|
||||||
FontChange(m_info, fromField);
|
FontChange(m_info, fromField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui::Paint FontEntry::paint()
|
||||||
|
{
|
||||||
|
ui::Paint paint;
|
||||||
|
ui::Paint::Style style = ui::Paint::Fill;
|
||||||
|
|
||||||
|
if (m_stroke) {
|
||||||
|
const float stroke = m_stroke->stroke();
|
||||||
|
if (m_stroke->fill()) {
|
||||||
|
if (stroke > 0.0f) {
|
||||||
|
style = ui::Paint::StrokeAndFill;
|
||||||
|
paint.strokeWidth(stroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
style = ui::Paint::Stroke;
|
||||||
|
paint.strokeWidth(stroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
paint.style(style);
|
||||||
|
return paint;
|
||||||
|
}
|
||||||
|
|
||||||
void FontEntry::onStyleItemClick(ButtonSet::Item* item)
|
void FontEntry::onStyleItemClick(ButtonSet::Item* item)
|
||||||
{
|
{
|
||||||
text::FontStyle style = m_info.style();
|
text::FontStyle style = m_info.style();
|
||||||
|
@ -404,4 +500,9 @@ void FontEntry::onStyleItemClick(ButtonSet::Item* item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FontEntry::onStrokeChange()
|
||||||
|
{
|
||||||
|
FontChange(m_info, From::Paint);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
|
@ -14,7 +14,11 @@
|
||||||
#include "ui/box.h"
|
#include "ui/box.h"
|
||||||
#include "ui/button.h"
|
#include "ui/button.h"
|
||||||
#include "ui/combobox.h"
|
#include "ui/combobox.h"
|
||||||
|
#include "ui/int_entry.h"
|
||||||
|
#include "ui/paint.h"
|
||||||
|
#include "ui/tooltips.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
@ -30,18 +34,22 @@ public:
|
||||||
Flags,
|
Flags,
|
||||||
Hinting,
|
Hinting,
|
||||||
Popup,
|
Popup,
|
||||||
|
Paint,
|
||||||
};
|
};
|
||||||
|
|
||||||
FontEntry();
|
FontEntry(bool withStrokeAndFill);
|
||||||
~FontEntry();
|
~FontEntry();
|
||||||
|
|
||||||
FontInfo info() { return m_info; }
|
FontInfo info() { return m_info; }
|
||||||
void setInfo(const FontInfo& info, From from);
|
void setInfo(const FontInfo& info, From from);
|
||||||
|
|
||||||
|
ui::Paint paint();
|
||||||
|
|
||||||
obs::signal<void(const FontInfo&, From)> FontChange;
|
obs::signal<void(const FontInfo&, From)> FontChange;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onStyleItemClick(ButtonSet::Item* item);
|
void onStyleItemClick(ButtonSet::Item* item);
|
||||||
|
void onStrokeChange();
|
||||||
|
|
||||||
class FontFace : public SearchEntry {
|
class FontFace : public SearchEntry {
|
||||||
public:
|
public:
|
||||||
|
@ -73,13 +81,40 @@ private:
|
||||||
|
|
||||||
class FontStyle : public ButtonSet {
|
class FontStyle : public ButtonSet {
|
||||||
public:
|
public:
|
||||||
FontStyle();
|
FontStyle(ui::TooltipManager* tooltips);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FontStroke : public HBox {
|
||||||
|
public:
|
||||||
|
FontStroke(ui::TooltipManager* tooltips);
|
||||||
|
bool fill() const;
|
||||||
|
float stroke() const;
|
||||||
|
obs::signal<void()> Change;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class WidthEntry : public ui::IntEntry,
|
||||||
|
public ui::SliderDelegate {
|
||||||
|
public:
|
||||||
|
WidthEntry();
|
||||||
|
obs::signal<void()> ValueChange;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onValueChange() override;
|
||||||
|
bool onAcceptUnicodeChar(int unicodeChar) override;
|
||||||
|
// SliderDelegate impl
|
||||||
|
std::string onGetTextFromValue(int value) override;
|
||||||
|
int onGetValueFromText(const std::string& text) override;
|
||||||
|
};
|
||||||
|
ButtonSet m_fill;
|
||||||
|
WidthEntry m_stroke;
|
||||||
|
};
|
||||||
|
|
||||||
|
ui::TooltipManager m_tooltips;
|
||||||
FontInfo m_info;
|
FontInfo m_info;
|
||||||
FontFace m_face;
|
FontFace m_face;
|
||||||
FontSize m_size;
|
FontSize m_size;
|
||||||
FontStyle m_style;
|
FontStyle m_style;
|
||||||
|
std::unique_ptr<FontStroke> m_stroke;
|
||||||
bool m_lockFace = false;
|
bool m_lockFace = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,11 @@ private:
|
||||||
if (!blob)
|
if (!blob)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
doc::ImageRef image = render_text_blob(blob, gfx::rgba(0, 0, 0));
|
ui::Paint paint;
|
||||||
|
paint.color(gfx::rgba(0, 0, 0));
|
||||||
|
paint.style(ui::Paint::Fill);
|
||||||
|
const gfx::RectF textBounds = get_text_blob_required_bounds(blob);
|
||||||
|
doc::ImageRef image = render_text_blob(blob, textBounds, paint);
|
||||||
if (!image)
|
if (!image)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1350,6 +1350,7 @@ public:
|
||||||
, m_h(h)
|
, m_h(h)
|
||||||
{
|
{
|
||||||
m_widget->getEntryThemeInfo(&m_index, &m_caret, &m_state, &m_range);
|
m_widget->getEntryThemeInfo(&m_index, &m_caret, &m_state, &m_range);
|
||||||
|
m_suffixIndex = m_widget->text().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int index() const { return m_index; }
|
int index() const { return m_index; }
|
||||||
|
@ -1369,6 +1370,11 @@ public:
|
||||||
bg = ColorNone;
|
bg = ColorNone;
|
||||||
fg = colors.text();
|
fg = colors.text();
|
||||||
|
|
||||||
|
// Suffix text
|
||||||
|
if (m_index >= m_suffixIndex) {
|
||||||
|
fg = colors.entrySuffix();
|
||||||
|
}
|
||||||
|
|
||||||
// Selected
|
// Selected
|
||||||
if ((m_index >= m_range.from) && (m_index < m_range.to)) {
|
if ((m_index >= m_range.from) && (m_index < m_range.to)) {
|
||||||
if (m_widget->hasFocus())
|
if (m_widget->hasFocus())
|
||||||
|
@ -1433,6 +1439,7 @@ private:
|
||||||
int m_lastX; // Last position used to fill the background
|
int m_lastX; // Last position used to fill the background
|
||||||
int m_y, m_h;
|
int m_y, m_h;
|
||||||
int m_charStartX;
|
int m_charStartX;
|
||||||
|
int m_suffixIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
@ -1445,8 +1452,10 @@ void SkinTheme::drawEntryText(ui::Graphics* g, ui::Entry* widget)
|
||||||
DrawEntryTextDelegate delegate(widget, g, bounds.origin(), widget->textHeight());
|
DrawEntryTextDelegate delegate(widget, g, bounds.origin(), widget->textHeight());
|
||||||
int scroll = delegate.index();
|
int scroll = delegate.index();
|
||||||
|
|
||||||
if (!widget->text().empty()) {
|
// Full text to paint: widget text + suffix
|
||||||
const std::string& textString = widget->text();
|
const std::string textString = widget->text() + widget->getSuffix();
|
||||||
|
|
||||||
|
if (!textString.empty()) {
|
||||||
base::utf8_decode dec(textString);
|
base::utf8_decode dec(textString);
|
||||||
auto pos = dec.pos();
|
auto pos = dec.pos();
|
||||||
for (int i = 0; i < scroll && dec.next(); ++i)
|
for (int i = 0; i < scroll && dec.next(); ++i)
|
||||||
|
@ -1454,38 +1463,28 @@ void SkinTheme::drawEntryText(ui::Graphics* g, ui::Entry* widget)
|
||||||
|
|
||||||
IntersectClip clip(g, bounds);
|
IntersectClip clip(g, bounds);
|
||||||
if (clip) {
|
if (clip) {
|
||||||
g->drawTextWithDelegate(
|
int baselineAdjustment = widget->textBaseline();
|
||||||
std::string(pos, textString.end()), // TODO use a string_view()
|
if (auto blob = widget->textBlob()) {
|
||||||
colors.text(),
|
baselineAdjustment -= blob->baseline();
|
||||||
ColorNone,
|
}
|
||||||
gfx::Point(bounds.x, widget->textBaseline() - widget->textBlob()->baseline()),
|
else {
|
||||||
&delegate);
|
text::FontMetrics metrics;
|
||||||
}
|
widget->font()->metrics(&metrics);
|
||||||
}
|
baselineAdjustment += metrics.ascent;
|
||||||
|
}
|
||||||
|
|
||||||
bounds.x += delegate.textBounds().w;
|
g->drawTextWithDelegate(std::string(pos, textString.end()), // TODO use a string_view()
|
||||||
|
colors.text(),
|
||||||
// Draw suffix if there is enough space
|
ColorNone,
|
||||||
if (!widget->getSuffix().empty()) {
|
gfx::Point(bounds.x, baselineAdjustment),
|
||||||
Rect sufBounds(bounds.x,
|
&delegate);
|
||||||
bounds.y,
|
|
||||||
bounds.x2() - widget->childSpacing() - bounds.x,
|
|
||||||
widget->textHeight());
|
|
||||||
IntersectClip clip(g, sufBounds & widget->clientChildrenBounds());
|
|
||||||
if (clip) {
|
|
||||||
drawText(g,
|
|
||||||
widget->getSuffix().c_str(),
|
|
||||||
colors.entrySuffix(),
|
|
||||||
ColorNone,
|
|
||||||
widget,
|
|
||||||
sufBounds,
|
|
||||||
widget->align(),
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw caret at the end of the text
|
// Draw caret at the end of the text
|
||||||
if (!delegate.caretDrawn()) {
|
if (!delegate.caretDrawn()) {
|
||||||
|
bounds.x += delegate.textBounds().w;
|
||||||
|
|
||||||
gfx::Rect charBounds(bounds.x + widget->bounds().x,
|
gfx::Rect charBounds(bounds.x + widget->bounds().x,
|
||||||
bounds.y + widget->bounds().y,
|
bounds.y + widget->bounds().y,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (c) 2020-2024 Igara Studio S.A.
|
// Copyright (c) 2020-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
|
||||||
|
@ -250,6 +250,11 @@ void convert_image_to_surface(const doc::Image* image,
|
||||||
os::SurfaceLock lockDst(surface);
|
os::SurfaceLock lockDst(surface);
|
||||||
os::SurfaceFormatData fd;
|
os::SurfaceFormatData fd;
|
||||||
surface->getFormat(&fd);
|
surface->getFormat(&fd);
|
||||||
|
#if LAF_SKIA
|
||||||
|
// Needed because Skia surfaces work with premultiplied alpha and
|
||||||
|
// here we need to copy unpremultiplied alpha RGB values to the Skia surface.
|
||||||
|
((os::SkiaSurface*)surface)->bitmap().setAlphaType(kUnpremul_SkAlphaType);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (image->pixelFormat()) {
|
switch (image->pixelFormat()) {
|
||||||
case IMAGE_RGB:
|
case IMAGE_RGB:
|
||||||
|
|
|
@ -60,7 +60,7 @@ private:
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
gfx::Size get_text_blob_required_size(const text::TextBlobRef& blob)
|
gfx::RectF get_text_blob_required_bounds(const text::TextBlobRef& blob)
|
||||||
{
|
{
|
||||||
ASSERT(blob != nullptr);
|
ASSERT(blob != nullptr);
|
||||||
|
|
||||||
|
@ -74,32 +74,28 @@ gfx::Size get_text_blob_required_size(const text::TextBlobRef& blob)
|
||||||
bounds.w = 1;
|
bounds.w = 1;
|
||||||
if (bounds.h < 1)
|
if (bounds.h < 1)
|
||||||
bounds.h = 1;
|
bounds.h = 1;
|
||||||
return gfx::Size(std::ceil(bounds.w), std::ceil(bounds.h));
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc::ImageRef render_text_blob(const text::TextBlobRef& blob, gfx::Color color)
|
doc::ImageRef render_text_blob(const text::TextBlobRef& blob,
|
||||||
|
const gfx::RectF& textBounds,
|
||||||
|
const ui::Paint& paint)
|
||||||
{
|
{
|
||||||
ASSERT(blob != nullptr);
|
ASSERT(blob != nullptr);
|
||||||
|
|
||||||
os::Paint paint;
|
doc::ImageRef image(
|
||||||
// TODO offer Stroke, StrokeAndFill, and Fill styles
|
doc::Image::create(doc::IMAGE_RGB, std::ceil(textBounds.w), std::ceil(textBounds.h)));
|
||||||
paint.style(os::Paint::Fill);
|
|
||||||
paint.color(color);
|
|
||||||
|
|
||||||
gfx::Size blobSize = get_text_blob_required_size(blob);
|
|
||||||
|
|
||||||
doc::ImageRef image(doc::Image::create(doc::IMAGE_RGB, blobSize.w, blobSize.h));
|
|
||||||
|
|
||||||
#ifdef LAF_SKIA
|
#ifdef LAF_SKIA
|
||||||
sk_sp<SkSurface> skSurface = wrap_docimage_in_sksurface(image.get());
|
sk_sp<SkSurface> skSurface = wrap_docimage_in_sksurface(image.get());
|
||||||
os::SurfaceRef surface = base::make_ref<os::SkiaSurface>(skSurface);
|
os::SurfaceRef surface = base::make_ref<os::SkiaSurface>(skSurface);
|
||||||
text::draw_text(surface.get(), blob, gfx::PointF(0, 0), &paint);
|
text::draw_text(surface.get(), blob, -textBounds.origin(), &paint);
|
||||||
#endif // LAF_SKIA
|
#endif // LAF_SKIA
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc::ImageRef render_text(const FontInfo& fontInfo, const std::string& text, gfx::Color color)
|
doc::ImageRef render_text(const FontInfo& fontInfo, const std::string& text, const ui::Paint& paint)
|
||||||
{
|
{
|
||||||
Fonts* fonts = Fonts::instance();
|
Fonts* fonts = Fonts::instance();
|
||||||
ASSERT(fonts);
|
ASSERT(fonts);
|
||||||
|
@ -113,10 +109,6 @@ doc::ImageRef render_text(const FontInfo& fontInfo, const std::string& text, gfx
|
||||||
const text::FontMgrRef fontMgr = fonts->fontMgr();
|
const text::FontMgrRef fontMgr = fonts->fontMgr();
|
||||||
ASSERT(fontMgr);
|
ASSERT(fontMgr);
|
||||||
|
|
||||||
os::Paint paint;
|
|
||||||
paint.style(os::Paint::StrokeAndFill);
|
|
||||||
paint.color(color);
|
|
||||||
|
|
||||||
// We have to measure all text runs which might use different
|
// We have to measure all text runs which might use different
|
||||||
// fonts (e.g. if the given font is not enough to shape other code
|
// fonts (e.g. if the given font is not enough to shape other code
|
||||||
// points/languages).
|
// points/languages).
|
||||||
|
|
|
@ -11,25 +11,28 @@
|
||||||
|
|
||||||
#include "doc/image_ref.h"
|
#include "doc/image_ref.h"
|
||||||
#include "gfx/color.h"
|
#include "gfx/color.h"
|
||||||
|
#include "gfx/rect.h"
|
||||||
#include "text/text_blob.h"
|
#include "text/text_blob.h"
|
||||||
|
#include "ui/paint.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class Color;
|
|
||||||
class FontInfo;
|
class FontInfo;
|
||||||
namespace skin {
|
|
||||||
class SkinTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the exact bounds that are required to draw this TextBlob,
|
// Returns the exact bounds that are required to draw this TextBlob in
|
||||||
// i.e. the image size that will be required in render_text_blob().
|
// the origin point (0, 0), i.e. the image size that will be required
|
||||||
gfx::Size get_text_blob_required_size(const text::TextBlobRef& blob);
|
// in render_text_blob().
|
||||||
|
gfx::RectF get_text_blob_required_bounds(const text::TextBlobRef& blob);
|
||||||
|
|
||||||
doc::ImageRef render_text_blob(const text::TextBlobRef& blob, gfx::Color color);
|
doc::ImageRef render_text_blob(const text::TextBlobRef& blob,
|
||||||
|
const gfx::RectF& textBounds,
|
||||||
|
const ui::Paint& paint);
|
||||||
|
|
||||||
doc::ImageRef render_text(const FontInfo& fontInfo, const std::string& text, gfx::Color color);
|
doc::ImageRef render_text(const FontInfo& fontInfo,
|
||||||
|
const std::string& text,
|
||||||
|
const ui::Paint& paint);
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
@ -257,11 +257,9 @@ Widget* WidgetLoader::convertXmlElementToWidget(const XMLElement* elem,
|
||||||
((ExprEntry*)widget)->setDecimals(strtol(decimals, nullptr, 10));
|
((ExprEntry*)widget)->setDecimals(strtol(decimals, nullptr, 10));
|
||||||
}
|
}
|
||||||
if (elem_name == "filename") {
|
if (elem_name == "filename") {
|
||||||
const char* button_only = elem->Attribute("button_only");
|
const bool buttononly = bool_attr(elem, "buttononly", false);
|
||||||
const app::FilenameField::Type type = ((button_only != nullptr &&
|
const app::FilenameField::Type type = (buttononly ? app::FilenameField::Type::ButtonOnly :
|
||||||
strtol(button_only, nullptr, 10) == 1) ?
|
app::FilenameField::Type::EntryAndButton);
|
||||||
app::FilenameField::Type::ButtonOnly :
|
|
||||||
app::FilenameField::Type::EntryAndButton);
|
|
||||||
|
|
||||||
widget = new app::FilenameField(type, "");
|
widget = new app::FilenameField(type, "");
|
||||||
}
|
}
|
||||||
|
@ -534,7 +532,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const XMLElement* elem,
|
||||||
}
|
}
|
||||||
else if (elem_name == "font") {
|
else if (elem_name == "font") {
|
||||||
if (!widget)
|
if (!widget)
|
||||||
widget = new FontEntry;
|
widget = new FontEntry(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Was the widget created?
|
// Was the widget created?
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -106,7 +106,6 @@ void Box::onResize(ResizeEvent& ev)
|
||||||
continue; \
|
continue; \
|
||||||
\
|
\
|
||||||
int size = 0; \
|
int size = 0; \
|
||||||
int sizeDiff = 0; \
|
|
||||||
\
|
\
|
||||||
if (align() & HOMOGENEOUS) { \
|
if (align() & HOMOGENEOUS) { \
|
||||||
if (i < visibleChildren - 1) \
|
if (i < visibleChildren - 1) \
|
||||||
|
|
|
@ -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()->setTranslateDeadKeys(true);
|
os::System::instance()->setTextInput(true, caretPosOnScreen());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kFocusLeaveMessage:
|
case kFocusLeaveMessage:
|
||||||
|
@ -304,7 +316,7 @@ bool Entry::onProcessMessage(Message* msg)
|
||||||
|
|
||||||
// Stop processing dead keys
|
// Stop processing dead keys
|
||||||
if (m_translate_dead_keys)
|
if (m_translate_dead_keys)
|
||||||
os::System::instance()->setTranslateDeadKeys(false);
|
os::System::instance()->setTextInput(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kKeyDownMessage:
|
case kKeyDownMessage:
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -115,8 +115,8 @@ bool IntEntry::onProcessMessage(Message* msg)
|
||||||
case kKeyDownMessage:
|
case kKeyDownMessage:
|
||||||
if (hasFocus() && !isReadOnly()) {
|
if (hasFocus() && !isReadOnly()) {
|
||||||
KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
|
KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
|
||||||
int chr = keymsg->unicodeChar();
|
const int chr = keymsg->unicodeChar();
|
||||||
if (chr >= 32 && (chr < '0' || chr > '9')) {
|
if (chr >= 32 && !onAcceptUnicodeChar(chr)) {
|
||||||
// "Eat" all keys that aren't number
|
// "Eat" all keys that aren't number
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,11 @@ void IntEntry::onValueChange()
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IntEntry::onAcceptUnicodeChar(const int unicodeChar)
|
||||||
|
{
|
||||||
|
return (unicodeChar >= '0' && unicodeChar <= '9');
|
||||||
|
}
|
||||||
|
|
||||||
void IntEntry::openPopup()
|
void IntEntry::openPopup()
|
||||||
{
|
{
|
||||||
m_slider->setValue(getValue());
|
m_slider->setValue(getValue());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2022 Igara Studio S.A.
|
// Copyright (C) 2022-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
|
@ -36,6 +36,7 @@ protected:
|
||||||
|
|
||||||
// New events
|
// New events
|
||||||
virtual void onValueChange();
|
virtual void onValueChange();
|
||||||
|
virtual bool onAcceptUnicodeChar(int unicodeChar);
|
||||||
|
|
||||||
int m_min;
|
int m_min;
|
||||||
int m_max;
|
int m_max;
|
||||||
|
|
|
@ -515,37 +515,39 @@ void Theme::paintLayer(Graphics* g,
|
||||||
if (!textBlob || style->font() != nullptr)
|
if (!textBlob || style->font() != nullptr)
|
||||||
textBlob = text::TextBlob::MakeWithShaper(m_fontMgr, g->font(), text);
|
textBlob = text::TextBlob::MakeWithShaper(m_fontMgr, g->font(), text);
|
||||||
|
|
||||||
const gfx::RectF blobSize = textBlob->bounds();
|
if (textBlob) {
|
||||||
const gfx::Border padding = style->padding();
|
const gfx::RectF blobSize = textBlob->bounds();
|
||||||
gfx::PointF pt;
|
const gfx::Border padding = style->padding();
|
||||||
|
gfx::PointF pt;
|
||||||
|
|
||||||
if (layer.align() & LEFT)
|
if (layer.align() & LEFT)
|
||||||
pt.x = rc.x + padding.left();
|
pt.x = rc.x + padding.left();
|
||||||
else if (layer.align() & RIGHT)
|
else if (layer.align() & RIGHT)
|
||||||
pt.x = rc.x + rc.w - blobSize.w - padding.right();
|
pt.x = rc.x + rc.w - blobSize.w - padding.right();
|
||||||
else
|
else
|
||||||
pt.x = guiscaled_center(rc.x + padding.left(), rc.w - padding.width(), blobSize.w);
|
pt.x = guiscaled_center(rc.x + padding.left(), rc.w - padding.width(), blobSize.w);
|
||||||
|
|
||||||
if (layer.align() & TOP)
|
if (layer.align() & TOP)
|
||||||
pt.y = rc.y + padding.top();
|
pt.y = rc.y + padding.top();
|
||||||
else if (layer.align() & BOTTOM)
|
else if (layer.align() & BOTTOM)
|
||||||
pt.y = rc.y + rc.h - blobSize.h - padding.bottom();
|
pt.y = rc.y + rc.h - blobSize.h - padding.bottom();
|
||||||
else
|
else
|
||||||
pt.y = baseline - textBlob->baseline();
|
pt.y = baseline - textBlob->baseline();
|
||||||
|
|
||||||
pt += layer.offset();
|
pt += layer.offset();
|
||||||
|
|
||||||
Paint paint;
|
Paint paint;
|
||||||
if (gfx::geta(bgColor) > 0) { // Paint background
|
if (gfx::geta(bgColor) > 0) { // Paint background
|
||||||
paint.color(bgColor);
|
paint.color(bgColor);
|
||||||
paint.style(os::Paint::Fill);
|
paint.style(os::Paint::Fill);
|
||||||
g->drawRect(gfx::RectF(textBlob->bounds()).offset(pt), paint);
|
g->drawRect(gfx::RectF(textBlob->bounds()).offset(pt), paint);
|
||||||
|
}
|
||||||
|
paint.color(layer.color());
|
||||||
|
g->drawTextBlob(textBlob, gfx::PointF(pt), paint);
|
||||||
|
|
||||||
|
if (style->mnemonics() && mnemonic != 0)
|
||||||
|
drawMnemonicUnderline(g, text, textBlob, pt, mnemonic, paint);
|
||||||
}
|
}
|
||||||
paint.color(layer.color());
|
|
||||||
g->drawTextBlob(textBlob, gfx::PointF(pt), paint);
|
|
||||||
|
|
||||||
if (style->mnemonics() && mnemonic != 0)
|
|
||||||
drawMnemonicUnderline(g, text, textBlob, pt, mnemonic, paint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style->font())
|
if (style->font())
|
||||||
|
|
Loading…
Reference in New Issue