Label text will now be centered, right-aligned and/or
justified based on the layout.
Galleys are no longer always pivoted in the left top corner,
so now have a Rect rather than just a size.
This PR introduces a completely rewritten text layout engine which is simpler and more powerful. It allows mixing different text styles (heading, body, etc) and formats (color, underlining, strikethrough, …) in the same layout pass, and baked into the same `Galley`.
This opens up the door to having a syntax-highlighed code editor, or a WYSIWYG markdown editor.
One major change is the color is now baked in at layout time. However, many widgets changes text color on hovered. But we need to do the text layout before we know if it is hovered. Therefor the painter has an option to override the text color of a galley.
## Performance
Text layout alone is about 20% slower, but a lot of that is because more tessellation is done upfront. Text tessellation is now a lot faster, but text layout + tessellation still lands at a net loss of 5-10% in performance. There are however a few tricks to speed it up (like using `smallvec`) which I am saving for later. Text layout is also cached, meaning that in most cases (when all text isn't changing each frame) text tessellation is actually more important (and that's more than 2x faster!).
Sadly, the actual text cache lookup is significantly slower (300ns -> 600ns). That's because the `TextLayoutJob` is a lot bigger (it has more options, like underlining, fonts etc), so it is slower to hash and compare. I have an idea how to speed this up, but I need to do some other work before I can implement that.
All in all, the performance impact on `demo_with_tesselate__realistic` is about 5-6% in the red. Not great; not terrible. The benefits are worth it, but I also think with some work I can get that down significantly, hopefully down to the old levels.
* First pass (missing rendering the bar)
* Render horizontal bars, and change Window scroll API
* emath: add impl Index + IndexMut for Align2
* Scrolling: fix subtle sizing bugs
* Add horizontal scrolling to color test
* try to wrap content before showing scrollbars, + add auto-shrink option
* Add hscroll to the misc demo window
* Fix for putting wrapping labels in an infinitely wide layout
* Add a egui_asserts to protect against nans in the layout engine
* Add line about horizontal scrolling to changelog
* Add example to docs of ScrollArea
* code cleanup
* Fix incorrect max_width/height of panels
* Fix set_width/set_min_width/set_height/set_min_height
Closes https://github.com/emilk/egui/issues/647
Broke in https://github.com/emilk/egui/pull/629
* Fix expand_to_include_x/expand_to_include_y
* Make minimum grid column width propagate properly
* Expand cursor when max_rect expands
* Add ui.expand_to_include_y
* Only expand cursor in advance
* demo: clean up font_book code
* Fix: Make sure `TextEdit` contents expand to fill width if applicable
* ProgressBar: minimum width and fix for having it in an infinite layout
* clippy fix
* Add methods for optionally displaying the background/axes of a `Plot`
These are particularly useful when using the `Plot` widget as an overlay
over an existing grid or some other content.
* Allow for showing each axis of a `Plot` individually
* Fix case where `Plot`'s `min_auto_bounds` can be ignored after first
I ran into an issue using `Plot` within my timeline widget where if I
zoom in and out of the timeline (not the plot), the `Plot` instances
would ignore the necessary changes to the `include_x` calls and in turn
would become skewed and misaligned with the timeline below.
This changes the `Plot` to check whether or not `min_auto_bounds` have
changed and, if so, reset the memory and recalculate the bounds.
See #562 for an image of my current use case.
* Carry hidden_items when updating plot for changed bounds
* added new line styles
* update changelog
* fix#524
Add missing functions to `HLine` and `VLine`
* add functions for creating points and dashes from a line
* apply suggestions
* clippy fix
* address comments
This allows for resizaeable grids, where the last column will be given the remainder of the width.
To demonstrate, the widget gallery window is now resizeable.
* Added plot items:
* Arrows, also called "Quiver plots" in matplotlib etc.
* Convex polygons
* Text
* Images
Other changes:
* Make HLine/VLine into PlotItems as well.
* Add a "fill" property to Line so that we can fill/shade the area between a line and a horizontal reference line.
* Add stems to Points, which are lines between the points and a horizontal reference line.
* Allow using .. when specifying ranges for values generated by explicit callback functions, as an alias for f64::NEG_INFINITY..f64::INFINITY
* Allow using ranges with exclusive end bounds for values generated by parametric callback functions to generate values where the first and last value are not the same.
* update changelog
* add legend background
* Use old 1.51 toolchain instead of bleeding edge
1.52 and 1.53 has problems with incremental compilation,
so some people chose to stay on 1.51 for now.
So let's make sure egui supports 1.51 for a while!
* Update to cint 0.2.2 to get rust 1.51.0 compatability
* Tweak style
More compact, less round, less noisy
* Button text is now same size as body text
* The rounder corners are now less rounded
* Collapsing headers no longer have a frame around them
* Combo-boxes looks better when opened
* Slightly more muted colors
* Remove extra line spacing after `\n` (i.e. between paragraphs)
* Thinner scrollbars
* Tweak light mode
* Tweak shadows
* Fix broken doc link
* Add style tweak to CHANGELOG
* Make sure the scroll bar is never outside the screen rectangle
This is an alternative attempt to fix the bug mentioned in
https://github.com/emilk/egui/pull/392
egui expects that the container can always be made wider,
which is true for all egui Ui:s, but not true for the outer
frame/chrome that egui ultimately needs to sit within.
* Clamp scroll to screen rect rather than available rect
* Fix scrollbar spacing when shrinking too small
* Update changelog
* initial work on markers
* clippy fix
* simplify marker
* use option for color
* prepare for more demo plots
* more improvements for markers
* some small adjustments
* better highlighting
* don't draw transparent lines
* use transparent color instead of option
* don't brighten curves when highlighting
* Initial changes to lengend:
* Font options
* Position options
* Internal cleanup
* draw legend on top of curves
* update changelog
* fix legend checkboxes
* simplify legend
* remove unnecessary derives
* remove config from legend entries
* avoid allocations and use line_segment
* compare against transparent color
* create new Points primitive
* fix doctest
* some cleanup and fix hover
* common interface for lines and points
* clippy fixes
* reduce visibilities
* update legend
* clippy fix
* change instances of "curve" to "item"
* change visibility
* Update egui/src/widgets/plot/mod.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Update egui/src/widgets/plot/mod.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Update egui_demo_lib/src/apps/demo/plot_demo.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Update egui_demo_lib/src/apps/demo/plot_demo.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* changes based on review
* add legend to demo
* fix test
* move highlighted items to front
* dynamic plot size
* add legend again
* remove height
* clippy fix
* update changelog
* minor changes
* Update egui/src/widgets/plot/legend.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Update egui/src/widgets/plot/legend.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Update egui/src/widgets/plot/legend.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* changes based on review
* add functions to mutate legend config
* use horizontal_align
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* initial work on markers
* clippy fix
* simplify marker
* use option for color
* prepare for more demo plots
* more improvements for markers
* some small adjustments
* better highlighting
* don't draw transparent lines
* use transparent color instead of option
* don't brighten curves when highlighting
* update changelog
* avoid allocations and use line_segment
* compare against transparent color
* create new Points primitive
* fix doctest
* some cleanup and fix hover
* common interface for lines and points
* clippy fixes
* reduce visibilities
* Update egui/src/widgets/plot/mod.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Update egui/src/widgets/plot/mod.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Update egui_demo_lib/src/apps/demo/plot_demo.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Update egui_demo_lib/src/apps/demo/plot_demo.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* changes based on review
* fix test
* dynamic plot size
* remove height
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Initial design for `TextBuffer` trait, to allow `TextEdit` to edit types other than `String`.
* Moved `insert_text` implementation into `TextBuffer`.
This allows the user to implement text inserting depedent on their type instead of using a `String` and converting back to `S`, which may be a lossless convertion.
* Moved part of `delete_selected_ccursor_range` implementation into `TextBuffer::delete_range`.
* `TextBuffer::insert_text` not returns how many characters were inserted into the buffer.
This allows implementations to "saturate" the buffer, only allowing for a limited length of characters to be inserted.
* Now using `byte_index_from_char_index` instead of custom implementation.
* `decrease_identation` impl now modified the string in-place.
Removed `From<String>` bound for `TextBuffer`.
* Added changes to changelog.
* Moved updated changelog to .
* Updated documentation on `TextBuffer`.
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Renamed `TextBuffer::delete_text_range` to `delete_char_range`.
Co-authored-by: Filipe Rodrigues <filipejacintorodrigues1@gmail.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* implement cint for color types under feature flag
* upgrade to cint 0.2, remove from default features
* upgrade to cint 0.2.1, add a couple more from/into implementations
* changelog entry
* fix typo in changelog
* sort dependency
* fmt