Skip to content

Commit

Permalink
feat(fixtures): add reload definitions button to fixture definition list
Browse files Browse the repository at this point in the history
  • Loading branch information
maxjoehnk committed Aug 9, 2024
1 parent 81ca61d commit b9fab99
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/api/src/handlers/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ impl<R: RuntimeApi> SettingsHandler<R> {
pub fn reload_midi_device_profiles(&self) -> anyhow::Result<()> {
self.runtime.reload_midi_device_profiles()
}

#[tracing::instrument(skip(self))]
#[profiling::function]
pub fn reload_fixture_definitions(&self) -> anyhow::Result<()> {
self.runtime.reload_fixture_definitions()
}
}
1 change: 1 addition & 0 deletions crates/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub trait RuntimeApi: Clone + Send + Sync {
fn get_device_manager(&self) -> DeviceManager;

fn reload_midi_device_profiles(&self) -> anyhow::Result<()>;
fn reload_fixture_definitions(&self) -> anyhow::Result<()>;

fn read_fader_value(&self, path: NodePath) -> anyhow::Result<f64>;

Expand Down
11 changes: 11 additions & 0 deletions crates/mizer/src/api/api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,17 @@ impl RuntimeApi for Api {
Ok(())
}

fn reload_fixture_definitions(&self) -> anyhow::Result<()> {
let settings_manager = self.settings.read();
let (tx, rx) = flume::bounded(1);
self.sender.send(ApiCommand::ReloadFixtureLibraries(
settings_manager.settings.paths.fixture_libraries,
tx,
))?;

rx.recv()?
}

#[profiling::function]
fn close_nodes_view(&self) {
tracing::debug!("Closing nodes view");
Expand Down
1 change: 1 addition & 0 deletions crates/ui/lib/api/contracts/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ abstract class SettingsApi {

Future<List<MidiDeviceProfile>> loadMidiDeviceProfiles();
Future<void> reloadMidiDeviceProfiles();
Future<void> reloadFixtureDefinitions();
}
5 changes: 5 additions & 0 deletions crates/ui/lib/api/plugin/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class ApplicationPluginApi implements SettingsApi {
await channel.invokeMethod("reloadMidiDeviceProfiles");
}

@override
Future<void> reloadFixtureDefinitions() async {
await channel.invokeMethod("reloadFixtureDefinitions");
}

static List<int> _convertBuffer(List<Object> response) {
return response.map((dynamic e) => e as int).toList();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:flutter/material.dart' hide Tab;
import 'package:mizer/api/contracts/settings.dart';
import 'package:mizer/i18n.dart';
import 'package:mizer/widgets/panel.dart';
import 'package:mizer/widgets/tabs.dart';
import 'package:mizer/widgets/table/data_table.dart';
import 'package:provider/provider.dart';

class FixtureDefinitionsView extends StatefulWidget {
const FixtureDefinitionsView({super.key});
Expand All @@ -23,6 +26,12 @@ class _FixtureDefinitionsViewState extends State<FixtureDefinitionsView> {
flex: 1,
child: Panel(
label: "Fixture Definitions",
actions: [
PanelActionModel(
label: "Reload".i18n,
onClick: () => context.read<SettingsApi>().reloadFixtureDefinitions(),
)
],
tabs: [
Tab(
label: "Open Fixture Library",
Expand Down
3 changes: 3 additions & 0 deletions crates/ui/src/plugin/channels/method/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ impl<LH: LifecycleHandler + 'static, R: RuntimeApi + 'static> MethodCallHandler
"reloadMidiDeviceProfiles" => {
reply.respond_unit_result(self.handler.reload_midi_device_profiles());
}
"reloadFixtureDefinitions" => {
reply.respond_unit_result(self.handler.reload_fixture_definitions());
}
_ => reply.not_implemented(),
}
}
Expand Down

0 comments on commit b9fab99

Please sign in to comment.