Skip to content

Commit

Permalink
Fix welcome screen and message panel on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Feb 14, 2024
1 parent a26a714 commit df0c95a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions dialogs/src/message_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 1 addition & 6 deletions dialogs/src/setup_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 5 additions & 4 deletions main/src/infrastructure/plugin/backbone_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -183,7 +184,7 @@ pub struct BackboneShell {
message_panel: SharedView<MessagePanel>,
osc_feedback_processor: Rc<RefCell<OscFeedbackProcessor>>,
proto_hub: crate::infrastructure::proto::ProtoHub,
setup_panel: SharedView<SetupPanel>,
welcome_panel: RefCell<Option<SharedView<WelcomePanel>>>,
/// We need to keep this panel in memory in order to be informed when it's destroyed.
_shutdown_detection_panel: SharedView<ShutdownDetectionPanel>,
audio_block_counter: Arc<AtomicU32>,
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions main/src/infrastructure/ui/message_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ impl View for MessagePanel {
&self.view
}

fn opened(self: SharedView<Self>, _window: Window) -> bool {
fn opened(self: SharedView<Self>, 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
}
Expand Down
2 changes: 1 addition & 1 deletion main/src/infrastructure/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ pub mod menus;

pub mod color_panel;
pub mod instance_panel;
pub mod setup_panel;
pub mod welcome_panel;
12 changes: 8 additions & 4 deletions main/src/infrastructure/ui/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pixels> = 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ 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(),
}
}
}

impl View for SetupPanel {
impl View for WelcomePanel {
fn dialog_resource_id(&self) -> u32 {
root::ID_SETUP_PANEL
}
Expand All @@ -32,8 +32,8 @@ impl View for SetupPanel {

fn opened(self: SharedView<Self>, 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);
Expand All @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit df0c95a

Please sign in to comment.