Skip to content

Commit

Permalink
Merge branch 'master' into feature/python3
Browse files Browse the repository at this point in the history
Conflicts:
	enable/viewport.py
  • Loading branch information
corranwebster committed Apr 29, 2016
2 parents 0b3cd68 + 9e8a545 commit aee0efe
Show file tree
Hide file tree
Showing 12 changed files with 599 additions and 55 deletions.
6 changes: 4 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include kiva/agg/agg.i
include chaco/tests/data/PngSuite/*.png
include chaco/tests/data/PngSuite/LICENSE.txt
include docs/Makefile
include docs/kiva/agg/notes
recursive-include docs *.py *.rst *.txt *.css *.png *.ico *.doc
recursive-include examples *.py *.txt *.gif *.jpg *.enaml
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
d = {}
execfile(os.path.join('..', '..', 'enable', '__init__.py'), d)
version = release = d['__version__']
execfile(os.path.join('..', '..', 'enable', '_version.py'), d)
version = release = d['full_version']

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
3 changes: 2 additions & 1 deletion enable/savage/svg/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ def open_image(self, path):
fin = open(path)

from PIL import Image
from kiva.compat import piltostring
import numpy
pil_img = Image.open(fin)
if pil_img.mode not in ('RGB', 'RGBA'):
pil_img = pil_img.convert('RGBA')
img = numpy.fromstring(pil_img.tostring(), numpy.uint8)
img = numpy.fromstring(piltostring(pil_img), numpy.uint8)
shape = (pil_img.size[1],pil_img.size[0],len(pil_img.mode))
img.shape = shape
return img
Expand Down
39 changes: 24 additions & 15 deletions enable/scrolled.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import with_statement

# Enthought library imports
from traits.api import Bool, Instance, Int, Any, Float
from traits.api import Any, Bool, DelegatesTo, Float, Instance, Int

# Local, relative imports
from .base import intersect_bounds, empty_rectangle
Expand All @@ -23,7 +23,17 @@ class Scrolled(Container):
component = Instance(Component)

# The viewport onto our component
viewport_component = Instance(Viewport)
viewport_component = Instance(Viewport, ())

# Whether or not the viewport should stay constrained to the bounds
# of the viewed component
stay_inside = DelegatesTo('viewport_component')

# Where to anchor vertically on resizes
vertical_anchor = DelegatesTo('viewport_component')

# Where to anchor vertically on resizes
horizontal_anchor = DelegatesTo('viewport_component')

# Inside padding is a background drawn area between the edges or scrollbars
# and the scrolled area/left component.
Expand Down Expand Up @@ -258,8 +268,8 @@ def _view_position_items_changed_for_viewport_component(self):
self.update_from_viewport()
return

def _component_bounds_items_handler(self, object, new):
if new.added != new.removed:
def _component_bounds_items_handler(self, object, event):
if event.added != event.removed:
self.update_bounds()

def _component_bounds_handler(self, object, name, old, new):
Expand Down Expand Up @@ -298,10 +308,14 @@ def _inside_padding_width_changed(self):

def _viewport_component_changed(self):
if self.viewport_component is None:
self.viewport_component = Viewport()
self.viewport_component.component = self.component
self.viewport_component.view_position = [0,0]
self.viewport_component = Viewport(
stay_inside=self.stay_inside,
vertical_anchor=self.vertical_anchor,
horizontal_anchor=self.horizontal_anchor,
)
self.viewport_component.view_bounds = self.bounds
self.viewport_component.component = self.component
self.viewport_component._initialize_position()
self.add(self.viewport_component)

def _alternate_vsb_changed(self, old, new):
Expand All @@ -323,12 +337,10 @@ def _component_update(self, old, new):
def _bounds_changed ( self, old, new ):
Component._bounds_changed( self, old, new )
self.update_bounds()
return

def _bounds_items_changed(self, event):
Component._bounds_items_changed(self, event)
self.update_bounds()
return


#---------------------------------------------------------------------------
Expand Down Expand Up @@ -400,6 +412,7 @@ def _do_layout ( self ):
range=range_x,
enabled=False,
)
self._hsb.scroll_position = self.viewport_component.view_position[0]
self._hsb.on_trait_change(self._handle_horizontal_scroll,
'scroll_position')
self._hsb.on_trait_change(self._mouse_thumb_changed,
Expand All @@ -411,8 +424,6 @@ def _do_layout ( self ):
self._hsb.position = hsb_position
elif self._hsb is not None:
self._hsb = self._release_sb(self._hsb)
if not hasattr(self.component, "bounds_offset"):
self.viewport_component.view_position[0] = 0
else:
# We don't need to render the horizontal scrollbar, and we don't
# have one to update, either.
Expand All @@ -432,9 +443,9 @@ def _do_layout ( self ):
self._vsb = NativeScrollBar(orientation = 'vertical',
bounds=bounds,
position=vsb_position,
range=range_y
range=range_y,
)

self._vsb.scroll_position = self.viewport_component.view_position[1]
self._vsb.on_trait_change(self._handle_vertical_scroll,
'scroll_position')
self._vsb.on_trait_change(self._mouse_thumb_changed,
Expand All @@ -446,8 +457,6 @@ def _do_layout ( self ):
self._vsb.range = range_y
elif self._vsb:
self._vsb = self._release_sb(self._vsb)
if not hasattr(self.component, "bounds_offset"):
self.viewport_component.view_position[1] = 0
else:
# We don't need to render the vertical scrollbar, and we don't
# have one to update, either.
Expand Down
Loading

0 comments on commit aee0efe

Please sign in to comment.