Commit Graph

187 Commits

Author SHA1 Message Date
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 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 1423bac3aa Smooth fading of plot grid and tick labels 2021-05-10 18:13:22 +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 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 0b52813f62 Sort demo windows (multi-touch demo was out of order) 2021-05-09 10:09:05 +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
Emil Ernerfeldt 268ddca161 demo_app: Remove screen_reader from default features
closes https://github.com/emilk/egui/issues/338
2021-05-08 16:27:41 +02:00
Emil Ernerfeldt 7374ed9d00 epi/eframe: move options out of `trait App` into new `NativeOptions` 2021-05-08 10:14:56 +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
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
Emil Ernerfeldt 1394205f52 Document and demonstrate how to expand a TextEdit to fill a Ui 2021-05-02 21:57:51 +02:00
Emil Ernerfeldt 7da9928548 Clean up new code editor code 2021-05-02 19:28:02 +02:00
Cristian Dinu 35c7b09285
Tab identation for multiline text edit (#246)
Lock focus on multiline text edit, and insert tabs on tab char

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-05-02 18:56:28 +02:00
Emil Ernerfeldt c2744a1437
Implement trackpad pinch-to-zoom for plots in egui_web (#333)
This adds a new `zoom_delta` to input.
This is hooked up to ctrl-scroll on egui_web and egui_glium.

Browsers convert trackpad pinch gestures to ctrl-scroll,
so this means you can not pinch-to-zoom plots (on trackpad).

In the future we can support multitouch pinch-to-zoom via the same
`InputState::zoom_factor()` function
2021-04-25 17:04:34 +02:00
Sven Niederberger a505d01090
Plot refactor (#331)
* drag and zoom support for plots

* update doctest

* use impl ToString

* revert back to Into<String> until #302 is solved

* Apply suggestions from code review

Co-authored-by: ilya sheprut <optitel223@gmail.com>

* use persistence feature for PlotMemory

* * split plot into multiple files
* add curve from function
* move more functionality into ScreenTransform struct

* changes from code review in base branch

* let user specify a range for generated functions

* rename file

* minor changes

* improve generator functionality

* improve callback and add parametric callback

* minor changes

* add documentation

* fix merge issues

* changes based on review

* rename folder

* make plot.rs the mod.rs file

* remove mod.rs

* rename file

* namespace changes

* fix doctest

* Update egui/src/widgets/plot/items.rs

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

Co-authored-by: ilya sheprut <optitel223@gmail.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-04-24 14:26:54 +02:00
Emil Ernerfeldt 6b24dbc997 Move easy_mark from egui deo egui_demo_lib 2021-04-24 01:18:08 +02:00
Sven Niederberger 012542d066
Drag and zoom support for plots (#317)
* drag and zoom support for plots

* update doctest

* use impl ToString

* revert back to Into<String> until #302 is solved

* Apply suggestions from code review

Co-authored-by: ilya sheprut <optitel223@gmail.com>

* use persistence feature for PlotMemory

* rename shift -> translate

* remove automatic bounds

* removed unused methods

* Into<String> -> ToString

* Apply suggestions from code review

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

* avoid potential invalid bounds bug

* use new is_valid method

* improve auto bounds behavior as suggested

* use NOTHING to initialize min_auto_bounds

Co-authored-by: ilya sheprut <optitel223@gmail.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-04-21 21:50:27 +02:00
ilya sheprut c69ecfe421
Memory usage example in the widget gallery (#307)
* init example

* add comments

* fix grammar in comments

* fix CI

* change example from view_edit to password

* rename file

* fix CI
2021-04-18 10:13:08 +02:00
Emil Ernerfeldt 580d27e0d3
Add anchors to windows and areas (#310)
This is so that you can put a window in e.g. the top right corner
or the center of the screen.
2021-04-18 10:01:41 +02:00
Emil Ernerfeldt 76d5229821
CI: run cargo doc (#309)
* Deny doc errors

* Add intentional bad intradoc link to test CI

* Add cargo doc to CI

* Fix carg doc web (add wasm32 target)

* Fix intentionally broken doc-link
2021-04-15 10:35:15 +02:00
Emil Ernerfeldt daf2e13238 demo: Use new id_data to store the show/hide password toggle 2021-04-12 22:37:39 +02:00
Emil Ernerfeldt 3803d0f3d1 Minor cleanup of the demo code 2021-04-05 14:23:42 +02:00
Emil Ernerfeldt 4b9db0cc55 Rename ui.advance_cursor to ui.add_space 2021-04-02 10:13:06 +02:00
Emil Ernerfeldt d848b2a664 Add TextEdit::password to hide input characters 2021-04-02 09:58:55 +02:00
Emil Ernerfeldt 1c955e56fe Some code cleanup 2021-04-01 23:07:58 +02:00
Emil Ernerfeldt f6770f0183 Various spelling fixes, docs improvements and code cleanup 2021-03-31 23:12:42 +02:00
Emil Ernerfeldt 3450168e94 egui_glium: add support for transparent windows
Also support non-decorated windows (without border)
2021-03-31 20:53:13 +02:00
Emil Ernerfeldt 0a21b01c31 Fix nightly build: remove deprecated missing_crate_level_docs lint
Closes https://github.com/emilk/egui/issues/250 and
https://github.com/emilk/egui/pull/251
2021-03-31 20:00:22 +02:00
Emil Ernerfeldt 5011623744 Deprecate old DragValue constructors in favor of DragValue::new 2021-03-27 16:09:09 +01:00
Emil Ernerfeldt de439b6e21 Deprecate old Slider constructors in favor of Slider::new 2021-03-27 16:07:18 +01:00
Emil Ernerfeldt 41c9de2734 Add new ComboBox builder to replace the combo_box_with_label function 2021-03-27 10:35:40 +01:00
Emil Ernerfeldt 70c6f4596a Add checkbox in demo app to turn screen reader on/off 2021-03-24 21:35:29 +01:00
Emil Ernerfeldt fd3444473f Add some clippy lints 2021-03-23 19:53:31 +01:00
Emil Ernerfeldt f5c372910c Replace emath::clamp with f32::clamp (new in rustc 1.50) 2021-03-21 17:47:03 +01:00
Emil Ernerfeldt ed0d406698 Improve misc documentation
Closes https://github.com/emilk/egui/issues/229
2021-03-21 17:13:58 +01:00
Emil Ernerfeldt f77ab26828 [EasyMark] Add support for small and raised text 2021-03-21 15:11:12 +01:00
Emil Ernerfeldt eaa1ed96ee Depcrecate ui.horizontal_for_text and ui.horizontal_wrapped_for_text
They just add unnecessary complexity at this point
2021-03-21 14:48:16 +01:00
Emil Ernerfeldt 953d2bb39b Add ui.set_row_height 2021-03-21 14:48:16 +01:00
Emil Ernerfeldt 958aea922f Add a lot more CursorIcon's 2021-03-13 12:38:03 +01:00
Emil Ernerfeldt 017d602fe5 Rename "kb_focus" to just "focus" everywhere 2021-03-09 20:55:24 +01:00
Tomáš Vojtášek f07f9bf5bd
Typo previus -> previous (#214) 2021-03-09 18:57:45 +01:00
Emil Ernerfeldt ea248d66b5 Improve widget info output for potential screen readers
Part of https://github.com/emilk/egui/issues/167
2021-03-08 18:36:32 +01:00
Emil Ernerfeldt 1c06622dbc Hold down a modifier key when clicking a link to open it in a new tab 2021-03-08 17:48:23 +01:00
Emil Ernerfeldt c212d4512e Clarify behavior of window resizing
closes https://github.com/emilk/egui/issues/206
2021-03-07 20:15:42 +01:00
Emil Ernerfeldt d6233de9dc Small improvements to the demo (add source code links etc) 2021-03-07 19:51:07 +01:00
Emil Ernerfeldt cd4c07e09a Output events when widgets gain keyboard focus
Part of https://github.com/emilk/egui/issues/167
2021-03-07 19:45:20 +01:00
Emil Ernerfeldt 9c8439d053 Add some helper functions to Response 2021-03-06 10:48:39 +01:00
Emil Ernerfeldt f793ac7f3e [demo] Remove dead code 2021-02-28 20:11:37 +01:00
Emil Ernerfeldt 1fb3b43dfc [demo] Improve painting demo slightly 2021-02-28 19:50:47 +01:00
Emil Ernerfeldt 84cc227f11 eframe: always provide a texture allocator 2021-02-28 19:09:48 +01:00
Emil Ernerfeldt d3fd51d6a4 Add Response::changed(): see if e.g. text was entered or slider dragged 2021-02-28 17:24:07 +01:00
Emil Ernerfeldt 5f6a468812 Add Context::set_pixels_per_point to control the scale of the UI 2021-02-21 11:23:33 +01:00
Emil Ernerfeldt ebc2486d22 Slider: use a DragValue for the value, and implement suffix/prefix 2021-02-20 18:29:09 +01:00
Emil Ernerfeldt 4e041185f1 Add module special_emojis with apple, linux, windows & github logos 2021-02-20 16:09:00 +01:00
Emil Ernerfeldt 6354709fe1 [demo] Link to the egui docs from the widget gallery 2021-02-20 12:07:15 +01:00
Emil Ernerfeldt 040553da78 impl<F> Widget for F where F: FnOnce(&mut Ui) -> Response
This enables functions that return `impl Widget`, so that you can
create a widget by just returning a lambda from a function.

For instance: `ui.add(toggle(bool))` (instead of `toggle(ui, bool)`)
2021-02-20 12:02:38 +01:00
Emil Ernerfeldt 6fe70e685b Simplify and unify colors of selectable widgets 2021-02-20 11:28:00 +01:00
Emil Ernerfeldt 21c99e1130 Add Ui::hyperlink_to 2021-02-20 09:26:58 +01:00
Emil Ernerfeldt 9e38674d13 [demo] Alwyas start with widget gallery 2021-02-20 09:19:40 +01:00
Emil Ernerfeldt 0f13fff24b Assign default colors to plot lines if not explicitly set 2021-02-18 18:59:59 +01:00
Emil Ernerfeldt a19140ec67 A simple 2D plot library 2021-02-17 22:54:10 +01:00
Emil Ernerfeldt 7dad76b913 Use explicit `epaint` over `paint` alias (re-export)
egui reexports the `epaint` crate both under its original name
and under the alias `paint` (for historical reasons)
2021-02-14 10:53:39 +01:00
Emil Ernerfeldt 6d255cd179 Use explicit `emath` to `math` alias
egui exports `emath` under its original name AND under the alias `math`
(for historical reasons).
2021-02-14 10:44:46 +01:00
Emil Ernerfeldt c376d0bb7e [emath] RectTransform: transforms Pos2 from one Rect to another
Very useful for transforming coordinate systems, e.g. for painting
2021-02-14 10:33:44 +01:00
Emil Ernerfeldt dbc6a620cd Control the maximum egui web canvas size with App::max_size_points 2021-02-12 17:58:02 +01:00
Emil Ernerfeldt 6377a4231f [demo] Refactor and minor cleanup 2021-02-07 17:04:03 +01:00
Emil Ernerfeldt e82fb81f07 Replace (ret, response) tuples with new struct InnerResponse 2021-02-07 14:09:44 +01:00
Emil Ernerfeldt df4c0257c0 Add Ui functions for doing manual layout ("put this widget here") 2021-02-07 13:48:55 +01:00
Emil Ernerfeldt bca722ddf8 Add ui.set_enabled(false) to disable all widgets in a Ui
Closes https://github.com/emilk/egui/issues/50
2021-02-07 10:55:45 +01:00
xue-blood ce14fa860b
Speed up fractal_clock painting (#152)
clip unwatchable line before drawing
2021-02-06 16:59:46 +01:00
Emil Ernerfeldt 26f966563a Add Grid::max_col_width 2021-02-06 16:54:38 +01:00
Emil Ernerfeldt 2d9d06dbff [emath] Use const values for Vec2::ZERO, Rect::EVERYTHING etc 2021-02-05 10:11:39 +01:00
Emil Ernerfeldt 0f37b009d6 Add TextEdit::hint_text for showing a weak hint text when empty 2021-02-03 21:06:50 +01:00
Lucas Walter 4e7e128b2b
Spelling ui_resouce -> ui_resource (#156) 2021-02-03 20:04:57 +01:00
Emil Ernerfeldt af3195f086 Add ctx.set_visuals() 2021-02-03 19:38:50 +01:00
Emil Ernerfeldt a19fd7b780 Add light mode 2021-02-03 19:30:58 +01:00
Emil Ernerfeldt 829455b347 Add `ui.group(|ui| { … })` to visually group some widgets within a frame 2021-02-03 00:25:07 +01:00
Emil Ernerfeldt ca886ea998 Add ui.visuals() as short for ui.style().visuals 2021-02-03 00:20:39 +01:00
Emil Ernerfeldt 01fca2f31c Add Ui::spacing() and Ui::spacing_mut() as shortcuts 2021-02-01 16:56:29 +01:00
Emil Ernerfeldt e529bd3ea4 [demo] Make syntect an optional dependency
Adds a whopping 1.4 MB to the WASM
2021-01-31 16:52:26 +01:00
Emil Ernerfeldt 16d66bd22d Replace markdown editor with new 'EasyMark' markup language 2021-01-31 16:42:32 +01:00
Emil Ernerfeldt 6029a438a2 Add a VERY experimental markdown viewer 2021-01-27 20:14:53 +01:00
Emil Ernerfeldt b493bc6efc Wrap tesselated output in struct ClippedMesh(Rect, Mesh) 2021-01-25 21:43:17 +01:00
Emil Ernerfeldt 75fa77e040 Rename Triangles to Mesh 2021-01-25 21:23:24 +01:00
Emil Ernerfeldt 63e4ff4382 [demo] Move layout demo to own window 2021-01-25 20:52:47 +01:00
Emil Ernerfeldt 749419c9fd [demo] Improve scroll demo and move to own window 2021-01-25 20:52:31 +01:00
Emil Ernerfeldt 5e3a89bf00 [demo] Move slider demo to own window 2021-01-25 20:14:39 +01:00
Emil Ernerfeldt 6d57a24f35 Add Slider::clamp_to_range(bool) 2021-01-25 19:55:08 +01:00
Emil Ernerfeldt 247026149c
Multiple mouse button support (#135)
Add support for primary, secondary and middle mouse buttons. Also improve ability to click things in low FPS situations.

This introduces a lot of breaking changes:

    Backends/integrations now pass mouse events via the even stream.
    Response has an interface of mostly methods instead of public members.
    input.mouse is now input.pointer and has new interface.


* Rename 'mouse' to 'pointer' everywhere (pointer = mouse or touch)

* Make Response::clicked and Response::double_clicked into methods

* Remove Response::active and add dragged() and interact_pointer_pos()

* Support multiple mouse buttons

* Make PointerState interface all methods

* Make most members of Response private
2021-01-25 18:50:19 +01:00
Emil Ernerfeldt 9f4c31c0e0 Add Frame::group for putting a frame around some widgets
Closes https://github.com/emilk/egui/issues/125
2021-01-20 23:26:46 +01:00
Emil Ernerfeldt e2217ff63a [style] Fade out windows on close 2021-01-20 00:31:43 +01:00
Emil Ernerfeldt 29bb7c9f9d egui_demo_lib 0.8.1: export ColorTest 2021-01-19 17:13:29 +01:00
Emil Ernerfeldt 31b7eda51e Rename Egui to egui
Also update iamges in README.md
2021-01-17 14:48:59 +01:00
Emil Ernerfeldt 07f1b074ca [grid] Allow putting a separator in a grid 2021-01-16 11:48:30 +01:00
Emil Ernerfeldt 620e43d483 New sleeker visual style
Remove a lot of borders, remove transparency, simplify and unify.
2021-01-15 22:23:08 +01:00