57 Commits

Author SHA1 Message Date
Charles Dang
f111ab1f7b GUI2/Text Box Base: use existing resolution config ptr
No need to call get_control twice. Only styled_widget needs to do that.
2025-03-11 23:55:38 -04:00
pentarctagon
d674e9f462 automatic copyright update 2025-02-17 12:59:51 -06:00
Charles Dang
99ee4a7703
Split text attribute handling into its own API (#9890) 2025-02-15 00:33:46 -05:00
Charles Dang
858d8b8ce1 GUI2: remove open_window_stack
This was only ever needed for is_in_dialog (and one thing in text_box_base), and we can use the dispatcher list for the former, since windows are the only dispatchers that register themselves to receive events.
2025-01-05 17:45:55 -05:00
Charles Dang
0badadaffe GUI2/Text Box Base: remove manual callback handling
Instead, register a NOTIFY_MODIFIED handler. Note I need to fix said event not firing when cutting text from the box.
2024-12-23 14:30:25 -05:00
Charles Dang
12fa8f2844 Use standard chrono types consistently throughout the codebase
* Functions that return time values now return proper std::chrono::duration units (milliseconds,
  seconds, etc.). This removes the need to do manual unit conversions.
* Simple time-to-execute logging was replaced with `utils::optimer`.
* Most uses of `SDL_GetTicks()` have been replaced with `std::chrono::steady_clock`.
* Uses of events::pump_info::ticks() have been replaced with direct calls to steady_clock::now().
  This made the countdown_clock code significantly simpler. As for the music_tinker, that needs
  to be rethought wholesale.
2024-11-07 11:10:13 -05:00
Subhraman Sarkar
b6dead682b clipboard: remove redundant methods 2024-09-18 23:01:46 -04:00
Subhraman Sarkar
54535fca3b scroll_text: markup and link awareness support
support for copying and partial editing only.
this does not make multiline_text a rich text editor.
2024-09-18 23:01:46 -04:00
Subhraman Sarkar
03a46f1d7c
Combobox, Tab Container and Editability in Text Box (#8390)
* new combobox and tab container widgets
* ediability in text box via the editable key
2024-05-06 09:56:44 +05:30
Subhraman Sarkar
6c5a8e923d
Spinner and multiline textbox widgets (#8199) 2024-02-13 11:54:34 -06:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Pentarctagon
80fb5650b1 Don't call back() if open_window_stack is empty since that's UB.
Resolves #7104
2022-11-24 21:01:35 -06:00
Tommy
a02709e0ff Remove \n from log lines with it as suffix on the final string 2022-07-20 15:20:57 +12:00
Tommy
1fe87c4e24 Remove "<< '\n';" from log lines 2022-07-20 15:20:57 +12:00
Tommy
06254e5581 Mega draw manager implementation
This has been megasquashed because it was a month-long mess of fixes
and reworks.

In summary:
* objects no-longer draw by hooking a DRAW event. In stead they
  inherit from gui2::top_level_drawable, and implement its interface.
* the game display now renders to an offscreen buffer. This is used
  to implement hardware scrolling, and to redraw after halos, floating
  labels etc. move.
* halos, floating labels, tooltips, and a few more things are now
  drawn on top of the game display, rather than as part of it. This
  allows them to be updated independently without reading pixels
  from the screen.
* surface restorers have been removed. Reading pixels from the screen
  should now be unnecessary excepting two cases: (a) screenshots,
  (b) background blur. Blur is cached, and screenshots are occasional.
* GUI2 widgets no longer keep track of dirty state. They are redrawn
  as necessary. Most places which previously set dirty state now queue
  a redraw in their part of the screen in stead.
* A consequence is that active translucency is enabled across all UI
  elements, and the game display can (and does) continue to animate
  while menus and dialogs are showing.
* performance is drastically increased for basically everything, most
  notably map scrolling, floating text, and halos.
* CPU usage is drastically decreased. With animations disabled it is
  essentially zero while nothing is moving.
* GPU usage is also minimal. The display is only flipped if something
  is drawn.
2022-07-13 13:34:01 +12:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Pentarctagon
57ce449af8
Re-add attribution to copyright notices.
These are mostly useless and outdated/wrong, but apparently it's probably illegal to remove them.
2021-07-27 20:21:38 -05:00
Pentarctagon
ba75e1af50
Copyright update.
This additionally:
* Makes all copyright notices identical aside from the starting year for Wesnoth-specific source files. Files not included: mariadbpp, lua, spirit po, xbrz, and bcrypt (crypt_blowfish).
* Removes all attribution from the files, since the vast majority of them are outdated or seemingly just outright incorrect. For example, I would guess that Dave is no longer the sole author of the majority of Wesnoth's current code.
2021-07-26 11:38:03 -05:00
Iris Morelle
3ddbeb0b1e gui2/text_box: Add a monospace font variation
This requires communicating the font family to the internal renderer, so
it's not just a WML change.
2021-03-13 19:23:42 -03:00
Charles Dang
6e2f3e099e Removed utils/functional.hpp 2020-12-04 15:30:46 +11:00
Charles Dang
30c7a747ab Explicitly specify std::placeholders namespace for all bind placeholders
Apparently, even on Boost 1.73 without Boost placeholders specialized as is_placeholder, they were somehow
getting used in the global namespace. Would explain all the "Boost placeholders in the global namespace is
deprecated" warnings I was getting after 23d1db043f9f8266c77c6270ed4ef3eafbc0cf67.

When testing with BOOST_BIND_NO_PLACEHOLDERS, even though I had `using namespace std::placeholders` in utils/functional.hpp,
compilation still failed in places. This confirms even more that Boost global placeholders were being used. Honestly,
it was simplest just to specify std::placeholders for everything. This also means we can remove the hack in utils/functional.hpp
designed to allow Boost placeholders to work with `std::bind`.
2020-12-04 15:28:15 +11:00
Iris Morelle
d7f2595393 gui2/text_box: Implement I-beam cursor
This cursor is active when the widget has the mouse focus. You know,
like textboxes are wont to do anywhere else. Took long enough, although
there was an interaction issue with tooltips fixed in the previous
commit.

I still need to figure out how to make this work with GUI1 textboxes
(e.g. in-game console).

The colour version of the cursor was kindly provided by LordBob, and the
B&W version is my own.
2019-11-13 00:03:38 -03:00
Iris Morelle
3beefca899 gui2/text_box: Add hover effect
This gives GUI2 textboxes (and password boxes since they are a subclass)
a simple hover effect by extending the canvas definitions for the widget
accordingly.
2019-11-11 17:16:39 +11:00
Charles Dang
4a3be684f4 Removed trailing tabs and whitespaces from C++ source
[ci skip]

I ran the same command from 9b7b1751fdda.

Excludes:
* lua/
* spirit_po/
2019-08-04 22:31:10 +11:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0678f40a209797d72dfaba3e5e88545
(cherry-picked from commit bc4d22dc72e79c3d6a3364ac896e473afd298246)
2018-10-07 03:23:36 +00:00
Gregory A Lundberg
c23808a92f Fix doccomment error
Remove lame doccomments.

(cherry-picked from commit 092f8f325c28aa34b1385c042132ec6cc5a40f1d)
2018-10-07 03:19:57 +00:00
Victor Sergienko
07e654510f #2782 Crash when using composing like ˇ and ' in lobby on macOS.
Some backstory: https://github.com/wesnoth/wesnoth/pull/2644#issuecomment-382298822

(cherry-picked from commit 16cd19873db9686c54b1c5d3ba2d5a17d431d145)
2018-10-07 03:19:37 +00:00
Charles Dang
dfce371287 Convert custom unicode type aliases to proper types (available as of C++11)
This changes:
utf8::char_t   ->  char
utf8::string   ->  std::string
utf16::char_t  ->  char16_t
utf16::string  ->  std::u16string
ucs4::char_t   ->  char32_t
ucs4::string   ->  std::u32string

utf16::string and ucs4::string are now proper strings instead of vectors of characters too.

In order to get this change to compile at all, I needed to add a ucs4_convert_impl::convert_impl
specialization for wchar_t alongside the new char16_t specialization; both point to the same
conversion implementation type.

This commit doesn't do any additional cleanup. I'm sure if we looked, we could get rid of a
lot of the custom conversion code and probably a bunch of stuff that might have had to do with
supporting utf16::string and ucs4::string being vectors instead of basic_string specializations.
Either way, I don't know the code (or encoding handling in general) to make a call as to what's
needed or not. I'll let someone else do that.

(cherry-picked from commit 1deacd89f640e1ddada75e1286c14a09ab8cce62)
2018-10-07 03:18:49 +00:00
Hironori Fujimoto
9bb1168a6b Rename variable so that it's role becomes clearly
(cherry-picked from commit 6b98bbdca125a748bc4eafb5f54394d0f14a7177)
2018-10-07 03:18:16 +00:00
Hironori Fujimoto
db183b331a Use is_composing() instead of raw ime_in_progress_
(cherry-picked from commit 6212a62a985b60110a7350ed28bfb0601cc1d0b8)
2018-10-07 03:18:15 +00:00
Hironori Fujimoto
60f00b4a69 Remove private member 'ime_length_'
In order to get length of composition text, just compare text_ and
text_cached

(cherry-picked from commit 5e22b2b714d58b7f6041c323b0e4c9c7e02bc0b1)
2018-10-07 03:18:15 +00:00
Hironori Fujimoto
adda2d3062 Turn ime_in_progress_ off when composition text is nothing
(cherry-picked from commit 16a8ac7e4956bdf236b518e42913af1ae7360cbf)
2018-10-07 03:18:15 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f6935176b70a035d3e1c03080f79687f94)
2018-10-07 03:17:59 +00:00
RatArmy
16c822cbb4 text_box_base: Fix segfault when type characters more than limit by IME (#2666)
pango_text.set_text() is not check whether the text over the maximum
length, so change it to insert_text()
2018-03-17 21:14:18 +11:00
Hironori Fujimoto
3b581b65e5 text_box_base: adapt to separated SDL_TextEditingEvent
Also arg 'len' removed from handle_editing because utf8::size(unicode)
can be used instead of len in wesnoth.
2018-03-13 16:40:22 +11:00
Charles Dang
9614a4280a Cleaned up various util includes 2018-01-22 11:21:59 +11:00
josteph
24392b98ea Revert part of "GUI2 Textbox: Remove the other two emacs keybindings"
This reverts part of commit 468c6e0f494793d57b0b1264894cd7f0b0383fa2.

Ctrl+A was removed because its emacs meaning is surprising to some
people.  Ctrl+E was removed because it was the counterpart of Ctrl+A.
Ctrl+U however doesn't conflict with anything else, and it's useful
to some people (me), so reinstate it.
2018-01-20 11:40:40 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
galegosimpatico
48ec4cd6f7 Reconfigure 'select all' for texts in macOS.
Use the idiomatic combination.

Update reference to particular comment line of
'src/widgets/textbox.cpp' in comment with the current line where the
comment is now.

Remove `unsigned` as the type for `copypaste_modifier`, because it was
a little bit less future proof that way, it is better as an
`SDL_Keycode`, which at the moment is `Sint32`, which in turn is
`int32_t` ultimately. Reuse the constant for 'select all' so renaming
it to `modifier_key`.
2017-10-27 15:15:04 +11:00
Charles Dang
b7ac634e78 Removed trailing tabs and whitespaces from C++ source
[ci skip]

I ran the same command from 9b7b1751fdda.

Excludes:
* lua/
* spirit_po/
2017-10-09 11:49:51 +11:00
Jyrki Vesterinen
670bcf71a3 Address a bunch of Coverity Scan warnings 2017-09-01 23:24:04 +03:00
Celtic Minstrel
468c6e0f49 GUI2 Textbox: Remove the other two emacs keybindings 2017-08-28 23:24:36 -04:00
Charles Dang
201fafd5ea GUI2/Text Box Base: made ctrl+a select all text
Previously it was an alias for HOME, which is unintuitive and rather useless.
2017-08-26 10:49:06 +11:00
Charles Dang
a87132ab6b GUI2: refactored widget initialization process
Essentially, this utilizes the second styled_widget overload that takes a builder reference to allow widgets
to initialize themselves without the extra init_control call. It also removes the need for extra functions such
as styled_widget::load_config_extra or styled_widget::init since the widget definition config and canvases are
loaded in the styled_widget ctor. Any code from the uses of the former function were moved either to widget
builders or their ctors.
2017-08-26 10:49:06 +11:00
RatArmy
0a3f125af2 Fix insert index of the text edited by IME (#1833) 2017-07-11 21:09:04 -04:00
Celtic Minstrel
5d43078ba4 [WIP] Implement IME support for GUI2 textboxes (#1758)
Implement IME support for GUI2 textboxes
2017-06-11 16:47:46 -04:00
Charles Dang
fc83e20dfb GUI2: get rid of all the magic canvas count numbers
These were unnecessary since the canvas vector was automatically resized the match the
available number of canvases when a styled_widget was constructed.
2017-05-26 21:27:33 +11:00
Celtic Minstrel
640e28f731 Don't update the textbox canvas if the cursor alpha didn't change 2017-05-12 15:34:18 -04:00
Celtic Minstrel
cbc4af1a20 Add blinking text cursor to focused textbox
Unlike the previous implementation, the blinking cursor now only applies
to the focused (frontmost) window.
2017-05-12 15:34:16 -04:00