Make Attach struct public in devtools
This commit is contained in:
parent
6bf709e03e
commit
fcff94fca3
1 changed files with 77 additions and 83 deletions
|
|
@ -28,9 +28,15 @@ use crate::widget::{
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
pub fn attach(program: impl Program + 'static) -> impl Program {
|
pub fn attach<P: Program + 'static>(program: P) -> Attach<P> {
|
||||||
struct Attach<P> {
|
Attach { program }
|
||||||
program: P,
|
}
|
||||||
|
|
||||||
|
/// A [`Program`] with some devtools attached to it.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Attach<P> {
|
||||||
|
/// The original [`Program`] managed by these devtools.
|
||||||
|
pub program: P,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P> Program for Attach<P>
|
impl<P> Program for Attach<P>
|
||||||
|
|
@ -53,10 +59,7 @@ pub fn attach(program: impl Program + 'static) -> impl Program {
|
||||||
|
|
||||||
(
|
(
|
||||||
devtools,
|
devtools,
|
||||||
Task::batch([
|
Task::batch([boot.map(Event::Program), task.map(Event::Message)]),
|
||||||
boot.map(Event::Program),
|
|
||||||
task.map(Event::Message),
|
|
||||||
]),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,19 +90,11 @@ pub fn attach(program: impl Program + 'static) -> impl Program {
|
||||||
state.subscription(&self.program)
|
state.subscription(&self.program)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn theme(
|
fn theme(&self, state: &Self::State, window: window::Id) -> Self::Theme {
|
||||||
&self,
|
|
||||||
state: &Self::State,
|
|
||||||
window: window::Id,
|
|
||||||
) -> Self::Theme {
|
|
||||||
state.theme(&self.program, window)
|
state.theme(&self.program, window)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn style(
|
fn style(&self, state: &Self::State, theme: &Self::Theme) -> theme::Style {
|
||||||
&self,
|
|
||||||
state: &Self::State,
|
|
||||||
theme: &Self::Theme,
|
|
||||||
) -> theme::Style {
|
|
||||||
state.style(&self.program, theme)
|
state.style(&self.program, theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,10 +103,9 @@ pub fn attach(program: impl Program + 'static) -> impl Program {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Attach { program }
|
/// The state of the devtools.
|
||||||
}
|
#[allow(missing_debug_implementations)]
|
||||||
|
pub struct DevTools<P>
|
||||||
struct DevTools<P>
|
|
||||||
where
|
where
|
||||||
P: Program,
|
P: Program,
|
||||||
{
|
{
|
||||||
|
|
@ -122,7 +116,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
enum Message {
|
pub enum Message {
|
||||||
HideNotification,
|
HideNotification,
|
||||||
ToggleComet,
|
ToggleComet,
|
||||||
CometLaunched(comet::launch::Result),
|
CometLaunched(comet::launch::Result),
|
||||||
|
|
@ -403,7 +397,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Event<P>
|
pub enum Event<P>
|
||||||
where
|
where
|
||||||
P: Program,
|
P: Program,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue