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
34 changes: 13 additions & 21 deletions enable/abstract_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,35 @@ class AbstractWindow(HasTraits):

# A reference to the nested component that has focus. This is part of the
# manual mechanism for determining keyboard focus.
focus_owner = Instance(Interactor)
focus_owner = Instance(Interactor, transient=True)

# If set, this is the component to which all mouse events are passed,
# bypassing the normal event propagation mechanism.
mouse_owner = Instance(Interactor)
mouse_owner = Instance(Interactor, transient=True)

# The transform to apply to mouse event positions to put them into the
# relative coordinates of the mouse_owner component.
mouse_owner_transform = Any()
mouse_owner_transform = Any(transient=True)

# When a component captures the mouse, it can optionally store a
# dispatch order for events (until it releases the mouse).
mouse_owner_dispatch_history = Trait(None, None, List)
mouse_owner_dispatch_history = Trait(None, None, List, transient=True)

# A scaling constant applied to any GraphicsContext used for drawing the
# window's component.
base_pixel_scale = Float(1.0)
base_pixel_scale = Float(1.0, transient=True)

# When True, allow `base_pixel_scale` to be greater than 1 if the
# underlying toolkit supports it.
high_resolution = Bool(True)
high_resolution = Bool(True, transient=True)

# The background window of the window. The entire window first gets
# painted with this color before the component gets to draw.
bgcolor = ColorTrait("sys_window")

alt_pressed = Bool(False)
ctrl_pressed = Bool(False)
shift_pressed = Bool(False)
alt_pressed = Bool(False, transient=True)
ctrl_pressed = Bool(False, transient=True)
shift_pressed = Bool(False, transient=True)

# A container that gets drawn after & on top of the main component, and
# which receives events first.
Expand All @@ -81,18 +81,18 @@ class AbstractWindow(HasTraits):
resized = Event

# Whether to enable damaged region handling
use_damaged_region = Bool(False)
use_damaged_region = Bool(False, transient=True)

# The previous component that handled an event. Used to generate
# mouse_enter and mouse_leave events. Right now this can only be
# None, self.component, or self.overlay.
_prev_event_handler = Instance(Component)
_prev_event_handler = Instance(Component, transient=True)

# (dx, dy) integer size of the Window.
_size = Trait(None, Tuple)
_size = Trait(None, Tuple, transient=True)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added transient=True for all traits that were previously explicitly listed in __getstate__ to preserve behavior. Perhaps we should re-evaluate though what actually should/shouldn't be transient


# The regions to update upon redraw
_update_region = Any
_update_region = Any(transient=True)

# When exceeding this, the entire window is marked damaged to save memory
MAX_DAMAGED_REGIONS = 100
Expand Down Expand Up @@ -200,7 +200,6 @@ def get_pointer_position(self):
# ------------------------------------------------------------------------

def __init__(self, **traits):
self._scroll_origin = (0.0, 0.0)
self._update_region = None
self._gc = None
self._pointer_owner = None
Expand Down Expand Up @@ -547,13 +546,6 @@ def _paint(self, event=None):

self._update_region = []

def __getstate__(self):
attribs = ("component", "bgcolor", "overlay", "_scroll_origin")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_scroll_origin is set to (0,0) in the __init__ method, but I don't see it used anywhere. A search of the chaco and enable codebases yields 0 results. Perhaps it can just be removed entirely?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it should probably just be removed. I also don't see it being used in some older internal codebases.

state = {}
for attrib in attribs:
state[attrib] = getattr(self, attrib)
return state

# -------------------------------------------------------------------------
# Wire up the mouse event handlers
# -------------------------------------------------------------------------
Expand Down
17 changes: 3 additions & 14 deletions enable/scrolled.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Scrolled(Container):

# An alternate vertical scroll bar to control this Scrolled, instead of the
# default one that lives outside the scrolled region.
alternate_vsb = Instance(Component)
alternate_vsb = Instance(Component, transient=True)

# The size of the left border space
leftborder = Float(0)
Expand All @@ -92,8 +92,8 @@ class Scrolled(Container):
# Private traits
# -------------------------------------------------------------------------

_vsb = Instance(NativeScrollBar)
_hsb = Instance(NativeScrollBar)
_vsb = Instance(NativeScrollBar, transient=True)
_hsb = Instance(NativeScrollBar, transient=True)

# Stores the last horizontal and vertical scroll positions to avoid
# multiple updates in update_from_viewport()
Expand Down Expand Up @@ -606,14 +606,3 @@ def _container_handle_mouse_event(self, event, suffix):
elif self._vsb:
self._vsb._mouse_wheel_changed(event)
event.handled = True

# -------------------------------------------------------------------------
# Persistence
# -------------------------------------------------------------------------

def __getstate__(self):
state = super().__getstate__()
for key in ["alternate_vsb", "_vsb", "_hsb"]:
if key in state:
del state[key]
return state