Skip to content

Commit

Permalink
Improve close button and show/hide behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Jun 17, 2024
1 parent f9946e3 commit afece85
Show file tree
Hide file tree
Showing 7 changed files with 961 additions and 490 deletions.
10 changes: 7 additions & 3 deletions main/src/infrastructure/plugin/backbone_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl BackboneShell {
}
// Detect shutdown via hidden child window as suggested by Justin
let shutdown_detection_panel = SharedView::new(HiddenHelperPanel::new());
shutdown_detection_panel.clone().open(reaper_window());
shutdown_detection_panel.clone().open(reaper_main_window());
BackboneShell {
_tracing_hook: tracing_hook,
_metrics_hook: metrics_hook,
Expand Down Expand Up @@ -1503,7 +1503,11 @@ impl BackboneShell {

pub fn show_welcome_screen() {
let shell = Self::get();
open_child_panel(&shell.welcome_panel, WelcomePanel::new(), reaper_window());
open_child_panel(
&shell.welcome_panel,
WelcomePanel::new(),
reaper_main_window(),
);
}

pub fn resolve_symbols_from_clipboard() {
Expand Down Expand Up @@ -2796,7 +2800,7 @@ impl ToolbarIconMap for BackboneShell {
}
}

fn reaper_window() -> Window {
pub fn reaper_main_window() -> Window {
Window::from_hwnd(Reaper::get().main_window())
}

Expand Down
4 changes: 4 additions & 0 deletions main/src/infrastructure/plugin/instance_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ impl InstanceShell {
self.find_unit_prop_by_id_simple(id, |i, unit_shell| (i, unit_shell.model().clone()))
}

pub fn panel(&self) -> &SharedView<InstancePanel> {
self.panel.get()
}

pub fn find_unit_panel_by_id(&self, id: Option<UnitId>) -> Option<SharedView<UnitPanel>> {
self.find_unit_prop_by_id_simple(id, |_, unit_shell| unit_shell.panel().clone())
}
Expand Down
1,412 changes: 938 additions & 474 deletions main/src/infrastructure/proto/generated.rs

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion main/src/infrastructure/proto/request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use reaper_high::{OrCurrentProject, Reaper};
use tonic::{Response, Status};

use base::spawn_in_main_thread;
use swell_ui::Window;

use crate::domain::{CompartmentKind, UnitId};
use crate::infrastructure::api::convert::from_data;
Expand Down Expand Up @@ -286,7 +287,9 @@ impl ProtoRequestHandler {
let action = TriggerGlobalAction::try_from(req.action)
.map_err(|_| Status::invalid_argument("unknown trigger global action"))?;
match action {
TriggerGlobalAction::Placeholder => {}
TriggerGlobalAction::FocusHost => {
Window::from_hwnd(Reaper::get().main_window()).focus();
}
}
Ok(Response::new(Empty {}))
}
Expand Down Expand Up @@ -315,6 +318,9 @@ impl ProtoRequestHandler {
.containing_fx()
.show_in_floating_window();
}
TriggerInstanceAction::CloseApp => {
instance.panel().stop_app_instance();
}
TriggerInstanceAction::ArrangementTogglePlayStop => {
if project.is_playing() {
project.stop();
Expand Down
6 changes: 3 additions & 3 deletions main/src/infrastructure/ui/app/app_library.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::infrastructure::plugin::BackboneShell;
use crate::infrastructure::plugin::{reaper_main_window, BackboneShell};
use crate::infrastructure::proto;
use crate::infrastructure::proto::{
create_initial_global_updates, create_initial_instance_updates, create_initial_unit_updates,
Expand Down Expand Up @@ -174,7 +174,7 @@ impl AppLibrary {
.main_library
.get(b"hide_app_instance\0")
.map_err(|_| anyhow!("failed to load hide_app_instance function"))?;
hide_app_instance(app_handle);
hide_app_instance(app_handle, reaper_main_window().raw());
};
Ok(())
}
Expand Down Expand Up @@ -309,7 +309,7 @@ type StartAppInstance = unsafe extern "C" fn(
type ShowAppInstance = unsafe extern "C" fn(parent_window: HWND, app_handle: AppHandle);

/// Signature of the function that we use to hide an app instance.
type HideAppInstance = unsafe extern "C" fn(app_handle: AppHandle);
type HideAppInstance = unsafe extern "C" fn(app_handle: AppHandle, host_window: HWND);

/// Signature of the function that we use to check whether an app instance has focus.
type AppInstanceHasFocus = unsafe extern "C" fn(app_handle: AppHandle) -> bool;
Expand Down
5 changes: 1 addition & 4 deletions main/src/infrastructure/ui/independent_panel_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::domain::{
CompartmentKind, MappingId, MappingMatchedEvent, SourceFeedbackEvent, TargetControlEvent,
TargetValueChangedEvent,
};
use crate::infrastructure::plugin::reaper_main_window;
use swell_ui::{SharedView, View, WeakView, Window};

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `Window`

Check failure on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Build

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Test

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Test

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Test

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Test

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Build

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Build

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Build

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Test

unused import: `Window`

Check warning on line 12 in main/src/infrastructure/ui/independent_panel_manager.rs

View workflow job for this annotation

GitHub Actions / Test

unused import: `Window`

const MAX_PANEL_COUNT: u32 = 4;
Expand Down Expand Up @@ -191,7 +192,3 @@ impl Drop for IndependentPanelManager {
self.destroy();
}
}

fn reaper_main_window() -> Window {
Window::from_hwnd(Reaper::get().main_window())
}
6 changes: 1 addition & 5 deletions main/src/infrastructure/ui/instance_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync;
use std::sync::Arc;

use crate::domain::{InstanceId, SharedInstance, UnitId};
use crate::infrastructure::plugin::{InstanceShell, SharedInstanceShell};
use crate::infrastructure::plugin::{reaper_main_window, InstanceShell, SharedInstanceShell};
use crate::infrastructure::ui::bindings::root;
use crate::infrastructure::ui::util::colors;
use swell_ui::{DeviceContext, Dimensions, Pixels, SharedView, View, ViewContext, Window};
Expand Down Expand Up @@ -310,7 +310,3 @@ impl View for InstancePanel {
util::view::get_brush_for_color_pair(colors::instance_panel_background())
}
}

fn reaper_main_window() -> Window {
Window::from_hwnd(Reaper::get().main_window())
}

0 comments on commit afece85

Please sign in to comment.