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
69 changes: 33 additions & 36 deletions chaco/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
Enum,
Callable,
ArrayOrNone,
observe
)

# Local relative imports
Expand Down Expand Up @@ -778,42 +779,38 @@ def _title_changed(self):
if self.component:
self.component.invalidate_draw()

def _anytrait_changed(self, name, old, new):
"""For every trait that defines a visual attribute
we just call _invalidate() when a change is made.
"""
invalidate_traits = [
"title_font",
"title_spacing",
"title_color",
"title_angle",
"tick_weight",
"tick_color",
"tick_label_font",
"tick_label_color",
"tick_label_rotate_angle",
"tick_label_alignment",
"tick_label_margin",
"tick_label_offset",
"tick_label_position",
"tick_label_formatter",
"tick_in",
"tick_out",
"tick_visible",
"tick_interval",
"tick_generator",
"orientation",
"origin",
"axis_line_visible",
"axis_line_color",
"axis_line_weight",
"axis_line_style",
"small_haxis_style",
"ensure_labels_bounded",
"ensure_ticks_bounded",
]
if name in invalidate_traits:
self._invalidate()
@observe([
"title_font",
"title_spacing",
"title_color",
"title_angle",
"tick_weight",
"tick_color",
"tick_label_font",
"tick_label_color",
"tick_label_rotate_angle",
"tick_label_alignment",
"tick_label_margin",
"tick_label_offset",
"tick_label_position",
"tick_label_formatter",
"tick_in",
"tick_out",
"tick_visible",
"tick_interval",
"tick_generator",
"orientation",
"origin",
"axis_line_visible",
"axis_line_color",
"axis_line_weight",
"axis_line_style",
"small_haxis_style",
"ensure_labels_bounded",
"ensure_ticks_bounded",
])
def _invalidate_on_changed_visual_attr(self, event):
self._invalidate()

# ------------------------------------------------------------------------
# Initialization-related methods
Expand Down
45 changes: 22 additions & 23 deletions chaco/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Instance,
Int,
List,
observe,
Str,
)

Expand Down Expand Up @@ -487,29 +488,27 @@ def _composite_icon_renderer_default(self):
return CompositeIconRenderer()

# -- trait handlers --------------------------------------------------------
def _anytrait_changed(self, name, old, new):
if name in (
"font",
"border_padding",
"padding",
"line_spacing",
"icon_bounds",
"icon_spacing",
"labels",
"plots",
"plots_items",
"labels_items",
"border_width",
"align",
"position",
"position_items",
"bounds",
"bounds_items",
"label_at_top",
):
self._layout_needed = True
if name == "color":
self.get_preferred_size()
@observe([
"font",
"border_padding",
"padding",
"line_spacing",
"icon_bounds",
"icon_spacing",
"labels.items",
"plots.items",
"border_width",
"align",
"position.items",
"bounds.items",
"title_at_top",
Comment thread
rahulporuri marked this conversation as resolved.
])
def _invalidate_existing_layout(self, event):
self._layout_needed = True
Comment thread
aaronayres35 marked this conversation as resolved.

@observe("color")
def _update_caches(self, event):
self.get_preferred_size()
Comment thread
aaronayres35 marked this conversation as resolved.

def _plots_changed(self):
"""Invalidate the caches."""
Expand Down
16 changes: 5 additions & 11 deletions examples/demo/advanced/scalar_image_function_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,11 @@ def compute_model(self):
self.model_changed = True
self._function = self.function

def _anytrait_changed(self, name, value):
if name in [
"function",
"npts_x",
"npts_y",
"min_x",
"max_x",
"min_y",
"max_y",
]:
self.compute_model()
@observe(
["function", "npts_x", "npts_y", "min_x", "max_x", "min_y", "max_y"]
)
def _compute_model_on_trait_update(self, event):
self.compute_model()


class PlotUI(HasTraits):
Expand Down