Commit Graph

46 Commits

Author SHA1 Message Date
Tom A. Wagner
c8f94ae302 Use link info callback instead of properties to get ids.
While the properties for a links node ids are not always set, they always are in the link info.

Also, the work done in this commit will easily allow to get the format of links and ports later,
so that we can get the format of them much more reliably,
and we can also get notified of changes to an existing global via the info callback.
2021-06-06 20:28:19 +02:00
Tom A. Wagner
907ef328d2 Move state to pipewire thread instead of the gtk thread.
This will allow easier state-keeping later, when setting up info-listeners on structs.
2021-06-06 09:20:07 +02:00
Tom A. Wagner
118c1ca28c Get node_from, node_to ids from state instead of props when a new link appears.
This is more reliable than assuming the link carries the id of its nodes, as there have been cases where a link was created without those
properties set.
Instead, we can just pull them from the state via the port ids of the link.
2021-06-04 10:30:31 +02:00
Tom A. Wagner
a9aec985b0 pipewire: Edit fixme about port media type 2021-05-25 22:45:13 +02:00
Tom A. Wagner
dce228ff60 Update dependencies
Glib MainContext is now aquired manually because a change in gtk-rs would lead to
a panic when attaching the receiver otherwise, because gtk::init() doesn't
"leak" the default main context anymore.
2021-05-22 14:00:51 +02:00
Mathias Rav
3cd19f2d1d When dragging a node, don't snap its top-left corner to the cursor
Revamp the node dragging implementation, moving it into the GraphView
widget.

When a drag is initiated, the node widget's current position is stored.
Whenever the drag gesture is updated, the node widget's position is set
by adding the relative drag vector to the position at the start of the
drag.

A drag gesture on the node widget rather than the GraphView widget was
considered, but this seems to lead to a weird flickering effect when the
node is moved while the drag gesture on the node is active.

To avoid interfering with the drag handlers on the ports, check if the
GraphView drag gesture targets a port, in which case the handler does
nothing.
2021-05-10 18:21:00 +00:00
Mathias Rav
6d60095da8 Move CSS to its own file 2021-05-09 21:53:27 +02:00
Tom A. Wagner
a9cd428a5a Change cursor to grab hand over output port.
This lets the user know the port can be dragged to create a link.
2021-05-08 18:44:50 +02:00
Tom A. Wagner
a5d8c871ee Update dependencies 2021-05-08 18:42:49 +02:00
Tom A. Wagner
13f02ad317 Toggle links on and off when ports are connected by the user.
This extends the `Application` struct to keep more advanced state.
This state is then used to determine the needed information to create
or delete a link between the two connected ports.

A message to create/delete the link is then send to the pipewire thread,
which executed the request.
2021-05-08 18:06:52 +02:00
Tom A. Wagner
be240231c0 Merge Controller and View structs into one Application struct.
The `View` sturct was mostly a layer of indirection, and the controller benefitted by absorbing the gtk::Application
subclass parts, so now those two are merged into a new gtk::Application subclass.
2021-05-08 18:06:52 +02:00
Tom A. Wagner
2cc684d57c Turn struct View into a gtk::Application subclass.
This lets us keep multiple reference-counted copies easier, and lets us emit signals to the controller.
2021-05-08 18:06:52 +02:00
Tom A. Wagner
b5071c09a0 Emit "link-toggled" signal when two ports widgets are connected 2021-05-08 18:06:37 +02:00
Tom A. Wagner
076fec7eb4 Modify architecture to run pipewire loop in second thread.
The pipewire loop now runs without interruption in a second thread and communicates with
the GTK thread via a channel in each direction, instead of checking for events once a second and using callbacks.

This allows changes to appear instantly in the view, instead of having to wait.
2021-05-05 21:48:00 +02:00
Tom A. Wagner
75aa0a30d0 Turn view::port::Port into a gtk::Button subclass 2021-04-02 14:53:58 +02:00
Tom A. Wagner
9b448f0a30 view: Add some comments to View struct 2021-04-01 16:24:21 +02:00
Tom A. Wagner
2cb155c5ee view: Refactor view to have a manager View struct.
The view struct creates, manages and runs the view, and handles all communication with components outside of the view.
2021-03-31 10:44:04 +02:00
Tom A. Wagner
48821be18d Move port coloring into view
The controller still determines the ports media type, but instead of coloring
the port itself, the media type is passed to the constructor, which then colors the port.
2021-03-28 21:03:43 +02:00
Tom A. Wagner
9519eefa6e Change architecture to controller-centered arch
struct PipewireConnection is now decoupled from any other components, another component (the controller)
can receive updates by registering a callback.

struct PipewireState has been refactored to a struct Controller.
It still keeps state and manages the view, but now also actively requests updates from the pipewire connection via callback.
2021-03-28 19:04:57 +02:00
Tom A. Wagner
d75dee5ea8 Update dependencies
This updates all crates to their newest release.

For pipewire-rs, this includes bumping the version to 0.3, which means this comment has to fix a few breaking changes, but nothing big.
0.3 also lets us create and delete remote objects, which will be needed for link creation and deletion.
2021-03-27 19:57:44 +01:00
Emmanuel Gil Peyrot
aab1f1bde3 Add a ^Q accel to quit
This is a somewhat standard shortcut used in many GTK applications.
2021-03-19 15:23:48 +00:00
Emmanuel Gil Peyrot
279c792345 Update to build with latest glib
glib replaced its glib::object_subclass!() macro with
a #[glib::object_subclass] attribute, to simplify a bunch of things.

See fdc8459b39
2021-03-14 00:25:08 +01:00
Tom A. Wagner
b348339b4e Update dependencies, use pipewire-rs crates from crates.io 2021-03-12 18:04:08 +01:00
Tom A. Wagner
528694b63e Change application name to 'Helvum' 2021-03-12 17:30:26 +01:00
Guillaume Desmottes
5784275d32 fix clippy warnings 2021-02-14 17:24:49 +01:00
Tom A. Wagner
5ac535ab37 Prevent nodes from being dragged out of the graph view 2021-02-10 10:58:01 +01:00
Tom A. Wagner
ec8de4a4a7 Color ports depending on the type of data (audio,video,midi) they carry 2021-02-09 12:51:35 +01:00
Tom A. Wagner
926829de22 Update dependencies 2021-01-19 15:37:05 +01:00
Tom A. Wagner
a3907a1832 Change Node from a frame subclass to a widget subclass. 2021-01-12 10:44:12 +01:00
Tom A. Wagner
5bf62eca6e Use log, env_logger crates to log warnings instead of using eprintln!() macro 2021-01-12 09:48:59 +01:00
Tom A. Wagner
181661a2db Delete items from graph when they are removed by the pipewire server. 2021-01-08 12:34:22 +01:00
Tom A. Wagner
9784b9bae0 Run rustfmt on the codebase 2021-01-08 09:58:58 +01:00
Tom A. Wagner
4744a1a647 Check that a widget is being dragged before checking the event in graphview.
A bug in gtk4-rs makes the library print errors when accessing an event, this change reduces the amount of errors, as they are only printed when the mouse is over a node now.
2021-01-08 09:57:25 +01:00
Tom A. Wagner
323e1a2a8f Refractor graphview.rs by moving accessor functions into wrapper type. 2021-01-08 09:56:36 +01:00
Tom A. Wagner
0e5b9bb1bc Remove unnecessary snapshot downcast into itself 2021-01-07 17:44:23 +01:00
Tom A. Wagner
7f054890ed Make graphview scrollable 2021-01-07 17:43:41 +01:00
Tom A. Wagner
f1b66d9c53 Turn Node into a gtk::Frame subclass. 2021-01-07 17:42:37 +01:00
Tom A. Wagner
d5283c803b Change cursor to grab when node can be dragged 2021-01-06 10:59:28 +01:00
Tom A. Wagner
85b21a920d Start application with a bigger window 2021-01-05 11:27:15 +01:00
Tom A. Wagner
9262308d28 Improve theming
Default to a dark theme and draw a grid on the background of the graphview
2021-01-05 11:24:49 +01:00
Tom A. Wagner
2897543acf Switch to gtk4 2021-01-05 09:46:34 +01:00
Tom A. Wagner
b129d84fa2 Display Nodes/Ports/Links obtained from pipewire server 2021-01-03 19:01:47 +01:00
Tom A. Wagner
438383e92f Render links as a curve instead of a straight line 2020-12-17 11:27:06 +01:00
Tom A. Wagner
82c9a5bd4d Make Nodes on graph draggable 2020-12-17 11:26:41 +01:00
Tom A. Wagner
c72bef364d Run rustfmt on the codebase 2020-12-14 11:28:06 +01:00
Tom A. Wagner
264ccf0982 Add initial project. 2020-12-14 11:20:29 +01:00