fix: video placeholder
This commit is contained in:
parent
e718b8e322
commit
10cd15d942
@ -4,7 +4,7 @@ use crate::route::RouteServices;
|
|||||||
use crate::services::ndb_wrapper::{NDBWrapper, SubWrapper};
|
use crate::services::ndb_wrapper::{NDBWrapper, SubWrapper};
|
||||||
use crate::stream_info::StreamInfo;
|
use crate::stream_info::StreamInfo;
|
||||||
use crate::theme::{MARGIN_DEFAULT, NEUTRAL_800, ROUNDING_DEFAULT};
|
use crate::theme::{MARGIN_DEFAULT, NEUTRAL_800, ROUNDING_DEFAULT};
|
||||||
use crate::widgets::{Chat, NostrWidget, StreamPlayer, StreamTitle, WriteChat};
|
use crate::widgets::{Chat, NostrWidget, PlaceholderRect, StreamPlayer, StreamTitle, WriteChat};
|
||||||
use egui::{vec2, Align, Frame, Layout, Response, Stroke, Ui, Vec2, Widget};
|
use egui::{vec2, Align, Frame, Layout, Response, Stroke, Ui, Vec2, Widget};
|
||||||
use nostrdb::{Filter, Note, NoteKey, Transaction};
|
use nostrdb::{Filter, Note, NoteKey, Transaction};
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
@ -47,11 +47,15 @@ impl StreamPage {
|
|||||||
Vec2::new(w, h),
|
Vec2::new(w, h),
|
||||||
Layout::top_down_justified(Align::Min),
|
Layout::top_down_justified(Align::Min),
|
||||||
|ui| {
|
|ui| {
|
||||||
if let Some(player) = &mut self.player {
|
let video_h =
|
||||||
let video_h =
|
((ui.available_width() / 16.0) * 9.0).min(ui.available_height() * 0.33);
|
||||||
((ui.available_width() / 16.0) * 9.0).min(ui.available_height() * 0.33);
|
ui.allocate_ui(vec2(ui.available_width(), video_h), |ui| {
|
||||||
ui.allocate_ui(vec2(ui.available_width(), video_h), |ui| player.ui(ui));
|
if let Some(player) = &mut self.player {
|
||||||
}
|
player.ui(ui)
|
||||||
|
} else {
|
||||||
|
ui.add(PlaceholderRect)
|
||||||
|
}
|
||||||
|
});
|
||||||
StreamTitle::new(&event).render(ui, services);
|
StreamTitle::new(&event).render(ui, services);
|
||||||
|
|
||||||
if let Some(c) = self.chat.as_mut() {
|
if let Some(c) = self.chat.as_mut() {
|
||||||
@ -87,9 +91,13 @@ impl StreamPage {
|
|||||||
Layout::left_to_right(Align::TOP).with_main_justify(true),
|
Layout::left_to_right(Align::TOP).with_main_justify(true),
|
||||||
|ui| {
|
|ui| {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
if let Some(player) = &mut self.player {
|
ui.allocate_ui(vec2(video_width, video_height), |ui| {
|
||||||
ui.allocate_ui(vec2(video_width, video_height), |ui| player.ui(ui));
|
if let Some(player) = &mut self.player {
|
||||||
}
|
player.ui(ui)
|
||||||
|
} else {
|
||||||
|
ui.add(PlaceholderRect)
|
||||||
|
}
|
||||||
|
});
|
||||||
ui.add_space(10.);
|
ui.add_space(10.);
|
||||||
StreamTitle::new(&event).render(ui, services);
|
StreamTitle::new(&event).render(ui, services);
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@ mod button;
|
|||||||
mod chat;
|
mod chat;
|
||||||
mod chat_message;
|
mod chat_message;
|
||||||
mod header;
|
mod header;
|
||||||
|
mod placeholder_rect;
|
||||||
mod profile;
|
mod profile;
|
||||||
mod stream_list;
|
mod stream_list;
|
||||||
mod stream_player;
|
mod stream_player;
|
||||||
@ -10,7 +11,6 @@ mod stream_tile;
|
|||||||
mod stream_title;
|
mod stream_title;
|
||||||
mod text_input;
|
mod text_input;
|
||||||
mod username;
|
mod username;
|
||||||
mod video_placeholder;
|
|
||||||
mod write_chat;
|
mod write_chat;
|
||||||
|
|
||||||
use crate::route::RouteServices;
|
use crate::route::RouteServices;
|
||||||
@ -24,11 +24,11 @@ pub use self::avatar::Avatar;
|
|||||||
pub use self::button::Button;
|
pub use self::button::Button;
|
||||||
pub use self::chat::Chat;
|
pub use self::chat::Chat;
|
||||||
pub use self::header::Header;
|
pub use self::header::Header;
|
||||||
|
pub use self::placeholder_rect::PlaceholderRect;
|
||||||
pub use self::profile::Profile;
|
pub use self::profile::Profile;
|
||||||
pub use self::stream_list::StreamList;
|
pub use self::stream_list::StreamList;
|
||||||
pub use self::stream_player::StreamPlayer;
|
pub use self::stream_player::StreamPlayer;
|
||||||
pub use self::stream_title::StreamTitle;
|
pub use self::stream_title::StreamTitle;
|
||||||
pub use self::text_input::NativeTextInput;
|
pub use self::text_input::NativeTextInput;
|
||||||
pub use self::username::Username;
|
pub use self::username::Username;
|
||||||
pub use self::video_placeholder::VideoPlaceholder;
|
|
||||||
pub use self::write_chat::WriteChat;
|
pub use self::write_chat::WriteChat;
|
||||||
|
13
src/widgets/placeholder_rect.rs
Normal file
13
src/widgets/placeholder_rect.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use crate::theme::{NEUTRAL_800, ROUNDING_DEFAULT};
|
||||||
|
use egui::{Response, Sense, Ui, Widget};
|
||||||
|
|
||||||
|
pub struct PlaceholderRect;
|
||||||
|
|
||||||
|
impl Widget for PlaceholderRect {
|
||||||
|
fn ui(self, ui: &mut Ui) -> Response {
|
||||||
|
let img_size = ui.available_size();
|
||||||
|
let (response, painter) = ui.allocate_painter(img_size, Sense::click());
|
||||||
|
painter.rect_filled(response.rect, ROUNDING_DEFAULT, NEUTRAL_800);
|
||||||
|
response
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
use crate::widgets::VideoPlaceholder;
|
use crate::widgets::PlaceholderRect;
|
||||||
use egui::{Context, Response, Ui, Vec2, Widget};
|
use egui::{Context, Response, Ui, Vec2, Widget};
|
||||||
use egui_video::{Player, PlayerControls};
|
use egui_video::{Player, PlayerControls};
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ impl Widget for &mut StreamPlayer {
|
|||||||
if let Some(p) = self.player.as_mut() {
|
if let Some(p) = self.player.as_mut() {
|
||||||
ui.add_sized(size, p)
|
ui.add_sized(size, p)
|
||||||
} else {
|
} else {
|
||||||
VideoPlaceholder.ui(ui)
|
PlaceholderRect.ui(ui)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,11 @@ impl Widget for StreamEvent<'_> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
painter.rect_filled(response.rect, 12., NEUTRAL_800);
|
painter.rect_filled(response.rect, ROUNDING_DEFAULT, NEUTRAL_800);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
painter.rect_filled(response.rect, 12., NEUTRAL_800);
|
painter.rect_filled(response.rect, ROUNDING_DEFAULT, NEUTRAL_800);
|
||||||
}
|
}
|
||||||
|
|
||||||
let overlay_label_pad = Vec2::new(5., 5.);
|
let overlay_label_pad = Vec2::new(5., 5.);
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
use egui::{Color32, Response, Rounding, Sense, Ui, Vec2, Widget};
|
|
||||||
|
|
||||||
pub struct VideoPlaceholder;
|
|
||||||
|
|
||||||
impl Widget for VideoPlaceholder {
|
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
|
||||||
let w = ui.available_width();
|
|
||||||
let h = (w / 16.0) * 9.0;
|
|
||||||
let img_size = Vec2::new(w, h);
|
|
||||||
|
|
||||||
let (response, painter) = ui.allocate_painter(img_size, Sense::click());
|
|
||||||
painter.rect_filled(
|
|
||||||
response.rect,
|
|
||||||
Rounding::same(12.),
|
|
||||||
Color32::from_rgb(200, 200, 200),
|
|
||||||
);
|
|
||||||
response
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user