Implemented window title update functionality for multiwindow.

This commit is contained in:
bungoboingo 2023-01-05 15:26:28 -08:00
parent 1944e98f82
commit ec41918ec4
14 changed files with 270 additions and 243 deletions

View file

@ -4,7 +4,6 @@ use crate::multi_window::Application;
use crate::window;
use crate::{Color, Debug, Point, Size, Viewport};
use std::collections::HashMap;
use std::marker::PhantomData;
use winit::event::{Touch, WindowEvent};
use winit::window::Window;
@ -31,8 +30,8 @@ where
<A::Renderer as crate::Renderer>::Theme: application::StyleSheet,
{
/// Creates a new [`State`] for the provided [`Application`] and window.
pub fn new(application: &A, window: &Window) -> Self {
let title = application.title();
pub fn new(application: &A, window_id: window::Id, window: &Window) -> Self {
let title = application.title(window_id);
let scale_factor = application.scale_factor();
let theme = application.theme();
let appearance = theme.appearance(&application.style());
@ -65,7 +64,7 @@ where
&self.viewport
}
/// TODO(derezzedex)
/// Returns whether or not the viewport changed.
pub fn viewport_changed(&self) -> bool {
self.viewport_changed
}
@ -184,12 +183,11 @@ where
pub fn synchronize(
&mut self,
application: &A,
windows: &HashMap<window::Id, Window>,
window_id: window::Id,
window: &Window,
) {
let window = windows.values().next().expect("No window found");
// Update window title
let new_title = application.title();
let new_title = application.title(window_id);
if self.title != new_title {
window.set_title(&new_title);