1
0
Fork 0
Commit graph

61 commits

Author SHA1 Message Date
Adrien Prokopowicz 65d970495f
Render a background for the open_window example (#175)
This PR adds code to render a basic gray background to the opened window in the `open_window` example.

This also helps making the example a bit more useful, since most users will want to render to their window.

And also it looks nicer. 🙂 

This is done using the `softbuffer` crate, in the same manner of the `open_parented` introduced in #172.
2024-03-25 18:41:39 -05:00
Adrien Prokopowicz 998ced845c
Added functional open_parented example (#172)
This PR adds a simple example that allows to test and showcase the `Window::open_parented` method.

That example first creates a parent window using `Window::open_blocking`, and then creates a smaller child window using `Window::open_parented`.

Both window's handlers log all of their events to the console, in a similar fashion to the `open_window` example.

Both windows actually do rendering (unlike the `open_window` example for now): the parent fills its window with a grey backround, and the child fills its window with a red background.

This example also uses the `softbuffer` crate to perform the rendering, which allows testing it in a more portable manner and in the simplest use case possible, without having to involve OpenGL or any 3D rendering pipeline at all.
2024-03-24 17:16:16 -05:00
Micah Johnston 92f1a19b81
Fix warnings in example (#158) 2023-12-16 19:29:27 -06:00
Taylor Holliday dbda356826 Use &str instead of String. 2023-02-22 10:14:54 -08:00
Taylor Holliday 9b1c3785c8 Linux build 2023-02-21 16:29:38 -08:00
Taylor Holliday 775d15df38 Simplify and use copy_to_clipboard. 2023-02-21 15:45:11 -08:00
Robbert van der Helm b4a3d2bb04 Add stubs for creating OpenGL contexts
There are now three todo!()s when compiling with the OpenGL flag that
need to be filled in, with the only nontrivial one being the X11
version.
2022-02-07 19:00:48 +01:00
Billy Messenger f6e99e9aa6
add ability to close window from user code, add HostWindowHandle (#103)
* add ability to close window from user code, add HostWindowHandle

* fix manual close method for Mac, rename HostWindowHandle to ChildWindowHandle

* fix rustfmt.toml and run cargo format

* fix merge conflict mistake

* fix more merge conflict mistakes

* implement requested changes (with a non-broken commit this time)

* implement requested changes

* slight reordering of impls
2021-11-16 00:00:22 -06:00
Pedro Tacla Yamada 2a894c6bc9
Run cargo fmt on source files (#106)
* Run cargo fmt on source files

* Update with rustfmt.toml

* Change rustfmt configuration and run it again
2021-11-10 00:57:54 -06:00
Joakim Frostegård 72b6a4a2d1
Support passing back some events to the platform (#90)
* Add mutable event status argument to WindowHandler::on_event

* macOS: simplify method declaration for simple mouse event handlers

* macOS: add macro for adding simple keyboard class methods

* macOS: reorder code in mouse_moved

* Take EventStatus as return value in WindowHandler::on_event

* Add doc comments for EventStatus

* Improve EventStatus documentation

* x11: ignore return value of on_event for now

* EventStatus: improve docs

* Improve EventsStatus docs

* Improve EventStatus docs further

* macOS: ignore EventStatus::Ignored for mouse events

* macOS: minor formatting improvement

* improve EventStatus docs again
2021-02-09 14:47:31 -06:00
micah ef27adeda1 add window argument to WindowHandler::on_frame() 2021-01-27 02:13:08 -05:00
micah 36e4474c8a separate Window::open() into three functions (parented, as_if_parented, and blocking) 2021-01-01 22:52:59 -06:00
Micah Johnston e02854452e remove WindowHandle 2020-12-12 17:15:09 -06:00
Micah Johnston 8402310c88 remove Message api 2020-12-12 17:06:50 -06:00
Joakim Frostegård 1c81921688 Use wait-free spsc message chan; split off AppRunner from WindowHandle 2020-12-04 20:03:55 +01:00
Joakim Frostegård 35a9841b29 Add WindowHandle::try_send_message, implement it on macOS 2020-12-04 20:03:55 +01:00
Billy Messenger 579dfee1eb clean up dpi features 2020-10-20 19:02:45 -05:00
Billy Messenger 2ee975231b fix Windows build 2020-10-20 17:04:37 -05:00
Billy Messenger 3fe752ca80 remove min/max resize policy 2020-10-20 16:06:40 -05:00
Billy Messenger 61ef63409b Merge branch 'master' of https://github.com/RustAudio/baseview into master 2020-10-20 15:56:54 -05:00
William Light 43cdc39335 x11: closure for building WindowHandler 2020-10-20 21:33:52 +02:00
Billy Messenger a91a5a1126 update x11 code 2020-10-17 17:36:28 -05:00
Billy Messenger 688d45c720 refactor to use conversion between Point and Size to PhyPoint and PhySize 2020-10-17 17:27:06 -05:00
Billy Messenger dc5d3b9622 Add Point and Size structs 2020-10-17 14:01:03 -05:00
Billy Messenger 1b9fbf9bb8 refactor and modify events 2020-10-17 13:35:39 -05:00
Billy Messenger aee594d23c add window resize hints 2020-10-15 16:31:38 -05:00
Billy Messenger 61de5e37f7 rename width, height to logical_width, logical_height 2020-10-15 13:26:21 -05:00
Billy Messenger 2bf229575f add UI scaling support 2020-10-15 13:17:03 -05:00
Billy Messenger cc2ae0ef39 rebase, cargo fmt 2020-09-11 12:38:06 -05:00
William Light 4d9c6c3131 remove FileDropEvent
we have no implementations for it, so it's just dead code for now.
2020-09-11 19:10:49 +02:00
William Light 196883b390 x11: WindowHandle.app_run_blocking() 2020-09-11 18:53:33 +02:00
William Light 5207d961d9 x11: run window in a separate thread
there's a thread.join() to mimic the previous semantics (which are the
same as on the other platforms).
2020-09-11 18:53:33 +02:00
Billy Messenger e67887d92f Remove Interval event 2020-09-11 11:49:56 -05:00
Billy Messenger ddbc95a2ed Merge branch 'master' of https://github.com/RustAudio/baseview into master 2020-09-11 11:39:20 -05:00
William Light b64183fb19 x11: Event::WillClose support
this is a nightmare of ICCCM protocols but hey it's done now.
2020-09-11 18:03:04 +02:00
Billy Messenger b8bc006fc1 Add and refactor events 2020-09-11 10:21:05 -05:00
William Light 072918cb3f rename WindowHandler.draw() to WindowHandler.on_frame()
also remove the `Window` ref argument because `on_frame()` shouldn't be
doing any window system ops (this is my opinion and i am happy to
backpedal if it turns out to be wrong).
2020-09-11 16:54:13 +02:00
William Light b650bf772f x11: frame/draw callbacks
currently fixed at 15ms (just above 60fps), but easily configurable and
something we can query the display server for in the future.
2020-09-11 16:32:21 +02:00
Micah Johnston 5ecce5d28d Window::open() returns WindowHandle struct 2020-09-08 18:45:29 -05:00
Micah Johnston 601a5d62a4 remove mspc channel (to be replaced by baseview-specific WindowHandle 2020-09-08 18:45:29 -05:00
Micah Johnston c51aea5c12 rename AppWindow -> WindowHandler 2020-09-08 18:45:29 -05:00
Micah Johnston 58ed00eb11 api change: AppWindow methods receive an &mut Window, which implements HasRawWindowHandle 2020-09-07 21:33:03 -04:00
Billy Messenger 08390d6004 Change AppWindow::create_context() to AppWindow::build() 2020-09-05 17:29:36 -05:00
Billy Messenger c7d9d7d107 Add small wrapper for RawWindowHandle 2020-09-05 15:22:23 -05:00
Billy Messenger 15b0c2e857 Replace RenderExpose event with draw method 2020-09-05 14:41:26 -05:00
Billy Messenger 6cf5966afa Rename Application tratit to AppWindow 2020-09-05 11:19:09 -05:00
Billy Messenger 29917b87cd Rename Receiver trait to Application 2020-09-03 11:50:15 -05:00
Billy Messenger 81e791f06b Rename Message to Event. Add AppMessage type and on_app_message method to Receiver trait. 2020-09-03 11:38:22 -05:00
Billy Messenger ab8cb1c223 Remove Opened message. Add RenderExpose message. 2020-09-03 10:58:24 -05:00
Billy Messenger b0c3792c74 Revert to Receiver trait. Add create_context method to Receiver trait. 2020-09-03 10:54:23 -05:00