Inherit Theme palette from Program in tester
This commit is contained in:
parent
d47c921b29
commit
964a4707dc
1 changed files with 22 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ use crate::core::Length::Fill;
|
|||
use crate::core::alignment::Horizontal::Right;
|
||||
use crate::core::border;
|
||||
use crate::core::mouse;
|
||||
use crate::core::theme;
|
||||
use crate::core::window;
|
||||
use crate::core::{Color, Element, Font, Settings, Size, Theme};
|
||||
use crate::futures::futures::channel::mpsc;
|
||||
|
|
@ -95,6 +96,14 @@ where
|
|||
) -> Element<'a, Self::Message, Self::Theme, Self::Renderer> {
|
||||
state.view(&self.program, window).map(Message)
|
||||
}
|
||||
|
||||
fn theme(&self, state: &Self::State, window: window::Id) -> Option<Theme> {
|
||||
state
|
||||
.theme(&self.program, window)
|
||||
.as_ref()
|
||||
.and_then(theme::Base::palette)
|
||||
.map(|palette| Theme::custom("Tester", palette))
|
||||
}
|
||||
}
|
||||
|
||||
/// A tester decorates a [`Program`] definition and attaches a test recorder on top.
|
||||
|
|
@ -399,6 +408,19 @@ impl<P: Program + 'static> Tester<P> {
|
|||
self.edit = None;
|
||||
}
|
||||
|
||||
fn theme(&self, program: &P, window: window::Id) -> Option<P::Theme> {
|
||||
match &self.state {
|
||||
State::Empty => None,
|
||||
State::Idle { state } => program.theme(state, window),
|
||||
State::Recording { emulator } | State::Playing { emulator, .. } => {
|
||||
emulator.theme(program)
|
||||
}
|
||||
State::Asserting { state, window, .. } => {
|
||||
program.theme(state, *window)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn preset<'a>(
|
||||
&self,
|
||||
program: &'a P,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue