From 95d3dc3288c408f44d89aeb2f5fe055f204f52c7 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 11 Jun 2024 17:12:18 -0400 Subject: [PATCH] Add placeholder methods for recommended sizes --- layouts/contract.go | 11 +++++++++++ layouts/flow.go | 10 ++++++++++ layouts/grid.go | 12 +++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/layouts/contract.go b/layouts/contract.go index 8550882..24d612e 100644 --- a/layouts/contract.go +++ b/layouts/contract.go @@ -42,6 +42,7 @@ func (contract Contract) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) } func (contract Contract) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) { + // TODO if we overflow in a direction, respect the reccomended size if contract.v() { dot := hints.Bounds.Min for index, box := range boxes { @@ -93,5 +94,15 @@ func (contract Contract) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) { } } +func (contract Contract) RecommendedHeight (hints tomo.LayoutHints, boxes []tomo.Box, width int) int { + // TODO + return 0 +} + +func (contract Contract) RecommendedWidth (hints tomo.LayoutHints, boxes []tomo.Box, height int) int { + // TODO + return 0 +} + func (contract Contract) v () bool { return contract == ContractVertical } func (contract Contract) h () bool { return contract == ContractHorizontal } diff --git a/layouts/flow.go b/layouts/flow.go index e6acd27..c4c8d33 100644 --- a/layouts/flow.go +++ b/layouts/flow.go @@ -123,3 +123,13 @@ func (flow Flow) deltaMinor (rectangle image.Rectangle) int { func (flow Flow) fallback () tomo.Layout { return Contract(flow) } + +func (flow Flow) RecommendedHeight (hints tomo.LayoutHints, boxes []tomo.Box, width int) int { + // TODO + return 0 +} + +func (flow Flow) RecommendedWidth (hints tomo.LayoutHints, boxes []tomo.Box, height int) int { + // TODO + return 0 +} diff --git a/layouts/grid.go b/layouts/grid.go index 80f7ee9..4943a72 100644 --- a/layouts/grid.go +++ b/layouts/grid.go @@ -4,7 +4,7 @@ import "math" import "image" import "git.tebibyte.media/tomo/tomo" -var _ tomo.Layout = Grid { } +var _ tomo.Layout = new(Grid) // Grid is a layout that arranges boxes in a grid formation with distinct rows // and columns. It is great for creating forms. @@ -108,3 +108,13 @@ func expand (hints tomo.LayoutHints, sizes []int, space int, expands func (int) func ceilDiv (x, y int) int { return int(math.Ceil(float64(x) / float64(y))) } + +func (this *Grid) RecommendedHeight (hints tomo.LayoutHints, boxes []tomo.Box, width int) int { + // TODO + return 0 +} + +func (this *Grid) RecommendedWidth (hints tomo.LayoutHints, boxes []tomo.Box, height int) int { + // TODO + return 0 +}