mirror of
https://github.com/lisk77/comet.git
synced 2025-12-12 09:08:49 +00:00
refactor(components): texts now store a String to allow mutable text
This commit is contained in:
parent
c0ce4e60ee
commit
9a47ee7b55
1 changed files with 7 additions and 7 deletions
|
|
@ -59,7 +59,7 @@ pub struct Camera2D {
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Text {
|
pub struct Text {
|
||||||
content: &'static str,
|
content: String,
|
||||||
font: &'static str,
|
font: &'static str,
|
||||||
font_size: f32,
|
font_size: f32,
|
||||||
color: Color,
|
color: Color,
|
||||||
|
|
@ -462,14 +462,14 @@ impl Camera for Camera2D {
|
||||||
|
|
||||||
impl Text {
|
impl Text {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
content: &'static str,
|
content: impl Into<String>,
|
||||||
font: &'static str,
|
font: &'static str,
|
||||||
font_size: f32,
|
font_size: f32,
|
||||||
is_visible: bool,
|
is_visible: bool,
|
||||||
color: impl ColorTrait,
|
color: impl ColorTrait,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
content,
|
content: content.into(),
|
||||||
font,
|
font,
|
||||||
font_size,
|
font_size,
|
||||||
color: Color::from_wgpu_color(color.to_wgpu()),
|
color: Color::from_wgpu_color(color.to_wgpu()),
|
||||||
|
|
@ -478,12 +478,12 @@ impl Text {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn content(&self) -> &'static str {
|
pub fn content(&self) -> &str {
|
||||||
self.content
|
&self.content
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_content(&mut self, content: &'static str) {
|
pub fn set_content(&mut self, content: impl Into<String>) {
|
||||||
self.content = content;
|
self.content = content.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn font(&self) -> &'static str {
|
pub fn font(&self) -> &'static str {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue