#![allow(missing_docs)] use iced_debug as debug; use iced_program as program; use iced_widget as widget; use iced_widget::core; use iced_widget::runtime; use iced_widget::runtime::futures; use crate::core::Element; use crate::core::keyboard; use crate::core::theme::{self, Base, Theme}; use crate::core::time::seconds; use crate::core::window; use crate::futures::Subscription; use crate::futures::futures::channel::oneshot; use crate::program::Program; use crate::runtime::Task; use crate::widget::{bottom_right, container, stack, text, themer}; use std::fmt; use std::thread; pub fn attach(program: impl Program + 'static) -> impl Program { struct Attach
{ program: P, } impl
Program for Attach
where P: Program + 'static, { type State = DevTools
; type Message = Message
;
type Theme = P::Theme;
type Renderer = P::Renderer;
type Executor = P::Executor;
fn name() -> &'static str {
P::name()
}
fn boot(&self) -> (Self::State, Task
where
P: Program,
{
state: P::State,
show_notification: bool,
}
impl DevTools
where
P: Program + 'static,
{
pub fn new(state: P::State) -> (Self, Task ,
) -> Task , P::Theme, P::Renderer> {
let view = program.view(&self.state, window).map(Message::Program);
let theme = program.theme(&self.state, window);
let notification = themer(
theme
.palette()
.map(|palette| Theme::custom("DevTools".to_owned(), palette))
.unwrap_or_default(),
bottom_right(
container(text("Press F12 to open debug metrics"))
.padding(10)
.style(container::dark),
),
);
stack![view]
.push_maybe(self.show_notification.then_some(notification))
.into()
}
pub fn subscription(&self, program: &P) -> Subscription
where
P: Program,
{
HideNotification,
ToggleComet,
Program(P::Message),
}
impl fmt::Debug for Message
where
P: Program,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Message::HideNotification => {
f.write_str("DevTools(HideNotification)")
}
Message::ToggleComet => f.write_str("DevTools(ToggleComet)"),
Message::Program(message) => message.fmt(f),
}
}
}