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
6 changes: 6 additions & 0 deletions .github/workflows/test-with-edm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
sudo apt-get install libxcb-render-util0
sudo apt-get install libxcb-xinerama0
if: matrix.toolkit != 'null'
# NOTE : Temporarily needed for building enable from source
# Should be removed when enable 5.2 is released
- name: Install GL dependencies necessary to build enable
run: |
sudo apt-get update
sudo apt-get install libglu1-mesa-dev
- name: Cache EDM packages
uses: actions/cache@v2
with:
Expand Down
118 changes: 26 additions & 92 deletions chaco/plot_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
Int,
)
from enable.api import OverlayContainer
from enable.stacked_layout import stack_layout, stacked_preferred_size
from enable.stacked_container import HStackedContainer, VStackedContainer

try:
from enable.api import ConstraintsContainer
Expand Down Expand Up @@ -108,35 +108,23 @@ class OverlayPlotContainer(OverlayContainer):
draw_layer = Str("plot")


class StackedPlotContainer(BasePlotContainer):
class HPlotContainer(HStackedContainer):
"""
Base class for 1-D stacked plot containers, both horizontal and vertical.
A plot container that stacks all of its components horizontally. Resizable
components share the free space evenly. All components are stacked from
according to **stack_order* in the same order that they appear in the
**components** list.
"""

draw_order = Instance(list, args=(DEFAULT_DRAWING_ORDER,))

# The dimension along which to stack components that are added to
# this container.
stack_dimension = Enum("h", "v", transient=True)

# The "other" dimension, i.e., the dual of the stack dimension.
other_dimension = Enum("v", "h", transient=True)

# The index into obj.position and obj.bounds that corresponds to
# **stack_dimension**. This is a class-level and not an instance-level
# attribute. It must be 0 or 1.
stack_index = 0
#: Redefine the container layers to name the main layer as "plot" instead
#: of the Enable default of "mainlayer"
container_under_layers = Tuple("background", "image", "underlay", "plot")

def get_preferred_size(self, components=None):
"""Returns the size (width,height) that is preferred for this component.
draw_layer = Str("plot")

Overrides PlotComponent.
"""
return stacked_preferred_size(container=self, components=components)
draw_order = Instance(list, args=(DEFAULT_DRAWING_ORDER,))

def _do_stack_layout(self, components, align):
"""Helper method that does the actual work of layout."""
stack_layout(container=self, components=components, align=align)
_cached_preferred_size = Tuple(transient=True)

### Persistence ###########################################################

Expand All @@ -148,83 +136,29 @@ def __getstate__(self):
return state


class HPlotContainer(StackedPlotContainer):
"""
A plot container that stacks all of its components horizontally. Resizable
components share the free space evenly. All components are stacked from
according to **stack_order* in the same order that they appear in the
**components** list.
"""

draw_order = Instance(list, args=(DEFAULT_DRAWING_ORDER,))

#: The order in which components in the plot container are laid out.
stack_order = Enum("left_to_right", "right_to_left")

#: The amount of space to put between components.
spacing = Float(0.0)

#: The vertical alignment of objects that don't span the full height.
valign = Enum("bottom", "top", "center")

_cached_preferred_size = Tuple(transient=True)

def _do_layout(self):
"""Actually performs a layout (called by do_layout())."""
if self.stack_order == "left_to_right":
components = self.components
else:
components = self.components[::-1]

if self.valign == "bottom":
align = "min"
elif self.valign == "center":
align = "center"
else:
align = "max"

return self._do_stack_layout(components, align)


class VPlotContainer(StackedPlotContainer):
class VPlotContainer(VStackedContainer):
"""
A plot container that stacks plot components vertically.
"""

draw_order = Instance(list, args=(DEFAULT_DRAWING_ORDER,))

#: Overrides StackedPlotContainer.
stack_dimension = "v"
#: Overrides StackedPlotContainer.
other_dimension = "h"
#: Overrides StackedPlotContainer.
stack_index = 1

# VPlotContainer attributes
#: Redefine the container layers to name the main layer as "plot" instead
#: of the Enable default of "mainlayer"
container_under_layers = Tuple("background", "image", "underlay", "plot")

#: The horizontal alignment of objects that don't span the full width.
halign = Enum("left", "right", "center")
draw_layer = Str("plot")

#: The order in which components in the plot container are laid out.
stack_order = Enum("bottom_to_top", "top_to_bottom")
draw_order = Instance(list, args=(DEFAULT_DRAWING_ORDER,))

#: The amount of space to put between components.
spacing = Float(0.0)
_cached_preferred_size = Tuple(transient=True)

def _do_layout(self):
"""Actually performs a layout (called by do_layout())."""
if self.stack_order == "bottom_to_top":
components = self.components
else:
components = self.components[::-1]
if self.halign == "left":
align = "min"
elif self.halign == "center":
align = "center"
else:
align = "max"
### Persistence ###########################################################

return self._do_stack_layout(components, align)
# PICKLE FIXME: blocked with _pickles, but not sure that was correct.
def __getstate__(self):
state = super().__getstate__()
if "stack_index" in state:
del state["stack_index"]
return state


class GridPlotContainer(BasePlotContainer):
Expand Down
19 changes: 19 additions & 0 deletions ci/edmtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,25 @@ def install(runtime, toolkit, environment, editable, source):
click.echo("Creating environment '{environment}'".format(**parameters))
execute(commands, parameters)

# NOTE : temporary code to install enable from source instead of relying on
# enable 5.1.1. This should be removed immediately after enable 5.2.0 is
# released.
command = "edm plumbing remove-package --environment {environment} --force enable" # noqa
execute([command], parameters)
source_pkgs = [
"git+http://github.com/enthought/enable.git@maint/5.2#egg=enable"
]
# Without the --no-dependencies flag such that new dependencies on
# master are brought in.
commands = [
"python -m pip install --force-reinstall {pkg} ".format(pkg=pkg)
for pkg in source_pkgs
]
commands = [
"edm run -e {environment} -- " + command for command in commands
]
execute(commands, parameters)

if source:
# Remove EDM ETS packages and install them from source
cmd_fmt = (
Expand Down