Commit graph

73 commits

Author SHA1 Message Date
awaken1ng
30f9700f6c
egui-web: Update web_location_hash when hash in URL changes (#1140) 2022-01-21 19:41:18 +01:00
Emil Ernerfeldt
66d80e2519
Texture loading in egui (#1110)
* Move texture allocation into epaint/egui proper
* Add TextureHandle
* egui_glow: cast using bytemuck instead of unsafe code
* Optimize glium painter
* Optimize WebGL
* Add example of loading an image from file
2022-01-15 13:59:52 +01:00
Emil Ernerfeldt
d5673412dd
Put everything in Context behind the same Mutex (#1050)
* Move all interior mutability from Context to CtxRef and make it a handle
* Rename `CtxRef` to `Context`
* The old `Context` is now `ContextImpl` and is non-pub
* Add benchmark Painter::rect

Co-authored-by: Daniel Keller <dklr433@gmail.com>
2022-01-10 23:13:10 +01:00
Emil Ernerfeldt
b1fd6a44e8
Switch to using glow as the default renderer both on native and the web (#1020)
* Switch to using glow as the default renderer both on native and the web
* Simplify code to find WebGL context for glow
* egui_web: make webgl an opt-in feature
* Stop using deprecated WEBGL_debug_renderer_info
2021-12-31 15:17:55 +01:00
Emil Ernerfeldt
190c85a40f Rename Texture to FontImage 2021-12-28 21:19:24 +01:00
Emil Ernerfeldt
b7441eeee7
Make epi::Frame cloneable so you can allocate textures in other threads (#999)
Closes https://github.com/emilk/egui/issues/673

Also adds `epi::Image`
2021-12-26 21:21:28 +01:00
Emil Ernerfeldt
c60d17b91b
Set MSRV to 1.56.0 and use rust edition 2021 (#998) 2021-12-25 19:32:25 +01:00
Emil Ernerfeldt
49e43885ff
Replace Context::begin_frame/end_frame with fn run taking a closure (#872)
* Replace Context begin_frame/end_frame with `fn run` taking a closure
* Create `egui::__run_test_ui` to replace `Ui::__test`
* Add helper `egui::__run_test_ctx` for doctests
2021-11-03 20:11:25 +01:00
triangle drawer
804722a1ba
Make egui_glow painter to work on web (#868)
Add WebGL1 and WebGL2 support to glow painter.
Add "glow" feature to egui_web to use the glow painter there.
Make winit an optional part of egui_glow
2021-11-03 19:17:07 +01:00
Emil Ernerfeldt
1dbe608e73
Refactor integrations (#871)
* Unify code in egui_glium and egui_glow into egui_winit::EpiIntegration
* Simplify `EguiGlium` interface
* Simplify `EguiGlow` interface
* egui_web refactor: merge `WebBackend` into `AppRunner`
2021-11-03 13:45:51 +01:00
Emil Ernerfeldt
316202c33a egui_web: improve text input on mobile and for IME 2021-10-24 15:57:36 +02:00
Caleb Smith
79d1ede496
Add Frame::set_window_title() (#828)
* Add `Frame::set_window_title()`

* Changelog and fmt for `Frame::set_window_title()`

Co-authored-by: Caleb Smith <caleb@myrvmail.com>
2021-10-23 00:03:17 +02:00
Emil Ernerfeldt
8178d23d19
Deduplicate code found in both egui_glium and egui_glow (#819)
* Move window building to egui-winit

* Move icon loading to egui-winit

* `use glow::HasContext;` -> `use glow::HasContext as _;`

* Move FileStorage into epi behind a feature flag

* De-duplicate screen_size_in_pixels and native_pixels_per_point

* Move creation of FileStorage to epi

* Handle epi app output (window size changes etc) in egui-winit

* Move app and memory persistence and autosave logic to egui-winit

* fix check.sh

* Make the epi backend opt-in for egui_glium and egui_glow

* Fix persistence

* Add integration name to epi::IntegrationInfo and the demo

* Clean up Cargo.toml files and fix making egui_glium optional

* fix typo

* Make egui_glium compile without the `epi` feature
2021-10-19 21:40:55 +02:00
Emil Ernerfeldt
844dd9d7a4 Remove "seconds_since_midnight" from epi/eframe. Use chrono instead
chrono works both natively and on web.

Related: https://github.com/emilk/egui/issues/212
2021-10-19 15:37:20 +02:00
Emil Ernerfeldt
5539dbe620
Add separate serialize feature and better persitence control (#753)
* Rename epaint feature "persistence" to "serialize"

* Add separate "serialize" feature to egui

* egui_demo_lib: separate serialize and persistence features

* Add App::persist_native_window and App::persist_egui_memory

Controls what gets persisted
2021-09-29 08:45:13 +02:00
zu1k
f6fb4d942a
epi: drag native window (#728)
* feat: drag window

* Update epi/src/lib.rs

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

* Update egui_demo_lib/src/backend_panel.rs

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

* cargo fmt

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-09-28 17:34:58 +02:00
zu1k
19eed94499
feat: Set whether to show decorations (#672)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-09-07 21:42:14 +02:00
Emil Ernerfeldt
9598596bdc
Replace all http code in epi/eframe/egui_glium/egui_web with ehttp (#697)
I've extracted all the http request code and turned it
into its own crate at <https://github.com/emilk/ehttp>.

There was never a reason for the HTTP request library to be part of
`eframe`. Much better to have it as its own crate!
2021-09-03 21:04:43 +02:00
Emil Ernerfeldt
e98ae2ea7a
Revert "feat: Set whether to show decorations (#660)" (#671)
This reverts commit 0db74f3000.
2021-08-28 12:29:19 +02:00
zu1k
0db74f3000
feat: Set whether to show decorations (#660)
* feat: Set whether to show decorations

* cargo fmt

* Update comment and changelog
2021-08-28 11:18:36 +02:00
Emil Ernerfeldt
9bc95289cc
egui_web: Fix use of egui on devices with both touch and mouse (#654) 2021-08-28 08:37:07 +02:00
Emil Ernerfeldt
62f58a3b05 egui_web: default to light mode unless prefers-color-scheme: dark 2021-06-07 20:56:18 +02:00
Emil Ernerfeldt
44b573f6a6 epi: merge App::load into App::setup, and provide Frame argument
This gives users more control over the order of load/setup.

It also allows users to load textures in setup.
2021-06-07 20:53:33 +02:00
Emil Ernerfeldt
6a576f4c34 Rename Output::text_cursor to text_cursor_pos 2021-05-20 21:58:44 +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
1068750bbc Clean up egui_web code a bit 2021-04-01 23:07:15 +02:00
Lin Han
22cd1a8e10
Move IME candidate window following text cursor (#258)
* egui_web: enable IME support on web.

* Move candidate window following text cursor.

* Preclude too frequent agent movement.

* IME candidate window move on native app.
2021-03-30 08:48:55 +02:00
Lin Han
795282edc0
egui_web: enable IME support on web. (#253) 2021-03-26 13:56:26 +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
44cd304cdf Add experimental screen_reader feature
Part of https://github.com/emilk/egui/issues/167
2021-03-08 20:58:01 +01:00
Emil Ernerfeldt
84cc227f11 eframe: always provide a texture allocator 2021-02-28 19:09:48 +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
dbc6a620cd Control the maximum egui web canvas size with App::max_size_points 2021-02-12 17:58:02 +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
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
b869db728b [egui_web] Call prevent_default for arrow keys when entering text
Closes https://github.com/emilk/egui/issues/58
2021-01-17 12:24:17 +01:00
Emil Ernerfeldt
ef595153c9 [egui_web] Improve alpha blending + add WebGL2 painter 2021-01-16 20:48:00 +01:00
Emil Ernerfeldt
fb2317c993 Rename PaintCmd to Shape 2021-01-10 11:43:01 +01:00
Emil Ernerfeldt
5ef9f35d1e [epi] Simplify TextureAllocator interface 2021-01-07 16:29:58 +01:00
Emil Ernerfeldt
69d31a5e47 [eframe] Make persistence, http and time optional features
Saves on compile times.
2021-01-04 10:25:13 +01:00
Emil Ernerfeldt
73f3d8cf46 Rename Srgba to Color32 2021-01-02 17:02:18 +01:00
Emil Ernerfeldt
14a96ca5d0 Add a dummy warm-up frame to the demo app to pre-cache emojis 2021-01-02 14:42:43 +01:00
Emil Ernerfeldt
b1022d01c1 Rename epi::App::ui to epi::App::update 2021-01-01 20:22:18 +01:00
Emil Ernerfeldt
375e317547 Move http fetch api from eframe to epi 2021-01-01 14:54:26 +01:00
Emil Ernerfeldt
84414e62a3 Add new crate eframe which wraps egui, epi, egui_web and egui_glium 2020-12-29 15:57:13 +01:00
Emil Ernerfeldt
d7459bc13d Move egui::app into new epi crate 2020-12-29 14:15:46 +01:00
Emil Ernerfeldt
d38b16f1ea Learn how to spell to "tessellation" 2020-12-29 12:18:41 +01:00
Emil Ernerfeldt
fb941cf618 [egui_web] Simplify the arguments you pass to start() 2020-12-19 21:15:07 +01:00
Emil Ernerfeldt
89937bf636 [egui_web] Auto-save app state to Local Storage every 30 seconds 2020-12-19 20:50:00 +01:00