Commit Graph

728 Commits

Author SHA1 Message Date
Emil Ernerfeldt ece25ee7f3 Add `Ui::set_visible` as a way to hide widgets
Closes https://github.com/emilk/egui/issues/460
2021-06-07 22:12:49 +02:00
Emil Ernerfeldt 3c603c55b8 Make Layouts:: horizontal/vertial align/justify pub 2021-06-07 21:06:29 +02:00
Emil Ernerfeldt 2af86cd2c7
Revert "Fix scroll bar position (#392)" (#458)
This reverts commit 2932ff0e53.
2021-06-04 00:11:35 +02:00
Jay Oster 2932ff0e53
Fix scroll bar position (#392)
* Fix scroll bar position

* Always position scroll bar on the right side of the ScrollArea inner rect

* Fix the clipping rect
2021-06-03 18:54:34 +02:00
Emil Ernerfeldt 6468b2b84e
Implement efficent scrolling of large content (#457) 2021-06-03 18:48:45 +02:00
Tiago Ferreira 2cdd90b111
Allow alternate shortcuts on Windows (#456) 2021-06-03 17:39:55 +02:00
Emil Ernerfeldt 4964d762a7 Move WidgetType from output.rs to lib.rs 2021-05-30 22:53:10 +02:00
Emil Ernerfeldt 3b807e1ad6 Add Context::set_debug_on_hover and egui::trace!(ui) 2021-05-27 19:30:08 +02:00
Sven Niederberger 8623909d82
Plotting: Add line markers (#363)
* 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>
2021-05-27 18:40:20 +02:00
Emil Ernerfeldt c9766f8a7b
Resizable panels + right and bottom panels (#438)
* Side panel resizing and add right panels

* Add resizable top/bottom panels

* Deprecate TopPanel

* Final tweaks and update CHANGELOG.md
2021-05-26 22:06:10 +02:00
Emil Ernerfeldt 196ddff499 Rename Shape::polygon to Shape::convex_polygon
epaint only supports filling convex polygons (for now)
2021-05-20 22:14:08 +02:00
Emil Ernerfeldt 085233f907 Improve various documentation 2021-05-20 22:12:17 +02:00
Emil Ernerfeldt 2dea4d8db2 Color picker: fix rare infinite loop in very weird situtations 2021-05-20 22:05:44 +02:00
Emil Ernerfeldt f4ddc21740 Simplify IME cursor pos handling in TextEdit 2021-05-20 22:01:59 +02:00
Emil Ernerfeldt 6a576f4c34 Rename Output::text_cursor to text_cursor_pos 2021-05-20 21:58:44 +02:00
Emil Ernerfeldt 8cce09687f Expose text layout functions in Painter 2021-05-20 21:53:39 +02:00
Emil Ernerfeldt 94479317b3 Add #[must_use] to container types: remind to call show() 2021-05-20 21:45:00 +02:00
Emil Ernerfeldt a892519297 Add Style::override_text_style
Add Style::override_text_style to easily change the text style
of everything in a `Ui` (or globally).

You can now change `TextStyle` on checkboxes,
radio buttons and `SelectableLabel`.

Closes https://github.com/emilk/egui/issues/406
Closes https://github.com/emilk/egui/pull/407
2021-05-20 21:31:34 +02:00
Zenithsiz 57981d49ee
Add support for buffers other than a `String` in `TextEdit` (#399)
* 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>
2021-05-20 21:00:50 +02:00
Wojciech Kępka d292b831a1
Add an option to overwrite frame of `SidePanel` and `TopPanel` (#418)
* Add an option to overwrite frame of SidePanel and TopPanel

* Update CHANGELOG
2021-05-20 20:10:30 +02:00
Gray Olson c0929014bf
Add support for `cint` (conversions to and from color types) (#393)
* 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
2021-05-20 20:09:52 +02:00
St John Giddy ac82cc7be3
fix(plot): expose VLine and HLine (#422) 2021-05-20 19:56:45 +02:00
Emil Ernerfeldt 5bc53ce069 Improve panel docs
Related to https://github.com/emilk/egui/issues/421
2021-05-20 19:48:34 +02:00
Violeta Hernández de02f7d042
Value of `DragValue` correctly clamped (#405)
* Update drag_value.rs

* `value` → `old_value`
2021-05-18 20:03:04 +02:00
Emil Ernerfeldt dd4ac43b13 Make sure egui can handle zero-sized screen rect
This would previously hit a debug assert

Fixes https://github.com/emilk/egui/issues/395
2021-05-17 22:53:52 +02:00
Emil Ernerfeldt 6e5b52e3bc Add features extra_asserts and extra_debug_asserts for more asserts
This replaces all debug_asserts with these opt-in asserts

Related: https://github.com/emilk/egui/issues/395
2021-05-17 22:38:39 +02:00
Sven Niederberger bfabb70cba
Fix BottomUp layout (#386) 2021-05-15 09:37:33 +02:00
Emil Ernerfeldt 2f46c975a5 Fix wrong vertical align in default layout
Only seen when having unusually high buttons
2021-05-13 23:15:44 +02:00
Emil Ernerfeldt 7b0f991b20 Improve docs concerning custom fonts, themes and accessibility
Closes https://github.com/emilk/egui/pull/370
Closes https://github.com/emilk/egui/issues/372
2021-05-11 14:56:27 +02:00
Emil Ernerfeldt 8f8ba16696 Release 0.12.0 - Multitouch, user memory, window pivots, and improved plots 2021-05-10 18:27:39 +02:00
Emil Ernerfeldt 1423bac3aa Smooth fading of plot grid and tick labels 2021-05-10 18:13:22 +02:00
Emil Ernerfeldt cf3d12669c Fix misc typos
Closes https://github.com/emilk/egui/pull/366
Closes https://github.com/emilk/egui/pull/365
2021-05-10 10:52:49 +02:00
Emil Ernerfeldt b1559963bf Enable a bunch more clippy lints 2021-05-09 14:13:09 +02:00
Emil Ernerfeldt 4022b84ae7 group rustdoc lints under rustdoc:: prefix 2021-05-09 14:01:57 +02:00
Emil Ernerfeldt fb5176c133 #![allow(clippy::float_cmp)] everywhere
it has always been an annoyance, never a help
2021-05-09 14:00:53 +02:00
Emil Ernerfeldt 38186fe23e Add a TODO 2021-05-09 13:20:27 +02:00
Emil Ernerfeldt 5a21bc78a6 minor code simplification 2021-05-09 13:19:09 +02:00
Emil Ernerfeldt a8c3deaf08 Rename `ui.wrap` to `ui.scope` 2021-05-09 13:17:32 +02:00
Emil Ernerfeldt 9dc092b778 Clean up demos 2021-05-09 13:07:56 +02:00
Emil Ernerfeldt aa3c40c49f bug fix: don't lock focus by default 2021-05-09 11:17:32 +02:00
Emil Ernerfeldt 4bb79a7047 Move normalize_angle to emath 2021-05-08 23:42:17 +02:00
Emil Ernerfeldt dd6980bacb Implement non-proportional multitouch pinch zooming 2021-05-08 23:31:31 +02:00
Emil Ernerfeldt 04d9ce227b Tidy up multitouch code: remove double spaces after full stop
Weirdest thing I've seen in my life.
2021-05-08 22:49:40 +02:00
follower a5e41f275c
Typo: `CollpasingHeaders` -> `CollapsingHeaders` (#359) 2021-05-08 16:24:22 +02:00
Emil Ernerfeldt 5e46bd404c Some documentation improvements 2021-05-08 09:25:52 +02:00
Luis Wirth 87bc26fb5a
implement mint conversions (#352)
* Implement mint conversions

Implement conversions for [mint](https://docs.rs/mint) (math interoperability standard types).

- `impl {From, Into}<mint::Point2> for Pos2`
- `impl {From, Into}<mint::Vector2> for Vec2`

* Forward `mint` feature: egui -> epaint -> emath
2021-05-08 08:17:01 +02:00
Sven Niederberger 838f3e4ff2
Add plot legends (#349)
* add plot legends

* don't show crosshairs when hovering over legend

* add a toggle for the legend

* changes based on review

* improve legend behavior when curves share names
2021-05-07 10:32:17 +02:00
Emil Ernerfeldt d862ff66ac Add Image::sense to let an image respond to clicks and drags 2021-05-06 22:10:05 +02:00
Ivo Vollrath 03721dbfd8
Basic multi touch support (issue #279) (#306)
* translate touch events from glium to egui

Unfortunately, winit does not seem to create _Touch_ events for the touch pad
on my mac.  Only _TouchpadPressure_ events are sent.

Found some issues (like
[this](https://github.com/rust-windowing/winit/issues/54)), but I am not sure
what they exactly mean:  Sometimes, touch events are mixed with
touch-to-pointer translation in the discussions.

* translate touch events from web_sys to egui

The are a few open topics:
- egui_web currently translates touch events into pointer events.
  I guess this should change, such that egui itself performs this kind of
  conversion.
- `pub fn egui_web::pos_from_touch_event` is a public function, but I
  would like to change the return type to an `Option`.  Shouldn't this
  function be private, anyway?

* introduce `TouchState` and `Gesture`

InputState.touch was introduced with type `TouchState`, just as
InputState.pointer is of type `Pointer`.

The TouchState internally relies on a collection of `Gesture`s.  This commit
provides the first rudimentary implementation of a Gesture, but has no
functionality, yet.

* add method InputState::zoom()

So far, the method always returns `None`, but it should work as soon as the
`Zoom` gesture is implemented.

* manage one `TouchState` per individual device

Although quite unlikely, it is still possible to connect more than one touch
device. (I have three touch pads connected to my MacBook in total, but
unfortunately `winit` sends touch events for none of them.)

We do not want to mix-up the touches from different devices.

* implement control loop for gesture detection

The basic idea is that each gesture can focus on detection logic and does not
have to care (too much) about managing touch state in general.

* streamline `Gesture` trait, simplifying impl's

* implement first version of Zoom gesture

* fix failing doctest

a simple `TODO` should be enough

* get rid of `Gesture`s

* Provide a Zoom/Rotate window in the demo app

For now, it works for two fingers only.  The third finger interrupts the
gesture.

Bugs:
- Pinching in the demo window also moves the window -> Pointer events must be
  ignored when touch is active
- Pinching also works when doing it outside the demo window -> it would be nice
  to return the touch info in the `Response` of the painter allocation

* fix comments and non-idiomatic code

* update touch state *each frame*

* change egui_demo to use *relative* touch data

* support more than two fingers

This commit includes an improved Demo Window for egui_demo, and a complete
re-write of the gesture detection.  The PR should be ready for review, soon.

* cleanup code and comments for review

* minor code simplifications

* oops – forgot the changelog

* resolve comment fee8ed83db (r623226656)

* accept suggestion https://github.com/emilk/egui/pull/306#discussion_r623229228

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* fix syntax error (dough!)

* remove `dbg!` (why didnt clippy see this?)

* apply suggested diffs from review

* fix conversion of physical location to Pos2

* remove redundanct type `TouchAverages`

* remove trailing space

* avoid initial translation jump in plot demo

* extend the demo so it shows off translation

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-05-06 21:01:10 +02:00
Emil Ernerfeldt 0d71017ad4 clippy fixes for rust 1.52 2021-05-06 20:49:22 +02:00