Commit Graph

109 Commits

Author SHA1 Message Date
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 bc3433fcf2 Add new ui::TranslationDelegate to translate Entry popup items
Parts of this commit are from #4968 and will be useful to reuse in the
multiline TextEdit widget.

Co-authored-by: Christian Kaiser <info@ckaiser.com.ar>
2025-02-15 12:09:37 -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 77dd92c679 Don't overlap search icon with text in SearchEntry 2024-10-28 15:32:41 -03:00
David Capello 5c7a3a41f6 Add ligatures button to Text tool (#4679)
Doesn't fully fix the issue as we cannot move the cursor between the
ligature clusters, but at least we can disable the ligatures now.
2024-09-25 16:37:41 -03:00
David Capello 8fa4775def Persist the text selection when we change the font 2024-08-26 18:21:13 -03:00
David Capello 7558504733 Fix caret/highlight positions when we change the font 2024-08-26 18:07:13 -03:00
David Capello 5a877f49e4 Fix caret position in ui::Entry
We have to fill/use the X position of each char box instead of
calculating it through the width of each glyph (because each advance
is different from the glyph width in isolation).
2024-08-26 18:07:08 -03:00
David Capello ae1d9ca9b1 Render text/highlight selected text on the canvas
Now we don't render the default ui::Entry edges, but we paint just a
border of the text bounds + the rendered text highlighting selected
text on the canvas itself.

With this change click mouse positions are translated with a scale
factor that changes depending on the app::Editor zoom.
2024-08-26 11:47:57 -03:00
David Capello 5ad969466b [win] Insert emojis with Windows key + . (period) correctly 2024-04-19 15:43:08 -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 5ae2e444f2 Replace asserts limiting values directly in Entry::selectedRange()
There are some cases where these asserts failed (mainly in the
dithering matrix selection combobox).
2023-11-30 11:23:15 -03:00
David Capello 63fb39e0e8 Fix sprintf() warnings using snprintf() or fmt::format() 2023-09-27 19:57:41 -03:00
Martín Capello 7a338250a3 Fix alignment of several controls when UI scaling is 200% and Screen scaling is 100% to make them look the same as when US scaling is 100% and Screen scaling is 200% 2023-03-13 10:52:01 -03:00
David Capello f8f925c634 Merge branch 'main' into beta 2022-07-13 19:49:03 -03:00
David Capello 4f2eae6b77 Use C++17 [[fallthrough]] if needed 2022-06-29 20:14:03 -03:00
David Capello 8f44b521b6 Merge branch 'main' into beta 2022-06-10 10:31: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 2a59076f49 Merge branch 'main' into beta 2022-04-25 11:45:31 -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 82a0ec5199 Improve seleting words w/double-clicking on a ui::Entry (fix #3229)
* Now we support selecting multiple words at the same time
* Now punctuation is not included as part of the word
2022-04-19 16:17:28 -03:00
David Capello 83e2604d12 Make ui::Entry smaller 2022-04-19 08:48:50 -03:00
David Capello 1f5b6980d3 Fix File > Open initial position when multiple monitors are used
With this patch we removed the ui::get_desktop_size() function
too (now we can get the workarea of the display's screen).
2021-04-21 17:01:43 -03:00
David Capello bcd69495ce Fix several issues locating windows with multiple UI windows
We've refactored the code to support locating windows (and popups
windows + hot regions) correctly in both modes: with one ui::Display
and with multiple ui::Displays.

For this we've added a new ui::fit_bounds() function that works in
both modes.
2021-03-19 18:57:56 -03:00
David Capello 35bb3af6e2 Replace all base::Bind() with lambda functions 2021-03-05 20:09:42 -03:00
David Capello c3d52f0bbe Add ui::Display to support multiple windows in the future
This ui::Display is related to one native os::Window, so the dirty
region/invalid region is now part of a ui::Display instead of a
ui::Manager.

* Replaced ui::display_w/h() functions with ui::Display::size()
  and ui::get_desktop_size()
* The ui::Manager contains the main ui::Display, and in the future an
  ui::Window will have its own ui::Display
2021-02-18 12:34:42 -03:00
David Capello 3fbdd40f24 Add skew transformation (fix #71)
This is the first version of the feature, it still needs some
fixes (e.g. avoid skew transform when the pivot is in the same side of
the skew handle which can calculate a division by zero).
2020-09-18 19:29:43 -03:00
David Capello 8a3f32b47f Replace all base::Bind() with lambda functions 2020-07-03 21:51:46 -03:00
David Capello f491a2a506 Add ui::Entry::Range to simplify code 2020-05-15 18:24:35 -03:00
David Capello fa187b35a8 Don't delete extra char using Ctrl+backspace to delete words in ui::Entry 2020-05-15 18:15:59 -03:00
David Capello 7cde901047 Alt+backspace deletes a word too on ui::Entry fields 2020-05-12 15:11:15 -03:00
David Capello 8b1b624320 Replace NULL to nullptr in ui library 2020-04-08 17:48:06 -03:00
David Capello 95b655168c Use new laf + skia m81 branch
* Some minor refactors due laf changes.
* Updated the instructions to compile Aseprite linking to external
  skia instructions and pre-built packages.
2020-03-01 23:42:08 -03:00
David Capello 34ec123ecc Remove MIN/MAX/MID macros from ui library 2019-12-20 15:08:34 -03:00
Gaspar Capello 7c92fe207a Fix caret position when click on a text entry (#2160) 2019-09-30 16:22:01 -03:00
David Capello 73de6c8b1d Add ability to edit multiple slices
Related to #721 and #1651, still need more work to give a better UX to
edit static and animated slices.
2019-05-02 16:26:13 -03:00
David Capello ab9883e260 Avoid running ui::Entry timer when it's not needed 2018-12-12 13:27:24 -03:00
David Capello aea8e9cd83 Fix combobox size hint when using some user themes
From: https://community.aseprite.org/t/2276
2018-11-26 16:46:02 -03:00
David Capello 5cb2d984f0 Rename she -> os 2018-08-09 12:58:43 -03:00
David Capello 40968891f2 Add option to disable native clipboard
This is related to #1100, as the Linux port is not well tested and may
fail, it's good to have an option to disable the native clipboard code
just in case.
2018-05-24 12:56:07 -03:00
David Capello dede3610f3 Fix bug inserting the first char in a text entry
If a text field (ui::Entry) contains text with length=1 (e.g. the number
"8"), and we focus and press that same char ("8"), the caret will be in
the position 0 with text "8" (the caret should be in position 1). this
patch fix this behavior.
2017-10-03 14:45:53 -03:00
David Capello d5c47e2213 Make Entry fields bigger in ContextBar to avoid text scrolling 2017-05-31 16:21:34 -03:00
David Capello 7bc593ac34 Change Entry::maxSize property from size_t to int 2017-04-19 17:51:03 -03:00
David Capello 73999c5415 Fix several issues with UI Scaling > 100% (fix #1456) 2017-04-15 08:13:20 -03:00
David Capello 482f3eed0e Fix crashes editing composed unicode strings 2017-03-08 13:54:21 -03:00
David Capello e4577665c3 Remove unused variable 2017-03-07 11:06:58 -03:00
David Capello 5d7b62e652 Fix ui::Entry to handle composed Unicode chars correctly 2017-02-21 18:05:23 -03:00