Skip to content

Commit

Permalink
rename view style method to style_pass. (#478)
Browse files Browse the repository at this point in the history
This is to avoid confusion with the style method on the Decorators trait.
This rename makes it so that when you want to call the style method on a view,
but the Decorators trait isn't yet in scope, rust analyzer will suggest the
correct method name.
  • Loading branch information
jrmoulton committed May 30, 2024
1 parent 5b6916a commit f91ce6f
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ impl<'a> StyleCx<'a> {
}
}

view.borrow_mut().style(self);
view.borrow_mut().style_pass(self);

self.restore();
}
Expand Down
6 changes: 3 additions & 3 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub trait View {
///
/// If the style changes needs other passes to run you're expected to call
/// `cx.app_state_mut().request_changes`.
fn style(&mut self, cx: &mut StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut StyleCx<'_>) {
for child in self.id().children() {
cx.style_view(child);
}
Expand Down Expand Up @@ -319,8 +319,8 @@ impl View for Box<dyn View> {
(**self).update(cx, state)
}

fn style(&mut self, cx: &mut StyleCx) {
(**self).style(cx)
fn style_pass(&mut self, cx: &mut StyleCx) {
(**self).style_pass(cx)
}

fn layout(&mut self, cx: &mut LayoutCx) -> NodeId {
Expand Down
2 changes: 1 addition & 1 deletion src/views/dropdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<T: 'static> View for DropDown<T> {
"DropDown".into()
}

fn style(&mut self, cx: &mut crate::context::StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut crate::context::StyleCx<'_>) {
if self.style.read(cx) {
cx.app_state_mut().request_paint(self.id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/editor/gutter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl View for EditorGutterView {
"Editor Gutter View".into()
}

fn style(&mut self, cx: &mut crate::context::StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut crate::context::StyleCx<'_>) {
if self.gutter_style.read(cx) {
cx.app_state_mut().request_paint(self.id());
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/editor/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ impl View for EditorView {
self.id
}

fn style(&mut self, cx: &mut crate::context::StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut crate::context::StyleCx<'_>) {
self.editor.with_untracked(|ed| {
ed.es.update(|s| {
if s.read(cx) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl View for Label {
}
}

fn style(&mut self, cx: &mut crate::context::StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut crate::context::StyleCx<'_>) {
if self.font.read(cx) | self.style.read(cx) {
self.text_layout = None;
self.available_text = None;
Expand Down
2 changes: 1 addition & 1 deletion src/views/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl View for Item {
"Item".into()
}

fn style(&mut self, cx: &mut StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut StyleCx<'_>) {
let selected = self.selection.get_untracked();
if Some(self.index) == selected {
cx.save();
Expand Down
2 changes: 1 addition & 1 deletion src/views/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ impl View for Scroll {
found
}

fn style(&mut self, cx: &mut crate::context::StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut crate::context::StyleCx<'_>) {
let style = cx.style();

self.scroll_style.read(cx);
Expand Down
2 changes: 1 addition & 1 deletion src/views/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl View for Slider {
EventPropagation::Continue
}

fn style(&mut self, cx: &mut crate::context::StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut crate::context::StyleCx<'_>) {
let style = cx.style();
let mut paint = false;

Expand Down
2 changes: 1 addition & 1 deletion src/views/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<T> View for Tab<T> {
}
}

fn style(&mut self, cx: &mut StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut StyleCx<'_>) {
for (i, child) in self.id.children().into_iter().enumerate() {
cx.style_view(child);
let child_view = child.state();
Expand Down
2 changes: 1 addition & 1 deletion src/views/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ impl View for TextInput {
EventPropagation::Continue
}

fn style(&mut self, cx: &mut crate::context::StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut crate::context::StyleCx<'_>) {
let style = cx.style();
if self.font.read(cx) || self.text_buf.is_none() {
self.update_text_layout();
Expand Down
2 changes: 1 addition & 1 deletion src/views/toggle_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl View for ToggleButton {
None
}

fn style(&mut self, cx: &mut crate::context::StyleCx<'_>) {
fn style_pass(&mut self, cx: &mut crate::context::StyleCx<'_>) {
if self.style.read(cx) {
cx.app_state_mut().request_paint(self.id);
}
Expand Down

0 comments on commit f91ce6f

Please sign in to comment.