Commit Graph

208 Commits

Author SHA1 Message Date
Matthew Olsson
4cf5514672 LibGfx: Re-add missing bounds-checks to Painter::draw_rect
This commit adds a draw_physical_line method, which is the exact same
as draw_line, except it's parameters are already transformed and
scaled. This is used by both draw_line and draw_rect, as a slight
optimization to save some work. It also fixed draw_rect not checking
whether it should draw the lines before drawing them.
2021-05-03 08:19:39 +02:00
Matthew Olsson
790908ffc3 LibGfx: Add scaling methods to Bitmap 2021-05-02 22:48:06 +02:00
Matthew Olsson
4233b69ecf Color: Add interpolate method 2021-05-02 22:48:06 +02:00
Matthew Olsson
ff76a5b8d2 LibGfx: Add directional floating-point scaling to Painter
This allows the painter to be scaled separately in both directions, and
not just in integer intervals. This is crucial for proper SVG viewBox
support.

Most bitmap-related things verify the scale to be one as of now.
2021-05-02 22:48:06 +02:00
Matthew Olsson
88cfaf7bf0 LibGfx: Unify Rect, Point, and Size
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
2021-05-02 22:48:06 +02:00
Matthew Olsson
ac238b3bd6 LibGfx: Add some helper methods to AffineTransform
Also makes some basic getters ALWAYS_INLINE and [[nodiscard]], as well
as fixing as error with the map method.
2021-05-02 22:48:06 +02:00
Gunnar Beutner
6cf59b6ae9 Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr 2021-05-01 21:25:06 +02:00
Andreas Kling
20dd5735ce WindowServer+LibGfx: Automatic "modified" markers in window titles
You can now add the string "[*]" to a window title and it will be
replaced with " (*)" if the window is modified, and with "" otherwise.
2021-05-01 19:42:29 +02:00
Andreas Kling
3d4afe7614 Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
2021-04-29 22:23:52 +02:00
Idan Horowitz
115b445dab LibGfx: Add basic support for bidirectional text rendering
This adds a *very* simplified version of the UNICODE BIDIRECTIONAL
ALGORITHM (https://www.unicode.org/reports/tr9/), that can render most
bidirectional text but also produces awkward results in a large amount
of edge cases, and as such, this should probably be replaced with a
fully spec compliant implementation at some point.
2021-04-29 10:36:23 +02:00
Linus Groh
649d2faeab Everywhere: Use "the SerenityOS developers." in copyright headers
We had some inconsistencies before:

- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."

I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.

By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
2021-04-29 00:59:26 +02:00
Linus Groh
5459c744f1 Everywhere: Add missing comma between copyright year and name 2021-04-29 00:59:26 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
thankyouverycool
cc7744f6ca LibGfx+FontEditor: Account for raw width when painting glyphs
Fixes hidden glyphs being painted in editor and map, and '?'
subsitute glyphs being overdrawn in the system.
2021-04-23 11:08:11 +02:00
Matthew Olsson
fcd3b9a0df Userland: Use mattco@serenityos.org for my copyright headers 2021-04-23 08:24:53 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
e875d4e044 LibGfx: Convert String::format() => String::formatted() 2021-04-21 23:49:01 +02:00
Andreas Kling
d996e43df6 LibGfx: Minor clean-ups in Gfx::FontDatabase
Use Core::DirIterator::next_full_path() instead of manually building
each path.

Also convert a fprintf(stderr, ...) to warnln()
2021-04-21 23:49:01 +02:00
Lenny Maiorani
ece8aeaaf4 Everywhere: Remove redundant inline keyword with constexpr
Problem:
- `constexpr` functions are additionally decorated with `inline`
  keyword. This is redundant since `constexpr` implies `inline`.

Solution:
- Remove redundancies.
2021-04-21 20:49:49 +02:00
Andreas Kling
6793574003 LibGfx: Improve PNG encoder API somewhat
This is still far from ideal, but let's at least make it take a
Gfx::Bitmap const&.
2021-04-19 23:49:16 +02:00
Idan Horowitz
397269d21e LibGfx: Report font glyph presence based on glyph's specific width
This uses the per glyph width to determine if the glyph is actually
present in the font, and not just inside the range the font can covers

This means that characters that are in the font's range but that are
missing a glyph will show up as the missing character glyph instead of
being invisible.
2021-04-18 22:10:25 +02:00
Idan Horowitz
18ae37439a FontEditor+LibGfx: Allow user to specify if a specific glyph is present
This replaces the glyph width spinbox in the font editor with a
checkbox when editing fixed width fonts that indicates if the
currently selected character's glyph is present in the edited font
(For variable width fonts a non zero width implies presence)

This commit also changes the background color of glyphs in the glyph
map based on the presence of each specific glyph in the font.
2021-04-18 22:10:25 +02:00
Idan Horowitz
08d1b16a8d LibGfx: Always load font widths array and use it for glyph presence
Since we were always saving the glyph widths array to the font file, we
now also always load it, even on (which also simplifies the logic a bit)
fixed width fonts. We also set it initially to 0 instead of the default
fixed width, which allows us to use it to check for glyph presence in
both fixed width and variable width fonts.
2021-04-18 22:10:25 +02:00
Idan Horowitz
3c894d1e6f LibGfx: Use size_t instead of int for glyph count
The count is always non-negative
2021-04-18 22:10:25 +02:00
Idan Horowitz
f461ee7d01 LibGfx: Add support for fonts that include the Hebrew Unicode Block 2021-04-18 18:57:35 +02:00
Andreas Kling
12546259ff Everywhere: Rename title_bar => titlebar 2021-04-18 16:35:18 +02:00
Sahan Fernando
e6b396c248 LibGfx: Fix sse enabled builds by removing implicit float conversion 2021-04-17 11:00:04 +02:00
Luke
dfb23babbb LibGfx: Make top highlight of classic buttons fit to the top left corner 2021-04-17 09:56:22 +02:00
Andreas Kling
e873d27ab1 LibGfx: Switch a bunch of API's from taking StringView to String
These were all getting converted into String internally anyway.
2021-04-17 01:27:30 +02:00
Nicholas-Baron
73dd293ec4 Everywhere: Add -Wdouble-promotion warning
This warning informs of float-to-double conversions. The best solution
seems to be to do math *either* in 32-bit *or* in 64-bit, and only to
cross over when absolutely necessary.
2021-04-16 19:01:54 +02:00
AnotherTest
801daf47f0 LibGfx+LibWeb: Wire up CanvasRenderingContext2D.ellipse()
Note that this is *extremely* naive, and not very good at being correct.
2021-04-15 17:50:16 +02:00
AnotherTest
6c05d6d370 LibGfx: Add a Path::arc_to() helper
...That just uses elliptical_arc_to().
2021-04-15 17:50:16 +02:00
AnotherTest
1ea466661f LibGfx+LibWeb: Move out the EllipticArcTo() logic into Path
At its previous state, the interface allowed invalid "ellipses" to be
specified, instead of doing that, simply use the parameters that SVG
uses :^)
2021-04-15 17:50:16 +02:00
AnotherTest
cb04a441cf LibGfx: Un-recursive-ify the Bezier and Elliptic curve implementations 2021-04-15 17:50:16 +02:00
Idan Horowitz
b7c3f046f7 LibGfx: initialize winding number to 1 for NonZero winding rules
Since we first check the winding number and only then update it, fills
for "Rectangle-like" (made up of 2 parallel segments) paths would draw
nothing when filled by NonZero winding rules. (Fix by alimpfard)
2021-04-14 23:01:23 +02:00
Andreas Kling
a2baab38fd Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"
I hereby declare these to be full nouns that we don't split,
neither by space, nor by underscore:

- Breadcrumbbar
- Coolbar
- Menubar
- Progressbar
- Scrollbar
- Statusbar
- Taskbar
- Toolbar

This patch makes everything consistent by replacing every other variant
of these with the proper one. :^)
2021-04-13 16:58:15 +02:00
thankyouverycool
c283429196 LibGfx: Add a count to FontTypes and a helper to return type names 2021-04-11 01:16:34 +02:00
Andreas Kling
d4d8d9ea0b LibGfx: Make sure draw_ui_text() paints underlines with text color
We shouldn't hard-code black here, then we won't respect the system
theme colors. :^)
2021-04-11 01:11:56 +02:00
Andreas Kling
a4992b5ece LibGUI+LibGfx: Collapse the '&' from Alt shortcuts in tooltip texts
Also resolve a FIXME about using GUI::Label auto-sizing since we're
changing this code and it simplifies what we're doing.

Fixes #6219.
2021-04-11 01:11:09 +02:00
AnotherTest
a6e4482080 AK+Everywhere: Make StdLibExtras templates less wrapper-y
This commit makes the user-facing StdLibExtras templates and utilities
arguably more nice-looking by removing the need to reach into the
wrapper structs generated by them to get the value/type needed.
The C++ standard library had to invent `_v` and `_t` variants (likely
because of backwards compat), but we don't need to cater to any codebase
except our own, so might as well have good things for free. :^)
2021-04-10 21:01:31 +02:00
Andreas Kling
11bea5d633 LibGfx+Base: Add Tray/TrayText theme colors and Gfx::ButtonStyle::Tray
A "Tray" is a sunken container area for widgets. The first intended
client of this style is the GUI::FilePicker's common locations frame.

Thanks to @nvella for coming up with the term "Tray" :^)
2021-04-09 21:53:43 +02:00
Andreas Kling
eecf60767a LibGfx: Make draw_ui_text() underlines take glyph spacing into account
Without this, the underline was ending up too far to the left.
2021-04-09 17:08:49 +02:00
Andreas Kling
2b9bc605d2 LibGfx: Add a Gfx::TextAlignment parameter to Painter::draw_ui_text() 2021-04-09 17:08:49 +02:00
Andreas Kling
b7a25bfaac LibGfx: Adjust parameter order for Painter::draw_ui_text()
Let's put the rect first so it's the same as draw_text().
2021-04-09 17:08:49 +02:00
Dmitrii Trifonov
323b7021bc LibGfx: Added dirty and raw cyrillic support for bitmap fonts.
This is a very quick and diry hack to implement support for cyrillic bitmap fonts.
2021-04-09 08:33:12 +02:00
Idan Horowitz
34c05a744f LibGfx: Update to PNGLoader to modern dbgln_if and if constexpr logging 2021-04-07 19:36:24 +02:00
Idan Horowitz
8a0f1d87c0 LibGfx: Fix IHDR filter method field validation
As per the PNG specification: "Filter method is a single-byte
integer that indicates the preprocessing method applied to the
image data before compression. At present, only filter method 0
(adaptive filtering with five basic filter types) is defined."
2021-04-07 19:36:24 +02:00
Idan Horowitz
f0bd17e610 LibGfx: Zero out dummy filter scanline
As per the PNG specification: "For all x < 0, assume Raw(x) = 0 and
Prior(x) = 0. On the first scanline of an image (or of a pass of an
interlaced image), assume Prior(x) = 0 for all x."
2021-04-07 19:36:24 +02:00
Andreas Kling
6d8ca9871c LibGfx: Move underline closer to text in draw_ui_text() 2021-04-05 23:15:43 +02:00
Andreas Kling
89bc655765 LibGfx: Add Gfx::Painter::draw_ui_text()
This function draw text while interpreting "&" as "underline the next
character" and "&&" as "&".
2021-04-05 23:15:43 +02:00
Oleg Sikorskiy
b34f194168 LibGfx: Avoid float->double->float when converting from linear to gamma
Benchmark shows 5x speedup (from 644ms to 110ms).
2021-04-04 17:33:35 +02:00
Oleg Sikorskiy
a5db11c1f0 LibGfx: Use integer version of Bresenham's algorithm. 2021-04-03 23:59:37 +02:00
Andreas Kling
ea34ba6fa6 WindowServer+LibGfx: Rename menu_bar => menubar
We had a mix of "menu_bar" and "menubar". Let's just use "menubar"
everywhere since that feels the most natural to write.
2021-03-31 23:38:26 +02:00
Andreas Kling
0e798234c7 WindowServer+LibGfx: Remove code for drawing the old-style menu bar 2021-03-31 23:38:26 +02:00
Idan Horowitz
77601e09c8 FontEditor+TextEditor+Playground: Refuse to load device files
This prevents the undefined behaviour that would come up as a result of
doing so. (For example: opening "infinite" devices like /dev/full will
result in an infinite loop until exhaustion of memory)
2021-03-30 11:29:52 +02:00
Edgar Araújo
532e0090fc LibGUI: Enable the use of font properties through GML
You can now specify the font, font_size, font_weight
and font_type (fixed_width/normal) through GML
2021-03-29 09:10:23 +02:00
Luke
c3d4fbb2a5 LibGfx: Use zlib instead of just deflate when loading PNGs
PNGs use deflate with zlib, however we were just skipping the zlib
bytes and then piping it into deflate decompressor. Since we have a
zlib decompressor, lets use that instead.

This has the added benefit of extra error checking.
2021-03-28 20:40:44 +02:00
Andreas Kling
4b6fba1e4c WindowServer+LibGfx: Make menubar menus slightly larger
Also make sure the left/right padding is equally large.
2021-03-26 14:25:37 +01:00
Andreas Kling
e76771bfad WindowServer+LibGfx: Show menus in windows! :^)
This patch begins the transition away from the global menu towards
per-window menus instead.

The global menu looks neat, but has always felt clunky, and there
are a number of usability problems with it, especially in programs
with multiple windows.

You can now call GUI::Window::set_menubar() to add a menubar to
your window. It will be specific to that one window only.
2021-03-25 22:14:09 +01:00
Oleg
d0e7d45b85
LibGfx: Don't use target's alpha if it doesn't have one (#5888) 2021-03-21 09:40:14 +01:00
Oleg Sikorskiy
961137ea4c LibGfx: Don't truncate macroblock indices in JPG decoder. 2021-03-16 22:17:15 +01:00
Idan Horowitz
211031e4f4 LibGfx: Fail gracefuly on invalid interlace method in PNGLoader
This fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29791
2021-03-16 21:52:05 +01:00
Andreas Kling
fe861512c8 LibGfx: Add BitmapFormat::RGBA8888
This will be used by ImageData objects in LibWeb since the web spec
says these store colors in RGBA8888 order.

The only thing you can do with this format right now is blitting it
onto a BGRA8888 bitmap.
2021-03-16 12:09:15 +01:00
Andreas Kling
5023331726 LibGfx: Rename 32-bit bitmap StorageFormats to BGRA8888 and BGRx8888 2021-03-16 12:00:43 +01:00
Andreas Kling
e0f32626bc LibGfx: Rename 32-bit BitmapFormats to BGRA8888 and BGRx888x
The previous names (RGBA32 and RGB32) were misleading since that's not
the actual byte order in memory. The new names reflect exactly how the
color values get laid out in bitmap data.
2021-03-16 11:50:03 +01:00
Linus Groh
18a5ddfadd LibGfx: Draw window frame icon scaled to title_bar_icon_rect()
Partially fixes #5806.
2021-03-15 22:47:05 +01:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
thankyouverycool
142ca4b818 WindowServer+LibGfx: Enumerate Disallow cursor 2021-03-12 09:59:03 +01:00
thankyouverycool
5806630cf4 LibGfx+LibGUI: Add support for vertical ProgressBars 2021-03-12 09:59:03 +01:00
Ben Wiederhake
bceb98e2df Userland: Remove superfluous headers
Userland has no reason to access 'kmalloc'.
2021-03-11 12:32:53 +01:00
Andreas Kling
48347fb1c7 LibGfx: Make most of Gfx::Color constexpr 2021-03-06 19:57:35 +01:00
Stephan Unverwerth
87d19273bc LibGfx: Fix draw_triangle() precision issues
This fixes some precision issues in Painter::draw_triangle()
that caused the Cube demo to leave pixels empty between triangles
under certain angles.

Also adds some extra comments for clarity and early returns when
parts of the triangle do not need to be drawn.
2021-03-06 15:03:44 +01:00
Mihai Parparita
c2f3d3afe1 LibWeb: Make CSS background image painting respect destination origin and transparency
It was previously using draw_tiled_bitmap, which always aligns the
tiles with the global origin and does not respect the alpha of the
source. Switch to a new Painter::blit_tiled helper which uses
Painter::blit under the hood, which has more correct behavior.
2021-03-06 14:56:31 +01:00
Idan Horowitz
c12781a6a2 LibCore+LibHTTP+LibGfx: Switch to LibCompress
This commit removes the only 3rd party library (and its usages)
in serenity: puff, which is used for deflate decompression. and
replaces it with the existing original serenity implementation
in LibCompress. :^)
2021-03-03 23:42:32 +01:00
Mart G
de9f458ff5 SpaceAnalyzer: Reduce thickness of black borders between cells.
-Adds take_from_{left,right,top,bottom} to Rect.
2021-03-02 14:46:06 +01:00
Luke
ce5fe2a6e8 LibGfx: Fix read buffer overflow in interlaced GIF decode
Unfortunately 10420dee7e didn't quite fix it,
as the buffer overflow was actually happening here:
af22204488/Userland/Libraries/LibGfx/GIFLoader.cpp (L402)

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30507
2021-02-27 07:30:39 +01:00
Linus Groh
e265054c12 Everywhere: Remove a bunch of redundant 'AK::' namespace prefixes
This is basically just for consistency, it's quite strange to see
multiple AK container types next to each other, some with and some
without the namespace prefix - we're 'using AK::Foo;' a lot and should
leverage that. :^)
2021-02-26 16:59:56 +01:00
Tom
6cdb657493 LibGUI: Improve IconView rubberband performance
Rather than invalidating the entire window, which is very expensive on
the transparent desktop widget, just invalidate the areas that actually
need updating.
2021-02-25 18:04:06 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
be2b45b215 LibGfx: Make Painter::draw_physical_pixel() clip with scaling in mind 2021-02-22 21:46:39 +01:00
Andreas Kling
9100a1fde9 LibGfx: Don't color outside the lines in Painter::draw_physical_pixel()
Fixes #5422.
2021-02-22 11:44:57 +01:00
Andreas Kling
8aec1cd232 LibTTF: ScaledFont should have a NonnullRefPtr<TTF::Font>
A ScaledFont without an underlying TTF::Font would not be valid.
2021-02-17 23:45:21 +01:00
Andreas Kling
f24287e0e1 LibGfx: Oops, fix misaligned window buttons for WindowType::Normal 2021-02-16 16:57:45 +01:00
Andreas Kling
11c8596ad3 WindowServer+LibGUI+LibGfx: Add WindowType::ToolWindow
Tool windows are secondary windows with a smaller title bar. The sit on
the layer above normal windows, and cannot be minimized.

These are intended for complex yet non-modal interactions with the
content of a primary window, such as find/replace windows, property
windows, etc.
2021-02-16 16:26:29 +01:00
Andreas Kling
57a345a590 LibGfx: Remove debug spam from FontDatabase lookups 2021-02-16 13:12:41 +01:00
Tom
d590e0c946 WindowServer: Add support for alpha channel based hit testing
This enables implementing non-rectangular window shapes, including
non-rectangular window frames.
2021-02-15 23:07:49 +01:00
Stephan Unverwerth
3b67b55c84 LibGfx: draw_glyph_or_emoji fix check for available glyph
This would cause question marks to be rendered when a ttf with fewer
glyphs than the value of the code_point was used.
2021-02-15 08:50:48 +01:00
Stephan Unverwerth
b8c25bc7ff LibGfx: Remove static load_from_file() from abstract Font class 2021-02-15 08:50:48 +01:00
Stephan Unverwerth
79dfe9846d LibGfx: Generalize glyph placement in Painter 2021-02-15 08:50:48 +01:00
Stephan Unverwerth
85158dc0ad LibGfx+LibTTF: Allow Painter to draw TTF glyphs 2021-02-15 08:50:48 +01:00
Stephan Unverwerth
0f41f5d9ba LibGUI+LibGfx+LibTTF: Make fontpicker handle TTF fonts 2021-02-15 08:50:48 +01:00
Stephan Unverwerth
5a70ccecb3 LibGfx: Add more query methods to FontDatabase and Typeface 2021-02-15 08:50:48 +01:00
Stephan Unverwerth
e504d4ef96 LibGfx: Add Color::multiply() for component wise multiplication 2021-02-15 08:50:48 +01:00
Stephan Unverwerth
179dba652e LibGfx: Insert pixel and ttf fonts into Typeface structure
This adds a new structure 'Typeface' to the FontDatabase that
represents all fonts of the same family and variant.
It can contain a list of BitmapFonts with varying size but of
the same family and weight or a pointer to a single TTF font
for all sizes of this Typeface.
2021-02-15 08:50:48 +01:00
Tom
ddbd88d5c6 LibGfx: Enable Painter::blit to apply opacity and mix alpha channels
This enables us to properly render windows that use both opacity and
alpha channels.
2021-02-13 19:57:31 +01:00
Tom
0138f13bfe WindowServer: Improvements to support alpha channel in window frames
This fixes some issues handling the alpha channel that may be present
in rendered window frames.

Fixes #5303
2021-02-13 00:39:33 +01:00
Tom
cf1c159ed5 WindowServer: Allow different shadows for active/inactive windows
Also allow specifying different shadows for the task and menu bar.
2021-02-11 23:36:11 +01:00
Tom
130d48fa13 LibGfx: Painter::blit_filtered should take into account alpha value
If either the destination or calculated source pixel color contains
an alpha value, we should blend them together.
2021-02-11 13:11:57 +01:00
Tom
a807d92a32 WindowServer: Fix switching between shadows and no shadows with themes
We weren't properly handling switching between having a shadow and
not having a shadow when switching themes. This allows an empty string
in the theme configuration for a shadow path, meaning no shadow should
be rendered.
2021-02-10 09:12:49 +01:00
Tom
964894dee6 WindowServer: Allow specifying different shadows for menus and tooltips
Also update the Redmond 2000 theme to drop shadows more Redmond-like.
2021-02-09 22:27:14 +01:00