Commit Graph

235 Commits

Author SHA1 Message Date
David Capello c781d82cf6 Match text caret size with Entry widget 2025-10-07 11:08:41 -03:00
Christian Kaiser f3d36ca4c4 User data with multiple lines of text (new TextEdit widget) (#3130, #3131, #4743, #4968) 2025-10-07 08:06:47 -03:00
Christian Kaiser 27da1b03d0 Add placeholder property to Entry, default placeholder for SearchEntry 2025-09-04 10:37:48 -03:00
David Capello 2d87a7b184 [ui] Fix drawing cursor at the end of the Entry/Combobox field
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
Regression introduced in 1a6a39700e
2025-07-07 22:21:58 -03:00
David Capello 1a6a39700e Fix suffix separation in Entry fields w/TTF fonts (fix #5261) 2025-07-02 20:43:17 -03:00
David Capello b3b956516b Fix themes loading custom TTF fonts without specifying a size (fix #5229)
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-06-13 18:22:00 -03:00
David Capello 5ceeac2f26 Add possibility to disable hinting for theme ttf/otf fonts (fix #5215) 2025-06-11 17:20:17 -03:00
David Capello 0ddf7d939b [ui] Align text with different fonts correctly to ui::Entry baseline
Regression introduced in af6e8b65c3
2025-06-11 17:06:55 -03:00
David Capello af6e8b65c3 Fix default font for CJK and other translations (fix #5210)
Now we use the correct fallback font with its size for non-existent
glyph in the sprite sheet font.
2025-06-11 14:40:56 -03:00
David Capello 2bc4f0582d Fix crash (and show error message) when default font is nullptr (fix #5208)
build / build (Debug, macos-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, macos-latest, noscripts, cli) (push) Waiting to run Details
build / build (Debug, ubuntu-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, ubuntu-latest, noscripts, cli) (push) Waiting to run Details
build / build (Debug, windows-latest, lua, cli) (push) Waiting to run Details
build / build (Debug, windows-latest, noscripts, cli) (push) Waiting to run Details
build / build (RelWithDebInfo, macos-latest, lua, gui) (push) Waiting to run Details
build / build (RelWithDebInfo, ubuntu-latest, lua, gui) (push) Waiting to run Details
build / build (RelWithDebInfo, windows-latest, lua, gui) (push) Waiting to run Details
Probably an edge-case for users that are creating new themes.
2025-06-10 22:02:12 -03:00
David Capello 2b522e222b Rename ui::Accelerator to ui::Shortcut
This was a pending refactor, where "user.aseprite-keys" files were
already using the "shortcut" attribute (instead of "accelerator").
This will include a refactor in the Weblate projects/all translations
to change [select_accelerator] section to [select_shortcut]. But that
must be coordinated after this commit is merged.
2025-06-09 17:20:16 -03:00
David Capello 978000a9dd Better support to use system fonts from themes
* There is a new system="" attribute for <font> elements
* New <font><windows ... /><macos ... /><linux /></font> elements to
  select platform specific fonts
* Fixed several bugs related to re-using fonts from the cache when
  customizing the current theme font from Edit > Preferences > Theme
* Removed Fonts::infoFromFont() adding FontInfo(FontData) constructor
2025-04-17 19:43:32 -03:00
David Capello 816be744ac Add Widget::textBaseline() to fix several misalignments using scalable fonts
* Each widget can customize its text baseline (onGetTextBaseline()) to
  know where to draw text when it's vertically aligned to the middle
  (now more correctly "aligned to the baseline").
* Add PAINT_BASELINE to test where the baseline is on each widget.
* "Aseprite" and "Aseprite Mini" fonts now have a special
  descent/ascent configuration with a specific baseline position.
2025-03-27 18:22:51 -03:00
David Capello 50bccf85fc Add support to scale sprite sheet fonts
We've highlighted (with an "*") the sprite sheet font size, so it's
easy to select its default size.
2025-03-24 23:19:30 -03:00
David Capello 805d98e943 Fix font rendering issues in non-English languages (fix #4804)
Graphics::measureText() wasn't shaping text correctly using the
FontMgr to get more fonts when they were required. And now
SkinTheme::drawText() can use Widget::textSize() (the cached size of
the widget text blob) to calculate the required text size.
2025-03-13 16:20:11 -03:00
David Capello d3265a1711 Fix UI vs Screen Scaling bugs w/window buttons and button sets/grids (fix #5043)
Includes:
* New ui::Style::rawMargin/Border/Padding() to detect what values are
  undefined, and ui::Style::margin/border/padding() to return normalized
  values (replacing kUndefinedSide with 0 when a value is not defined in
  the whole hierarchy of styles). With this change we avoid using a
  margin/border/padding value of -1 by mistake.
* New guiscaled_div() to calculate an integer division taking care the
  guiscale() for a scaled value.
* CALC_FOR_CENTER() renamed to guiscaled_center() and moved to ui/scale.h

There are still a lot of work to be done to fully fix these UI issues
between Screen Scaling=200%/UI Scaling=100% vs Screen Scaling=100%/UI
Scaling=200%
2025-03-09 22:01:55 -03:00
David Capello c949f4a5a6 Centralize defined fonts in new app::Fonts class 2025-03-04 13:54:15 -03:00
David Capello 2706d2d75a Move font related types to src/app/fonts 2025-03-03 22:36:11 -03:00
David Capello da5909639b Use the new Surface::applyScale() 2025-03-03 16:42:03 -03:00
David Capello 28d31a0b41 Change background color of read-only ui::Entry fields 2025-02-26 09:13:38 -03:00
David Capello b7967a078e Select the default theme font when clicking custom font check boxes 2025-02-15 13:04:49 -03:00
David Capello d4406629e6 Add possibility to customize theme fonts (#712, #4307)
From Edit > Preferences > Themes we now can customize the theme Font
and Mini Font.
2025-02-15 12:58:25 -03:00
David Capello 09538f9a1a clang-format all files 2024-12-16 14:52:19 -03:00
David Capello ab599c5863 Simplify Font ptrs management in ui-lib returning FontRefs
We can return "const text::FontRef&" to avoid adding a new reference
to an existing FontRef just to access a Style/Widget font.
2024-11-30 09:38:04 -03:00
David Capello 7e780bf3bf Move Theme::fontMgr() impl from app-lib to ui-lib 2024-11-30 09:38:04 -03:00
David Capello 77dd92c679 Don't overlap search icon with text in SearchEntry 2024-10-28 15:32:41 -03:00
David Capello b547b96835 Paint caret in ui::Entry even when there is no text 2024-10-28 15:28:01 -03:00
David Capello f9d2f1ce46 Remove Graphics::measureUIText/Length() functions
With the introduction of Widget::processMnemonicFromText() in
17151cddcd we don't require these
functions anymore because the '&' character isn't not present in the
widget text (so we can just measure the text length as usual).

This was discovered in PR #4604:
https://github.com/aseprite/aseprite/pull/4604#discussion_r1731172284
2024-08-28 15:22:51 -03:00
David Capello 0bf9353a02 Add new Text tool (fix #28)
This is the first (not yet production-ready) version of the
interactive Text tool. The text input is done with a transparent
ui::Entry, and on each text modification an ExtraCel is rendered with
this same ui::Entry's TextBlob to be displayed in the canvas with the
active zoom level.

The ui::Entry is being painted along the text in the canvas (just for
testing), but this is something to be fixed. Probably it will not be
the case in the future and a fully customized rendering (onPaint())
process will be required.
2024-08-26 11:47:57 -03:00
David Capello cf514f0c53 New font selector (fix #4363)
This new font selector list installed fonts with its proper name. It
still needs some extra work to select font set styles (regular, bold,
italic, etc.)
2024-08-26 11:47:57 -03:00
Christian Kaiser aed9127b51 Avoid drawing empty strings 2024-08-26 10:00:11 -03:00
David Capello c904a78994 Merge branch 'main' into beta 2024-04-23 15:34:43 -03:00
David Capello e48e71ba28 Update to tinyxml2 2024-04-22 18:28:03 -03:00
David Capello ab18cd986c Update to new laf draw_text() API
As the new text::draw_text() can draw text with "native" (Skia) fonts,
we have to pass the font manager (text::FontMgr) to it, which is in
SkiaTheme. So we've added a new abstract fontMgr() member function to
ui::Theme to get the active font manager.
2024-03-07 19:23:38 -03:00
David Capello 571b4ec9f2 Update to new laf API (os::System::instance()/make()) 2024-03-05 18:50:24 -03:00
David Capello 9fb61c8a01 Use new laf-text module 2024-02-20 18:18:36 -03:00
David Capello bd91a6430f Process os::Event::MouseEnter/Leave in correct order
When we received a MouseEnter/Leave, we were processing those laf-os
events immediately without taking care of all the MouseMove/Down/Up
events in the middle. Now we enqueue all the events as
messages (MouseEnter -> MouseMove/Down/Up -> MouseLeave).

This is important because when we process MouseLeave we are calling
setMouse(nullptr), which resets the mouse widget HAS_MOUSE flag, and
some widgets needs to know if they have the mouse above before the
MouseUp event. With this change we can remove the
Widget::hasMouseOver() function (that was checking the global
ui::get_mouse_position() instead of the HAS_MOUSE flag directly).

Another change was introduced to keep the old behavior now that
hasMouseOver() is not available: the ui::Manager doesn't assign the
HAS_MOUSE flag if the mouse is captured (it only assign the HAS_MOUSE
to the widget with the mouse captured, or to no widget, at least until
the capture is released).
2023-07-10 10:54:37 -03:00
Martín Capello 0958573cac Add canvas autoScaling feature (fix #3748) 2023-04-27 11:07:26 -03:00
Martín Capello b72d498070 Introduce a "combobox" style to replace the way combobox entries are painted 2023-03-13 10:52:01 -03:00
David Capello 0ae8bc9b10 Improve backward compatibility with old themes
We have to copy all missing <style> into the new theme, so these
styles are re-loaded using colors and parts from the new
theme (instead of using the data of the default theme).
2023-02-28 14:28:09 -03:00
Martín Capello 40426075f2 Add gap, gap-rows, and gap-columns style attributes 2023-02-27 09:43:48 -03:00
Martín Capello d3f01ebe17 Add width, height, minwidth, minheight, maxwidth, and maxheight attributes to styles 2023-02-27 09:43:48 -03:00
Martín Capello dded1f6eae Add mnemonics attribute for font and styles to enable/disable accelerators underlining 2023-02-27 09:43:48 -03:00
Martín Capello 195a8d0e92 Fix border, margin, and padding attributes inheritance 2023-02-27 09:43:48 -03:00
Martín Capello 11dc816878 Add "capture" state to style layer states 2023-02-27 09:43:48 -03:00
Gaspar Capello 55885ee266 Fix regression: TextBox isn't rendering text (doesn't update the bounds area of the text box)
Regression in dd0c296209 (Use
tooltip_text style & color to paint tooltip windows #2554).

Prior this fix, text box does not update its bounds area because it
has not a style assigned.

Fix #3442, fix #3443
2022-08-02 16:39:18 -03:00
David Capello dd0c296209 Use tooltip_text style & color to paint tooltip windows (fix #2554) 2022-07-18 16:00:13 -03:00
David Capello 71d885d2a0 Replace base::clamp -> std::clamp as now we use C++17 2022-06-09 19:05:48 -03:00
David Capello 65ef6f8e96 Replace utf8 iterators with utf8_decode (fix #3260)
This should fix some problems decoding invalid UTF-8 strings.
2022-04-21 20:24:49 -03:00
David Capello 2d3de1728c Add SkinTheme::get() to avoid using SkinTheme::instance() as much as possible
This was done to avoid some nullptr references using
SkinTheme::instance() (mainly from
StatusBar::IndicatorsGeneration::add()) when the application is being
closed because an exception was thrown. This might be useful to detect
certain kind of crashes from Sentry.
2022-02-18 19:01:46 -03:00