diff --git a/dialogs/src/message_panel.rs b/dialogs/src/message_panel.rs index 405ef9fdc..31d094636 100644 --- a/dialogs/src/message_panel.rs +++ b/dialogs/src/message_panel.rs @@ -5,14 +5,14 @@ pub fn create(context: ScopedContext, ids: &mut IdGenerator) -> Dialog { let controls = [ctext( "Some message", ids.named_id("ID_MESSAGE_TEXT"), - context.rect(0, 0, 155, 19), + context.rect(0, 0, 300, 40), ) + SS_CENTERIMAGE + SS_WORDELLIPSIS + NOT_WS_GROUP]; Dialog { id: ids.named_id("ID_MESSAGE_PANEL"), caption: "ReaLearn", - rect: context.rect(0, 0, 155, 19), + rect: context.rect(0, 0, 300, 40), styles: Styles(vec![ DS_SETFONT, DS_MODALFRAME, diff --git a/dialogs/src/setup_panel.rs b/dialogs/src/setup_panel.rs index e7fb23685..146ac1592 100644 --- a/dialogs/src/setup_panel.rs +++ b/dialogs/src/setup_panel.rs @@ -10,13 +10,8 @@ pub fn create(context: ScopedContext, ids: &mut IdGenerator) -> Dialog { rect: context.rect(0, 0, 250, 250), styles: Styles(vec![ // Places the window into the center by default - DS_CENTER, - // Displays a close button + DS_CENTER, // Displays a close button WS_SYSMENU, - // Displays a maximize button - WS_MAXIMIZEBOX, - // Allows user to change size of window - WS_THICKFRAME, ]), controls: vec![ ctext( diff --git a/main/src/infrastructure/plugin/backbone_shell.rs b/main/src/infrastructure/plugin/backbone_shell.rs index 98dc8b296..d283adbe7 100644 --- a/main/src/infrastructure/plugin/backbone_shell.rs +++ b/main/src/infrastructure/plugin/backbone_shell.rs @@ -51,7 +51,8 @@ use crate::infrastructure::plugin::{ }; use crate::infrastructure::server::services::Services; use crate::infrastructure::ui::instance_panel::InstancePanel; -use crate::infrastructure::ui::setup_panel::SetupPanel; +use crate::infrastructure::ui::util::{open_child_panel, open_child_panel_dyn}; +use crate::infrastructure::ui::welcome_panel::WelcomePanel; use anyhow::bail; use base::hash_util::NonCryptoHashSet; use base::metrics_util::MetricsHook; @@ -183,7 +184,7 @@ pub struct BackboneShell { message_panel: SharedView, osc_feedback_processor: Rc>, proto_hub: crate::infrastructure::proto::ProtoHub, - setup_panel: SharedView, + welcome_panel: RefCell>>, /// We need to keep this panel in memory in order to be informed when it's destroyed. _shutdown_detection_panel: SharedView, audio_block_counter: Arc, @@ -459,7 +460,7 @@ impl BackboneShell { message_panel: Default::default(), osc_feedback_processor: Rc::new(RefCell::new(osc_feedback_processor)), proto_hub: crate::infrastructure::proto::ProtoHub::new(), - setup_panel: SharedView::new(SetupPanel::new()), + welcome_panel: Default::default(), _shutdown_detection_panel: shutdown_detection_panel, audio_block_counter, } @@ -1504,7 +1505,7 @@ impl BackboneShell { pub fn show_welcome_screen() { let shell = Self::get(); - shell.setup_panel.clone().open(reaper_window()); + open_child_panel(&shell.welcome_panel, WelcomePanel::new(), reaper_window()); } pub fn resolve_symbols_from_clipboard() { diff --git a/main/src/infrastructure/ui/message_panel.rs b/main/src/infrastructure/ui/message_panel.rs index 98b018d7a..8a143cd08 100644 --- a/main/src/infrastructure/ui/message_panel.rs +++ b/main/src/infrastructure/ui/message_panel.rs @@ -66,10 +66,10 @@ impl View for MessagePanel { &self.view } - fn opened(self: SharedView, _window: Window) -> bool { + fn opened(self: SharedView, window: Window) -> bool { self.view .require_control(root::ID_MESSAGE_TEXT) - .set_cached_font(fonts::normal_font(20)); + .set_cached_font(fonts::normal_font(window, 20)); self.invalidate(); true } diff --git a/main/src/infrastructure/ui/mod.rs b/main/src/infrastructure/ui/mod.rs index 6ed4d0131..6a57d7cb9 100644 --- a/main/src/infrastructure/ui/mod.rs +++ b/main/src/infrastructure/ui/mod.rs @@ -84,4 +84,4 @@ pub mod menus; pub mod color_panel; pub mod instance_panel; -pub mod setup_panel; +pub mod welcome_panel; diff --git a/main/src/infrastructure/ui/util.rs b/main/src/infrastructure/ui/util.rs index e1452000b..2ce0baeb5 100644 --- a/main/src/infrastructure/ui/util.rs +++ b/main/src/infrastructure/ui/util.rs @@ -164,10 +164,14 @@ pub mod view { } pub mod fonts { - use swell_ui::FontDescriptor; - - pub const fn normal_font(font_size: u32) -> FontDescriptor { - FontDescriptor::new(normal_font_name(), font_size) + use swell_ui::{DialogUnits, Dimensions, FontDescriptor, Pixels, Window}; + + pub fn normal_font(window: Window, font_size: u32) -> FontDescriptor { + let font_dimensions: Dimensions = window.convert_to_pixels(Dimensions::new( + DialogUnits(font_size), + DialogUnits(font_size), + )); + FontDescriptor::new(normal_font_name(), font_dimensions.height.get()) } const fn normal_font_name() -> &'static str { diff --git a/main/src/infrastructure/ui/setup_panel.rs b/main/src/infrastructure/ui/welcome_panel.rs similarity index 91% rename from main/src/infrastructure/ui/setup_panel.rs rename to main/src/infrastructure/ui/welcome_panel.rs index eed5103b1..4c5d1537c 100644 --- a/main/src/infrastructure/ui/setup_panel.rs +++ b/main/src/infrastructure/ui/welcome_panel.rs @@ -6,14 +6,14 @@ use crate::base::notification::alert; use crate::infrastructure::plugin::BackboneShell; use crate::infrastructure::ui::bindings::root; use crate::infrastructure::ui::util::{fonts, symbols}; -use swell_ui::{SharedView, View, ViewContext, Window}; +use swell_ui::{DialogUnits, Dimensions, Pixels, SharedView, View, ViewContext, Window}; #[derive(Debug)] -pub struct SetupPanel { +pub struct WelcomePanel { view: ViewContext, } -impl SetupPanel { +impl WelcomePanel { pub fn new() -> Self { Self { view: Default::default(), @@ -21,7 +21,7 @@ impl SetupPanel { } } -impl View for SetupPanel { +impl View for WelcomePanel { fn dialog_resource_id(&self) -> u32 { root::ID_SETUP_PANEL } @@ -32,8 +32,8 @@ impl View for SetupPanel { fn opened(self: SharedView, window: Window) -> bool { window.center_on_screen(); - let large_font = fonts::normal_font(20); - let medium_font = fonts::normal_font(14); + let large_font = fonts::normal_font(window, 20); + let medium_font = fonts::normal_font(window, 14); // Text 1 let text_1 = window.require_control(root::ID_SETUP_INTRO_TEXT_1); text_1.set_cached_font(large_font); @@ -48,7 +48,6 @@ impl View for SetupPanel { text_3.set_text(format!("Tip: You can come back here at any time via\nExtensions {arrow} Helgobox {arrow} Show welcome screen")); // Checkboxes let playtime_checkbox = window.require_control(root::ID_SETUP_ADD_PLAYTIME_TOOLBAR_BUTTON); - playtime_checkbox.set_cached_font(medium_font); playtime_checkbox.check(); self.invalidate_controls(); true @@ -71,7 +70,7 @@ impl View for SetupPanel { } } -impl SetupPanel { +impl WelcomePanel { fn invalidate_controls(&self) { let button_text = if self.build_instructions().is_empty() { "Close"