initial macos porting work
This commit is contained in:
@@ -11,9 +11,9 @@ use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::future::Future;
|
||||
use std::iter;
|
||||
use std::time::Instant;
|
||||
use std::marker::PhantomData;
|
||||
use std::rc::Rc;
|
||||
use std::time::Instant;
|
||||
|
||||
use ruin_reactivity::effect;
|
||||
use ruin_runtime::queue_future;
|
||||
@@ -25,6 +25,9 @@ use ruin_ui::{
|
||||
TextSystem, TextWrap, UiSize, WindowController, WindowSpec, WindowUpdate,
|
||||
layout_snapshot_with_cache,
|
||||
};
|
||||
#[cfg(target_os = "macos")]
|
||||
use ruin_ui_platform_macos::start_macos_ui;
|
||||
#[cfg(target_os = "linux")]
|
||||
use ruin_ui_platform_wayland::start_wayland_ui;
|
||||
|
||||
pub use ResourceState::{Pending, Ready};
|
||||
@@ -32,6 +35,16 @@ pub use ruin_app_proc_macros::{component, context_provider, view};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn start_platform_ui() -> ruin_ui::UiRuntime {
|
||||
start_wayland_ui()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn start_platform_ui() -> ruin_ui::UiRuntime {
|
||||
start_macos_ui()
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Window {
|
||||
spec: WindowSpec,
|
||||
@@ -149,7 +162,7 @@ impl<M: Mountable> MountedApp<M> {
|
||||
render_state,
|
||||
} = self;
|
||||
|
||||
let mut ui = start_wayland_ui();
|
||||
let mut ui = start_platform_ui();
|
||||
let window = ui.create_window(app_window.spec.clone())?;
|
||||
let initial_viewport = app_window
|
||||
.spec
|
||||
@@ -378,7 +391,7 @@ impl<M: Mountable> MountedApp<M> {
|
||||
}
|
||||
|
||||
fn handle_text_selection_event(
|
||||
window: &WindowController,
|
||||
_window: &WindowController,
|
||||
interaction_tree: &InteractionTree,
|
||||
event: &RoutedPointerEvent,
|
||||
text_selection: &TextSelectionState,
|
||||
@@ -439,7 +452,8 @@ impl<M: Mountable> MountedApp<M> {
|
||||
|
||||
if selection_changed {
|
||||
text_selection.version.update(|value| *value += 1);
|
||||
sync_primary_selection(window, interaction_tree, *text_selection.selection.borrow())?;
|
||||
#[cfg(target_os = "linux")]
|
||||
sync_primary_selection(_window, interaction_tree, *text_selection.selection.borrow())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1848,6 +1862,7 @@ fn apply_text_selection_overlay(
|
||||
scene.items = next_items;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn sync_primary_selection(
|
||||
window: &WindowController,
|
||||
interaction_tree: &InteractionTree,
|
||||
@@ -1983,8 +1998,9 @@ pub mod prelude {
|
||||
Pending, Ready, Resource, ResourceState, Result, ScrollBoxBuilder, ScrollBoxWidget,
|
||||
Shortcut, ShortcutScope, Signal, TextBuilder, TextChildren, TextRole, TextValue, View,
|
||||
WidgetRef, Window, block, button, colors, column, component, context_provider, provide,
|
||||
row, scroll_box, surfaces, text, use_context, use_effect, use_memo, use_resource, use_shortcut,
|
||||
use_shortcut_with_context, use_signal, use_widget_ref, use_window_title, view,
|
||||
row, scroll_box, surfaces, text, use_context, use_effect, use_memo, use_resource,
|
||||
use_shortcut, use_shortcut_with_context, use_signal, use_widget_ref, use_window_title,
|
||||
view,
|
||||
};
|
||||
pub use ruin_ui::{
|
||||
Border, Color, CursorIcon, Edges, Element, ElementId, InteractionTree, PointerButton,
|
||||
|
||||
Reference in New Issue
Block a user