Commit Graph

291 Commits

Author SHA1 Message Date
Antonio Scandurra
cf23b0e4a2 Prompt for paths asynchronously to avoid double borrow 2021-04-14 16:30:03 +02:00
Antonio Scandurra
29d2236ed2
Merge pull request #19 from zed-industries/single-global-action-dispatch
Dispatch global actions only once when triggering a menu item
2021-04-14 15:50:07 +02:00
Antonio Scandurra
f755cbbe98 Dispatch global actions only once when triggering a menu item
Previously we would dispatch the same global action more than once
because we would invoke `dispatch_action_any` _and_
`dispatch_global_action_any`. However, the former already takes care of
going through the global action handlers when no entity in the dispatch
path handled the action.
2021-04-14 14:47:18 +02:00
Antonio Scandurra
40980edffe Merge branch 'master' into copy-paste 2021-04-14 12:05:52 +02:00
Nathan Sobo
0cc5e8f742 Replace easy-parallel with scoped-pool for path searches
The easy-parallel crate spawned new threads on each call, which was resulting in way too many threads.

Co-Authored-By: Brooks Swinnerton <934497+bswinnerton@users.noreply.github.com>
2021-04-13 20:07:42 -06:00
Nathan Sobo
0a2d2aa684 Replace app/app_mut on contexts with AsRef/AsMut impls
Co-Authored-By: Brooks Swinnerton <934497+bswinnerton@users.noreply.github.com>
2021-04-13 20:07:25 -06:00
Max Brunsfeld
c83f02dd04 Implement multi-selection copy/cut/paste 2021-04-13 17:28:51 -07:00
Antonio Scandurra
13514aae6c Allow metadata to be associated with text written to clipboard
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-04-13 19:03:56 +02:00
Antonio Scandurra
f4c1ffc329 Start on copy-paste 2021-04-13 14:58:10 +02:00
Max Brunsfeld
902b0f7dfa Dispatch menu commands on the focused view
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-04-12 15:42:33 -07:00
Max Brunsfeld
d4436f3018 Don't try to handle errors when opening platform windows
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-04-12 15:14:25 -07:00
Max Brunsfeld
86c0f41c9e Move set_menus method to MutableAppContext
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-04-12 14:38:18 -07:00
Max Brunsfeld
41358f34e3 Set up menu handler in App::new
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-04-12 14:25:00 -07:00
Max Brunsfeld
2332b7e06b Move open command handler to workspace global action
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-04-12 14:18:24 -07:00
Max Brunsfeld
3247f49954 Allow menu items to specify arguments for their commands
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-04-12 14:09:49 -07:00
Nathan Sobo
b9b511148b Make gpui::platform module private 2021-04-10 00:22:45 -06:00
Nathan Sobo
619e2b7e01 Remove platform::mac::runner 2021-04-10 00:19:25 -06:00
Nathan Sobo
4638391412 Remove MutableAppContext::downgrade 2021-04-10 00:14:26 -06:00
Nathan Sobo
620eedb727 Allow effects to be flushed before TestAppContext::update callback completes 2021-04-10 00:11:13 -06:00
Nathan Sobo
97a8a8ed43 Remove unsafe code from App::test_async
I don't actually think it was correct to allow the future to borrow a mutable app reference. I went back to passing a wrapper around the refcell to async tests. They'll be a bit more annoying to write but also totally safe.
2021-04-10 00:05:09 -06:00
Nathan Sobo
448dace281 Pass the on_finish_launching callback to Platform::run 2021-04-09 21:33:17 -06:00
Max Brunsfeld
079050541f Get app running and test passing after gpui App+Platform restructure 2021-04-09 16:56:32 -07:00
Nathan Sobo
4ecc17b1bb WIP: Make App the only entry point from main
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-04-09 13:38:09 -06:00
Nathan Sobo
301163bab7 Add lifecycle methods to Platform trait
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-04-09 13:03:26 -06:00
Max Brunsfeld
00d7dafbba Merge branch 'master' into menus 2021-04-09 10:34:21 -07:00
Max Brunsfeld
7ebcbdc0cb Implement File > Open menu item 2021-04-08 22:25:54 -07:00
Max Brunsfeld
f656b387b3 Call SetActivationPolicy at the proper time
If this method is called too early, the menu bar won't be
clickable on startup until the window loses focus. Calling
it once the application finishes launching seems to fix
the issue.

See https://github.com/glfw/glfw/issues/1648
2021-04-08 16:11:45 -07:00
Max Brunsfeld
334de06322 Create an API for assigning the menubar contents 2021-04-08 16:01:36 -07:00
Nathan Sobo
9f6f27f305 Order debug JSON and allow elements to be named; copy to clipboard 2021-04-07 21:54:14 -06:00
Nathan Sobo
cbb23a93a6 Log prettified element debug JSON to on cmd-alt-i 2021-04-07 21:54:14 -06:00
Nathan Sobo
0664321125 Add ability to debug element trees as JSON 2021-04-07 21:54:14 -06:00
Max Brunsfeld
0a12774680 Add a stub of a native 'File' menu 2021-04-07 17:49:44 -07:00
Max Brunsfeld
7e5186e4a0 Start work on a native application menu
Add an application menu with a quit command, bound to command-q
2021-04-07 17:48:22 -07:00
Max Brunsfeld
187eb95b13 Throw a little between filename and modified icon
We probably need a primitive to right-align an element within
its parent, but I don't have strong opinions about how that
should be designed, so I'm just adding this as a temporary
measure so that the tabs won't look too ugly in the meantime.
2021-04-07 15:39:09 -07:00
Nathan Sobo
13ee86e334 Remove unused method 2021-04-06 20:47:09 -06:00
Max Brunsfeld
dabd6abe37 Start work on displaying modified status in tabs 2021-04-06 14:37:21 -07:00
Max Brunsfeld
0f157d5083 Silence warning in text example 2021-04-06 14:36:16 -07:00
Max Brunsfeld
c632aab382 Vertically center linebox child element
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-04-06 13:03:19 -07:00
Nathan Sobo
2a9e71d725 Vertically center glyphs in Line::paint based on ascender/descender for line 2021-04-06 09:15:21 -06:00
Nathan Sobo
fc4135d55b Render example text in example via Line::paint 2021-04-06 09:15:21 -06:00
Nathan Sobo
765c3f9c18 Open platform window before first invalidation
This ensures we have an invalidation handler present so we render the first frame in all cases.
2021-04-06 09:15:21 -06:00
Nathan Sobo
a5b39220a4 WIP: Add example app to test text rendering 2021-04-06 09:15:21 -06:00
Antonio Scandurra
5f1f49b011 Reduce path atlas size by using a single channel for the texture 2021-04-06 13:53:20 +02:00
Antonio Scandurra
e0c43dac25 Implement SVG rendering 2021-04-06 13:46:33 +02:00
Nathan Sobo
2970e934da Use handles to obtain entities in future callbacks
This guarantees that the spawning entity will be present and simplifies
the logic for obtaining the entity. Now we can forward the results of spawned futures and streams in the same way regardless of whether what spawned them was a model or a view.
2021-04-05 20:04:04 -06:00
Max Brunsfeld
fda1394057 Rename Task -> EntityTask (a BackgroundTask is just a Task)
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-04-05 17:03:42 -07:00
Max Brunsfeld
c39c7c3eff Make background executor available on AppContext
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-04-05 16:45:55 -07:00
Max Brunsfeld
dba3c82530 Remove stray print statements 2021-04-02 15:00:20 -07:00
Max Brunsfeld
575f5910fa Use a real FontSystem in test platform 2021-04-02 14:35:44 -07:00
Max Brunsfeld
dd31b870c3 Remove small pieces of unused code 2021-04-02 14:26:53 -07:00
Nathan Sobo
c43d7cfb39 Use a condvar instead of a channel to implement finish_pending_tasks
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-04-02 13:53:06 -06:00
Nathan Sobo
526a55d0d7 Complete finish_pending_tasks future when tasks are cancelled
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-04-02 12:42:23 -06:00
Nathan Sobo
fd1f75333f Initialize logger in gpui tests
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-04-02 12:42:01 -06:00
Nathan Sobo
2d79193fb6 Remove future/stream handlers when task is dropped
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-04-02 12:03:35 -06:00
Nathan Sobo
914cf37f37 Remove executor::ForegroundTask wrapper
Now that smol returns the same Task as async_task, we can simply re-export the async_task::Task struct from our executor module.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-04-02 11:02:09 -06:00
Nathan Sobo
d68a747754 Fix hanging finish_pending_tasks test
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-04-02 10:48:03 -06:00
Antonio Scandurra
72ced45df0 Remove unused edge_to_point calculation in quad shader 2021-04-02 13:53:11 +02:00
Antonio Scandurra
d10fc6ce3f Fix crash when selections exceed the container's bounds 2021-04-02 13:49:44 +02:00
Nathan Sobo
995acefce5 Inset container contents to account for container border 2021-04-01 10:31:00 -06:00
Antonio Scandurra
e487aa5cbd Don't render glyphs located outside of BufferElement's bounds 2021-04-01 11:19:50 +02:00
Nathan Sobo
c525d7c712 💄 naming 2021-03-31 20:43:15 -06:00
Max Brunsfeld
3bd6b92244 Introduce a GPUI test platform, get most tests running
There are still two tests that don't pass:
* `gpui::app::tests::test_finish_pending_tasks` hangs
* `editor::buffer_view::tests::test_fold` has an assertion failure
2021-03-31 17:03:58 -07:00
Max Brunsfeld
2efc90adc6 Ensure that path windings are rendered to the right atlas texture
Fixes #5
2021-03-31 14:52:41 -07:00
Antonio Scandurra
a9c428ad05 Remove Overdraw
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-31 17:58:43 +02:00
Antonio Scandurra
d5a9bab4a0 Fix tabs layout
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-31 17:57:00 +02:00
Antonio Scandurra
97e0db205d Don't blend alpha channels
We want to use the source alpha to determine the color of the final
pixel, but we want the final pixels to be fully opaque.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-31 16:24:28 +02:00
Antonio Scandurra
385d15cd0c Round clip bounds to whole pixels
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-31 16:23:37 +02:00
Antonio Scandurra
d853dbb048 Render borders correctly when only a subset of the border is visible 2021-03-31 14:53:34 +02:00
Antonio Scandurra
073ff96a9f Snap quads to pixel grid to avoid antialiasing them around the edges 2021-03-31 14:53:15 +02:00
Antonio Scandurra
bbf8762447 💄 2021-03-31 10:32:53 +02:00
Antonio Scandurra
f5e5d7180f Remove conditional from winding number computation 2021-03-31 10:30:16 +02:00
Nathan Sobo
5c444b2bfa Call did_modify_range on only once per render 2021-03-30 23:07:14 -06:00
Nathan Sobo
6ba08b510f Avoid generic parameter
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-03-30 18:05:13 -06:00
Nathan Sobo
77b6a29f5f Optimize grouping of path sprites by layer/atlas
Avoid filtering sprites redundantly on every layer and allocating intermediate vectors to group by atlas.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-03-30 18:03:00 -06:00
Nathan Sobo
3103d28285 Clear the path atlases on every frame and fix spelling
@as-cii you were right about the plural of "atlas" after all.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-03-30 16:56:11 -06:00
Nathan Sobo
8dabb15248 Decrease max windings to avoid problems with anti-aliasing
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-03-30 16:34:01 -06:00
Nathan Sobo
c4f23e411a Fix double-borrow when synthesizing drag events 2021-03-30 14:25:47 -06:00
Nathan Sobo
5c4b08f05f Use correct texture size when drawing paths into atlas 2021-03-30 14:03:29 -06:00
Nathan Sobo
4773f5034b Bump max path windings to 128
This eliminates artifacts while still seeming to work with anti-aliasing.
2021-03-30 14:02:59 -06:00
Max Brunsfeld
011d4d8437 wip 2021-03-30 12:36:18 -07:00
Antonio Scandurra
da1960c3e8 Snap path sprites to pixel grid
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-03-30 19:37:49 +02:00
Antonio Scandurra
1903f63c45 WIP: Add anti-aliasing to paths and render them after spriting them 2021-03-30 16:37:12 +02:00
Antonio Scandurra
98845663a9 Render stencils to atlas 2021-03-30 11:28:35 +02:00
Nathan Sobo
b538f5cfb7 WIP
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-03-29 22:56:47 -06:00
Nathan Sobo
64af4c694a WIP: Render paths into stencil buffers
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-03-29 22:46:26 -06:00
Max Brunsfeld
0b12779e62 WIP: Render path winding numbers to stencil buffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-29 16:28:35 -07:00
Max Brunsfeld
a8495d09f8 Whitelist shader bindings using a regex, not individual types 2021-03-29 12:39:21 -07:00
Antonio Scandurra
6222150688 WIP: Start on rendering paths
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-03-29 19:51:39 +02:00
Antonio Scandurra
d3d251a9ce Introduce a Path struct
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-03-29 19:50:38 +02:00
Antonio Scandurra
11f469b8e2 Construct Metal command encoder inside of Renderer
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-03-29 19:48:14 +02:00
Max Brunsfeld
8a119a51bf Avoid nested structs in vertex function return types
This is required to compile successfully on macos versions <= 10.15 (catalina)
2021-03-28 19:04:36 -07:00
Antonio Scandurra
466016a374 Snap sprites to pixel grid in Renderer
Previously, we were doing so in the `SpriteCache` but that would cause
floating point errors that caused glyphs to sometimes be positioned
midway through a pixel.
2021-03-26 11:07:16 +01:00
Antonio Scandurra
61d4da9934 Introduce layer clipping 2021-03-26 10:28:05 +01:00
Antonio Scandurra
63f9719c99 💄 2021-03-26 09:58:55 +01:00
Antonio Scandurra
5439213199 Fix Empty sometimes returning an infinite size in layout
This commit also ensures that elements never report an infinite size by
adding a debug assertion in the `Lifecycle` element.
2021-03-26 09:46:53 +01:00
Antonio Scandurra
1cb987d489 Remove stray use of pathfinder_geometry 2021-03-25 18:19:20 +01:00
Antonio Scandurra
466f6e0479 Center line around its bounding box 2021-03-25 17:21:26 +01:00
Antonio Scandurra
4dc1b1e179 Fix test_render_glyph (but still leave it commented out for now) 2021-03-25 15:10:21 +01:00
Antonio Scandurra
0f6927eb4b Re-export font_kit primitives from a new fonts module
...also, rename the old `fonts` to `font_cache`.
2021-03-25 10:58:33 +01:00
Antonio Scandurra
0906b2a2f4 Remove unused dependencies and avoid instantiating FontCache in tests 2021-03-25 10:48:32 +01:00
Antonio Scandurra
5f3dbb05d6 Honor vertical subpixel positions
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-24 18:35:48 +01:00
Antonio Scandurra
bc977fc873 Render different variants according to subpixel positioning
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-24 18:20:25 +01:00
Antonio Scandurra
9178e91cc0 Extract platform-dependant FontSystem
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-24 16:51:28 +01:00
Antonio Scandurra
e0e4cff815 Align glyphs correctly using font-kit's raster_bounds 2021-03-24 11:46:17 +01:00
Nathan Sobo
7523df05cf Space out sprites in atlas
This prevents us from accidentally sampling a neighboring sprite.
2021-03-23 19:02:03 -06:00
Nathan Sobo
e5d586a942 Get glyphs sort of rendering 2021-03-23 18:54:09 -06:00
Nathan Sobo
28b84c081d Fix noise in atlas texture 2021-03-23 17:27:28 -06:00
Antonio Scandurra
ad7974608b WIP
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-23 19:11:56 +01:00
Nathan Sobo
247afa1666 WIP 2021-03-23 09:13:35 -06:00
Antonio Scandurra
764bfba2e2 WIP: Start on rendering glyphs
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-23 15:15:41 +01:00
Antonio Scandurra
43abd96769 Apply padding correctly when painting Container's children 2021-03-23 10:59:35 +01:00
Antonio Scandurra
bac543657c Declare float literals consistently in shader 2021-03-23 10:45:09 +01:00
Antonio Scandurra
3de0ce6079 Remove artifact when a border side was not rendered
This introduces an extra conditional in the shader, there's probably a
way of writing it without ifs but I like how the logic reads with it and
it shouldn't be that big of a deal performance-wise.
2021-03-23 10:33:31 +01:00
Antonio Scandurra
32c070250c Scale corner_radius by the scale factor when rendering shadows 2021-03-23 10:14:07 +01:00
Nathan Sobo
66dcb73263 Respect margins when painting Container 2021-03-22 21:11:08 -06:00
Nathan Sobo
548b542766 Get the file finder rendering with a drop shadow 2021-03-22 20:54:52 -06:00
Antonio Scandurra
859c0f53cb WIP: Introduce layers in renderer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-22 18:55:53 +01:00
Antonio Scandurra
bfc57cb4f6 Start on rendering shadows
This still doesn't work properly because shadows are rendered beneath
quads and we still don't have a layering mechanism.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-22 18:05:16 +01:00
Antonio Scandurra
45c1337c84 Support rendering borders
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-22 16:24:26 +01:00
Antonio Scandurra
f330fdb6a7 Clarify variable name
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-03-22 15:27:48 +01:00
Antonio Scandurra
123b7c55f6 Render quads with anti-aliased rounded corners 2021-03-22 13:50:43 +01:00
Nathan Sobo
119aa452b6 Overhaul the entire element system
Now the Element trait is designed to be wrapped in a Lifecycle enum that gets placed inside an ElementBox. This allows the framework to store data on behalf of the Element implementation, such as sizes, bounds, and also implementation-specific LayoutState and PaintState types. This makes it easier to reason about which data is available in each Element method.
2021-03-21 20:54:23 -06:00
Nathan Sobo
046fe3fff9 Dispatch keystrokes and fix rerendering when window invalidated
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2021-03-21 11:38:23 -06:00
Nathan Sobo
f5df3681f8 Add file_finder module
Still need to wire up key bindings to make it toggle.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2021-03-21 10:50:07 -06:00
Nathan Sobo
0c59937a65 Wire up events and fix synthetic dragging
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2021-03-21 09:44:14 -06:00
Nathan Sobo
04665800c0 Scale quads by scale factor before writing to Metal buffer
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2021-03-21 09:19:12 -06:00
Nathan Sobo
31fb707eea Fix translation to device coords in shader
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2021-03-21 09:01:50 -06:00
Nathan Sobo
1f647ef24c Clean up
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2021-03-21 09:00:47 -06:00
Nathan Sobo
e5ffe43bb6 Get basic graphics rendering via Metal
Also, handle window resize.
2021-03-20 22:19:26 -06:00
Nathan Sobo
292b41ad57 Start on metal rendering infrastructure 2021-03-20 09:38:36 -06:00
Nathan Sobo
d14c943150 Start on Scene 2021-03-19 13:31:25 -06:00
Nathan Sobo
cfe3aae2de WIP: Get everything compiling again and keep window open 2021-03-19 12:12:10 -06:00
Nathan Sobo
605bdd62dd WIP: Start on rendering scenes via presenter 2021-03-18 21:33:16 -06:00
Nathan Sobo
e809d6119a Return tasks from spawn and spawn_stream
Also, eliminate the background spawning methods. We can spawn futures
on the executor and then spawn those on the app if we need to wait for
the result of running one.
2021-03-18 20:10:32 -06:00
Nathan Sobo
f849857309 Handle command line arguments and populate worktree 2021-03-18 17:54:35 -06:00
Nathan Sobo
9bab29c72f Get workspace module in and compiling 2021-03-18 15:52:46 -06:00
Nathan Sobo
23308e17a9 WIP on rebuilding with extracted UI framework 2021-03-18 13:13:31 -06:00
Nathan Sobo
356bc41752 WIP 2021-03-09 21:00:51 -07:00
Nathan Sobo
a015c61337 Add context predicate parser 2021-03-09 19:33:19 -07:00
Nathan Sobo
222f9d373d WIP 2021-02-20 16:05:36 -07:00
Nathan Sobo
b400449a58 Start rebuilding with a cleanly-separated UI framework 2021-02-20 10:02:34 -07:00