136 Commits

Author SHA1 Message Date
Charles Dang
457ed4bb43
Conduct surface manipulation in-place when possible (#9218) 2024-08-17 20:22:44 -04:00
Subhraman Sarkar
43f5644e36
Rich Text Label widget for Help Browser GUI2 port (#8655)
A rich text label widget that can show text marked up with help markup.
Also includes the GUI Test Window, accessible in the title screen after launching wesnoth using --clock option. It can be used as dialog template/example or as a place to test GUI2 code.
2024-06-06 16:33:37 +05:30
Subhraman Sarkar
9b38089db0
Story screen redesign (#8510) 2024-05-24 19:29:46 +05:30
Charles Dang
08fc993c16 GUI2/Canvas: allow text shape to set outline (resolves #8398) 2024-02-24 18:30:33 -05:00
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
gfgtdf
9f66b1e8ff Don't assert on config input.
assert() is not a good way to handle incorrect user input,
It is a debugging tool that should only be used for
conditions that the program guarantees to be true
(unless there a is a bug in the c++ code).
2023-12-13 17:01:28 +01:00
Tommy
5a4271ea98 Regenerate blur effects if canvas screen location has changed.
This should catch most cases of moving or resizing blurred windows.
2023-11-23 12:30:35 +13:00
Tommy
ca5edd5336 Regenerate story screen message panel blur when background changes. 2023-10-30 12:28:14 +13:00
Tommy
7695ee7159 Enable multi-pass rendering.
An extra rendering pass can be requested during render or expose
by calling draw_manager::request_extra_render_pass().
This is used for blur effects.
2023-10-30 12:28:14 +13:00
Tommy
766cfe8201 Implement deferred rendering for blurrables.
UI elements with blur effects (such as translucent windows) now defer
rendering for one frame, so they can snapshot the area underneath
for blurring.

In the future this should be done as multiple passes in one frame,
but for now this is fine.
2023-10-28 12:13:33 +13:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Charles Dang
ca366554a0 GUI2/Canvas: default to NN scaling for images if not specified 2022-08-20 20:53:22 -04:00
Tommy
29c82e308a CVideo: Remove CVideo singleton, replacing with "video" interface
The only real change is that in stead of passing around CVideo
pointers and calling things via CVideo::get_singleton().foo()
one simply does not pass around pointers, and calls video::foo().
2022-07-24 22:06:33 +12:00
Tommy
3835f9580b Fix some poor indentation, and tidy some TODOs 2022-07-22 15:07:59 +12:00
Tommy
ba24612f73 Remove trailing newlines from multiline log messages 2022-07-20 15:20:57 +12: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
1c25ebdfa2 Remove std::endl from log lines, now that it's added automatically 2022-07-20 15:20:57 +12:00
Tommy
2931615cdf Ported over the text texture cache from new_rendering
Squashed from new_rendering:
 * Ported over the basic text texture cache
 * Font/Text: fixed bad hashing leading to duplicate textures
 * Use text texture drawing method instead of surface one
 * Cleaned up and optimized pango_text rendering pipeline
 * Font/Text: removed get_width and get_height in favor of just get_size
 * Font/Text: guard against caching a null texture

This breaks the credits screen. The game will crash when it tries to
display it.
2022-07-13 13:34:01 +12:00
Tommy
91e6ee91db draw: add fill overloads for filling the entire render target 2022-07-05 18:43:42 +12:00
Tommy
96703ca242 Replace sdl::intersect_rects with new rect::intersect and rect::clip
rect::intersect returns the constructed intersection, whereas
rect::clip modifies the rectangle.
2022-07-02 12:30:58 +12:00
Tommy
f0e4d3673f sdl/rect: Add scalar multiplication and division operators
Mostly useful for simplifying pixel scale conversions.
2022-07-02 12:30:58 +12:00
Tommy
e44129fb91 Address some slightly less straightforward TODOs 2022-07-01 15:06:25 +12:00
Tommy
132a45c52f sdl/rect: Move fill_surface_rect to sdl/utils.hpp
And then have to clean up over a dozen files that were relying on
sdl/rect.hpp including sdl/utils.hpp and various other side effects.
2022-06-29 13:13:15 +12:00
Charles Dang
7f1bc41162 GUI2/Canvas: removed unused image_shape members 2022-06-28 20:14:47 +12:00
Tommy
8efd9d43f2 GUI2: Port over most of the canvas cleanup
Text is still drawing clipped because otherwise Credits crashes. It has
bugs because the viewport is too large, but at least it doesn't crash.
2022-06-28 20:14:47 +12:00
Charles Dang
43a1ecc8bd CVideo: minor cleanup
- Removed overload of set_resolution taking two ints
- Removed get_width and get_height in favor of draw_area
- Removed some dead code
- Minor formatting cleanup
2022-06-14 14:48:34 +12:00
Tommy
ebcae03e48 Add a new image tiling mode: "tile_highres" for high-DPI tiled images.
The other options "tile" and "tile_center" work in draw space,
which is consistent with past behaviour, but doesn't look as nice.
2022-06-14 14:48:03 +12:00
Tommy
352236a094 Correctly handle images with resize_mode of scale or stretch.
Correctly meaning using linear filtering in stead of none.
2022-06-14 14:47:54 +12:00
Tommy
9af1251540 Update high-DPI font handling to reside entirely in font/text.cpp.
It is now transparent to the user.

The meaning of sdl::texture.w() and .h() have changed. These now
return the intended width and height of the texture in draw-space,
rather than the real width and height. To get the real width and
height, use texture::get_info().
2022-06-14 14:44:11 +12:00
Tommy
0d30c9d7c3 Fix text positioning when clipped to a viewport.
Should fix the lua console, and the credits screen.
2022-06-11 15:37:03 +12:00
Tommy
f183978071 Some small rendering fixes.
* halo background draw fixed
* tiled images clip correctly
* new interface/setter for reducing clipping area.
2022-06-01 00:35:53 +12:00
Tommy
743a1b5655 Implement a mirror mode for tiling textures.
It mirrors such that tiles always share a common edge.

This isn't currently used for anything, simply included for completeness.
2022-05-31 21:17:33 +12:00
Tommy
638c02b59e Rename image_shape.vertical_mirror_ to mirror_.
It is in fact (and always was) mirroring horizontally.
2022-05-31 21:17:33 +12:00
Tommy
e94291b2dc Fix canvas blits. 2022-05-31 21:17:33 +12:00
Tommy
881abd1123 Move circle drawing code to draw.cpp. 2022-05-31 21:17:33 +12:00
Tommy
96bc7d6046 Consolidate drawing functions in new "draw" namespace.
Contains primitive drawing functions, such as fill, points, line, etc,
and also texture drawing functions blit, flipped, tiled.

This removes specialty drawing code from several places, most notably
CVideo and gui/core/canvas.

Functions to draw to the screen should now go in draw.cpp.
2022-05-31 21:17:33 +12:00
Tommy
3bc0defdce image: deprecate get_image for new explicit get_surface and get_texture.
Places where usage is clear have been converted to the new calls.
Places that need extra work to convert are still using get_image(),
as are places that will be clobbered as part of general rendering
system upgrades anyway.
2022-05-31 21:17:33 +12:00
Tommy
f808039fb3 sdl::texture: cache texture width and height for easy access. 2022-05-31 21:17:33 +12:00
Tommy
89553a195f Some minor todo and informational comments. 2022-05-31 21:17:33 +12:00
Tommy
088f0cd118 Mostly convert gui/core/canvas to the new rendering system.
This enables high-res textures and fonts.

There are some bugs with redrawing. Rather than fixing these,
the related system should be overhauled.
2022-05-31 21:17:33 +12:00
Tommy
0bb74bdb32 Remove all remaining direct usage of the drawing surface.
It can now be phased out.

Everything should now be fixed and working except map screenshots.
2022-05-08 11:34:39 +12:00
Tommy
29c862b088 Fix blur. 2022-05-08 11:25:59 +12:00
Tommy
27758e4b24 gui/canvas: Reenable blur.
This is now done in a way compatible with hardware rendering,
but is not yet behaving correctly.
2022-05-08 11:21:07 +12:00
Tommy
eb60753664 Overhaul drawing to use CVideo API in stead of blitting to a surface.
Draws now immediately apply to the render target, in stead of
accumulating on the drawing surface. This means textures can start
to be used for drawing in stead of surfaces, and both systems
should be able to be used interchangably for now.

Some things have been broken, including but probably not limited to:
  * background blur
  * the occasional direct SDL_FillRect call
  * floating labels
  * map screenshots

Some things will be broken if textures are used for drawing:
  * widget restore images
  * other screenshots
  * clipping areas

However, this is the first step towards proper high-dpi hardware-
accelerated rendering.
2022-05-08 11:17:42 +12:00
Charles Dang
0f9ee653ab GUI2: removed frameBuffer argument from widget drawing functions 2022-05-03 21:19:06 -04:00
Tommy
d130622b96 Initial indirect rendering prototype.
Rendering is now done to a separate surface. All routines that previously
wrote directly to the framebuffer now write to this surface. When the screen
is flipped, this surface is copied directly to a streaming texture, which is
then scaled to the window's rendering surface for display.

This has enabled a drawing resolution that differs from display resolution.
It is active and for the most part works. Input events are converted to the
correct scale by SDL, so most input handling routines can be used unchanged,
but one or two are causing problems so there are some bugs. To test this,
change the "pixel_scale" preference. Don't expect a playable game with
any pixel scale other than 1 yet.
2022-04-18 17:25:06 +12:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Charles Dang
6d13209a64 GUI2: used a scoped enum for resize_mode 2021-08-09 00:55:17 -04:00
Charles Dang
3d87478a29 GUI2: add resize_mode=scale_sharp for [image] shapes 2021-08-09 00:45:23 -04:00