Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ fn make_light_style() -> StyleResource {
}

impl Editor {
pub const UI_FONT_SIZE: &'static str = "Editor.UI.Font.Size";

pub fn new(startup_data: Option<StartupData>) -> Self {
Self::new_with_settings(startup_data, Default::default())
}
Expand Down
8 changes: 7 additions & 1 deletion fyrox-ui/src/formatted_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
variable::InheritableVariable, visitor::prelude::*,
},
font::{Font, FontGlyph, FontHeight, FontResource, BUILT_IN_FONT},
style::StyledProperty,
style::{resource::StyleResource, StyledProperty},
HorizontalAlignment, Thickness, VerticalAlignment,
};
use fyrox_resource::state::{LoadError, ResourceState};
Expand Down Expand Up @@ -727,6 +727,12 @@ impl FormattedText {
self
}

/// Sets desired style.
pub fn set_style(&mut self, style: &StyleResource) -> &mut Self {
self.font_size.update(style);
self
}

/// Runs can optionally modify various style settings for portions of the text.
/// Later runs override earlier runs if their ranges overlap and the later run
/// sets a property that conflicts with an earlier run.
Expand Down
8 changes: 7 additions & 1 deletion fyrox-ui/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use crate::{
style::{resource::StyleResourceExt, Style, StyledProperty},
widget::{Widget, WidgetBuilder},
BBCode, BuildContext, Control, HorizontalAlignment, UiNode, UserInterface, VerticalAlignment,
WidgetMessage,
};
use fyrox_core::algebra::Matrix3;
use fyrox_core::variable::InheritableVariable;
Expand Down Expand Up @@ -401,7 +402,12 @@ impl Control for Text {
self.widget.handle_routed_message(ui, message);

if message.destination() == self.handle() {
if let Some(msg) = message.data::<TextMessage>() {
if let Some(msg) = message.data::<WidgetMessage>() {
if let WidgetMessage::Style(style) = msg {
self.formatted_text.borrow_mut().set_style(style);
self.invalidate_layout();
}
} else if let Some(msg) = message.data::<TextMessage>() {
let mut text_ref = self.formatted_text.borrow_mut();
match msg {
TextMessage::BBCode(text) => {
Expand Down
4 changes: 4 additions & 0 deletions fyrox-ui/src/text_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,10 @@ impl Control for TextBox {
self.selecting = false;
ui.release_mouse_capture();
}
WidgetMessage::Style(style) => {
self.formatted_text.borrow_mut().set_style(style);
self.invalidate_layout();
}
_ => {}
}
} else if let Some(msg) = message.data::<TextMessage>() {
Expand Down
Loading