Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cc88479
basic scaffold done
kushalkolar Sep 13, 2026
08af418
inheritance
kushalkolar Sep 13, 2026
9bf1c7c
done
kushalkolar Sep 14, 2026
364e8bf
config works!
kushalkolar Sep 14, 2026
8cbe3ee
config on graphics
kushalkolar Sep 14, 2026
0082501
axes config
kushalkolar Sep 14, 2026
bce7736
full config implementation basically works
kushalkolar Sep 14, 2026
593111e
fix
kushalkolar Sep 14, 2026
ad75df4
mixins call Graphic construtors with kwargs nothing is positional
kushalkolar Sep 14, 2026
e8e2f0e
print
kushalkolar Sep 14, 2026
97d6e47
config presets
kushalkolar Sep 14, 2026
5fb0ffd
comments, docstrings
kushalkolar Sep 14, 2026
26a5aab
docstrings
kushalkolar Sep 14, 2026
febb665
remove ConfigValue
kushalkolar Sep 15, 2026
62606a4
comments
kushalkolar Sep 15, 2026
a54c021
much better add graphics mixin using descriptors, examples, fix a test
kushalkolar Sep 15, 2026
575c028
anotehr example
kushalkolar Sep 15, 2026
3b92364
GlobalConfig.to_dict()
kushalkolar Sep 15, 2026
bc25682
docs
kushalkolar Sep 15, 2026
82ba3e1
reset to default config after each screenshot test
kushalkolar Sep 15, 2026
c16ee88
add_<graphics>() stub generator, fix maintain_aspect logic w.r.t. con…
kushalkolar Sep 15, 2026
09dfc8d
change so maintain_aspect can be tested better
kushalkolar Sep 15, 2026
7366725
docstring
kushalkolar Sep 15, 2026
23901a3
reset config after running each docs gallery examle
kushalkolar Sep 15, 2026
dcd63bf
better example
kushalkolar Sep 15, 2026
b8dd4b3
docs
kushalkolar Sep 15, 2026
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
Prev Previous commit
Next Next commit
full config implementation basically works
  • Loading branch information
kushalkolar committed Sep 14, 2026
commit bce773629014990af9599e1b416ce85e73a2a366
24 changes: 17 additions & 7 deletions fastplotlib/layouts/_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@
from ._utils import controller_types as valid_controller_types
from ._subplot import Subplot
from ._engine import GridLayout, WindowLayout, ScreenSpaceCamera
from .. import ImageGraphic, ImageYUVGraphic
from ..graphics import ImageGraphic, ImageYUVGraphic
from ..utils import global_config, ConfigValue


@global_config.register
class Figure:
config = global_config.descriptor

@global_config.set(size=(500, 300))
def __init__(
self,
shape: tuple[int, int] = (1, 1),
Expand All @@ -48,7 +53,7 @@ def __init__(
canvas: str | BaseRenderCanvas | pygfx.Texture = None,
renderer: pygfx.WgpuRenderer = None,
canvas_kwargs: dict = None,
size: tuple[int, int] = (500, 300),
size: tuple[int, int] = ConfigValue,
names: list | np.ndarray = None,
):
"""
Expand Down Expand Up @@ -569,11 +574,16 @@ def _start_render(self):
"""start render cycle"""
self.canvas.request_draw(self._render)

@global_config.set(
autoscale=True,
maintain_aspect=True,
axes_visible=True,
)
def show(
self,
autoscale: bool = True,
maintain_aspect: bool = None,
axes_visible: bool = True,
autoscale: bool = ConfigValue,
maintain_aspect: bool = ConfigValue,
axes_visible: bool = ConfigValue,
sidecar: bool = False,
sidecar_kwargs: dict = None,
):
Expand All @@ -585,8 +595,8 @@ def show(
autoscale: bool, default ``True``
autoscale the Scene

maintain_aspect: bool, default ``True``
maintain aspect ratio
maintain_aspect: bool, default ``None``
maintain aspect ratio, if ``None`` uses the existing value from the camera

axes_visible: bool, default ``True``
show axes
Expand Down
54 changes: 45 additions & 9 deletions fastplotlib/layouts/_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from ..utils.types import SelectorColorStates
from ..graphics import TextGraphic


"""
Each Subplot is framed by a 2D plane mesh, a rectangle.
The rectangles are viewed using the UnderlayCamera where (0, 0) is the top left corner.
Expand Down Expand Up @@ -118,6 +117,9 @@ def __init__(
imgui_windows,
toolbar_visible,
canvas_rect,
spacing: dict = None,
title_kwargs: dict = None,
color: str = None,
):
"""
Manages the plane mesh, resize handle point, and subplot title.
Expand Down Expand Up @@ -154,13 +156,39 @@ def __init__(
canvas_rect: tuple
figure canvas rect, the render area excluding any areas taken by imgui edge windows

spacing: dict, optional
{

"""

self.viewport = viewport
self.docks = docks
self._imgui_windows = imgui_windows
self._toolbar_visible = toolbar_visible

_spacing = {
"x0": 1,
"sides": 2,
"title_flanks": 8,
"resize_handle_space": 13,
"bottom": 8,
}
if spacing is not None:
_spacing = {**_spacing, **spacing}

self._spacing = _spacing

_title_kwargs = {"font_size": 16, "face_color": "w"}
if title_kwargs is not None:
_title_kwargs = {**_title_kwargs, **title_kwargs}

if color is not None:
self.plane_color = SelectorColorStates(
idle=color,
highlight=self.plane_color.highlight,
action=self.plane_color.action,
)

# create rect manager to handle all the backend rect calculations
if rect is not None:
self._rect_manager = RectManager(*rect, canvas_rect)
Expand All @@ -176,7 +204,7 @@ def __init__(
title_text = ""
else:
title_text = title
self._title_graphic = TextGraphic(title_text, font_size=16, face_color="white")
self._title_graphic = TextGraphic(title_text, **_title_kwargs)
m = self._title_graphic.world_object.material
m.alpha_mode = "blend"
m.render_queue = RenderQueue.background
Expand Down Expand Up @@ -231,6 +259,10 @@ def __init__(
self._reset()
self.reset_viewport()

@property
def spacing(self) -> dict:
return self._spacing

@property
def rect_manager(self) -> RectManager:
return self._rect_manager
Expand Down Expand Up @@ -342,7 +374,10 @@ def _set_toolbar_rect(self):

x, y, w, h = self.rect
window._fpl_set_rect(
round(x + 1), round(y + h - IMGUI_TOOLBAR_HEIGHT), round(w - 2), IMGUI_TOOLBAR_HEIGHT
round(x + 1),
round(y + h - IMGUI_TOOLBAR_HEIGHT),
round(w - 2),
IMGUI_TOOLBAR_HEIGHT,
)

def get_render_rect(self) -> tuple[float, float, float, float]:
Expand All @@ -354,11 +389,13 @@ def get_render_rect(self) -> tuple[float, float, float, float]:
# the rect of the entire Frame
x, y, w, h = self.rect

x += 1 # add 1 so a 1 pixel edge is visible
w -= 2 # subtract 2, so we get a 1 pixel edge on both sides
x += self._spacing["x0"] # add 1 so a 1 pixel edge is visible
w -= self._spacing[
"sides"
] # subtract 2, so we get a 1 pixel edge on both sides

# add 4 pixels above and below title for better spacing
y = y + 4 + self._title_graphic.font_size + 4
y = y + self._title_graphic.font_size + self._spacing["title_flanks"]

# spacing on the bottom if imgui toolbar is visible
if self.toolbar_visible:
Expand All @@ -367,16 +404,15 @@ def get_render_rect(self) -> tuple[float, float, float, float]:
else:
toolbar_space = 0
# need some space for resize handler if imgui toolbar isn't present
resize_handle_space = 13
resize_handle_space = self._spacing["resize_handle_space"]

# adjust for the 4 pixels from the line above
# also give space for resize handler if imgui toolbar is not present
h = (
h
- 4
- self._title_graphic.font_size
- toolbar_space
- 4
- self._spacing["bottom"]
- resize_handle_space
)

Expand Down
Loading