mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: remove redundant type param
This commit is contained in:
parent
c033a5618b
commit
df3dac183e
12 changed files with 113 additions and 125 deletions
|
|
@ -1,17 +1,17 @@
|
|||
use crate::*;
|
||||
|
||||
/// A component that may contain [Focusable] components.
|
||||
pub trait Focus <const N: usize, T, U>: Render<T, U> + Handle<T, U> {
|
||||
pub trait Focus <const N: usize, E: Engine>: Render<E> + Handle<E> {
|
||||
fn focus (&self) -> usize;
|
||||
fn focus_mut (&mut self) -> &mut usize;
|
||||
fn focusable (&self) -> [&dyn Focusable<T, U>;N];
|
||||
fn focusable_mut (&mut self) -> [&mut dyn Focusable<T, U>;N];
|
||||
fn focusable (&self) -> [&dyn Focusable<E>;N];
|
||||
fn focusable_mut (&mut self) -> [&mut dyn Focusable<E>;N];
|
||||
|
||||
fn focused (&self) -> &dyn Focusable<T, U> {
|
||||
fn focused (&self) -> &dyn Focusable<E> {
|
||||
let focus = self.focus();
|
||||
self.focusable()[focus]
|
||||
}
|
||||
fn focused_mut (&mut self) -> &mut dyn Focusable<T, U> {
|
||||
fn focused_mut (&mut self) -> &mut dyn Focusable<E> {
|
||||
let focus = self.focus();
|
||||
self.focusable_mut()[focus]
|
||||
}
|
||||
|
|
@ -33,13 +33,13 @@ pub trait Focus <const N: usize, T, U>: Render<T, U> + Handle<T, U> {
|
|||
}
|
||||
|
||||
/// A component that may be focused.
|
||||
pub trait Focusable<T, U>: Render<T, U> + Handle<T, U> {
|
||||
pub trait Focusable<E: Engine>: Render<E> + Handle<E> {
|
||||
fn is_focused (&self) -> bool;
|
||||
fn set_focused (&mut self, focused: bool);
|
||||
}
|
||||
|
||||
impl<F: Focusable<T, U>, T, U> Focusable<T, U> for Option<F>
|
||||
where Option<F>: Render<T, U>
|
||||
impl<F: Focusable<E>, E: Engine> Focusable<E> for Option<F>
|
||||
where Option<F>: Render<E>
|
||||
{
|
||||
fn is_focused (&self) -> bool {
|
||||
match self {
|
||||
|
|
@ -59,21 +59,21 @@ impl<F: Focusable<T, U>, T, U> Focusable<T, U> for Option<F>
|
|||
($struct:ident ($focus:ident) : $count:expr => [
|
||||
$($focusable:ident),*
|
||||
]) => {
|
||||
impl Focus<$count, T, U> for $struct {
|
||||
impl Focus<$count, E> for $struct {
|
||||
fn focus (&self) -> usize {
|
||||
self.$focus
|
||||
}
|
||||
fn focus_mut (&mut self) -> &mut usize {
|
||||
&mut self.$focus
|
||||
}
|
||||
fn focusable (&self) -> [&dyn Focusable<T, U>;$count] {
|
||||
fn focusable (&self) -> [&dyn Focusable<E>;$count] {
|
||||
[
|
||||
$(&self.$focusable as &dyn Focusable<T, U>,)*
|
||||
$(&self.$focusable as &dyn Focusable<E>,)*
|
||||
]
|
||||
}
|
||||
fn focusable_mut (&mut self) -> [&mut dyn Focusable<T, U>;$count] {
|
||||
fn focusable_mut (&mut self) -> [&mut dyn Focusable<E>;$count] {
|
||||
[
|
||||
$(&mut self.$focusable as &mut dyn Focusable<T, U>,)*
|
||||
$(&mut self.$focusable as &mut dyn Focusable<E>,)*
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue