diff --git a/backends/x/window.go b/backends/x/window.go index 8150076..f3981cb 100644 --- a/backends/x/window.go +++ b/backends/x/window.go @@ -96,9 +96,6 @@ func (window *Window) Adopt (child elements.Element) { window.child.OnDamage(nil) window.child.OnMinimumSizeChange(nil) } - if previousChild, ok := window.child.(elements.Flexible); ok { - previousChild.OnFlexibleHeightChange(nil) - } if previousChild, ok := window.child.(elements.Focusable); ok { previousChild.OnFocusRequest(nil) previousChild.OnFocusMotionRequest(nil) @@ -115,9 +112,6 @@ func (window *Window) Adopt (child elements.Element) { if newChild, ok := child.(elements.Configurable); ok { newChild.SetConfig(window.config) } - if newChild, ok := child.(elements.Flexible); ok { - newChild.OnFlexibleHeightChange(window.resizeChildToFit) - } if newChild, ok := child.(elements.Focusable); ok { newChild.OnFocusRequest(window.childSelectionRequestCallback) } @@ -263,26 +257,7 @@ func (window *Window) redrawChildEntirely () { func (window *Window) resizeChildToFit () { window.skipChildDrawCallback = true - if child, ok := window.child.(elements.Flexible); ok { - minimumHeight := child.FlexibleHeightFor(window.metrics.width) - minimumWidth, _ := child.MinimumSize() - - icccm.WmNormalHintsSet ( - window.backend.connection, - window.xWindow.Id, - &icccm.NormalHints { - Flags: icccm.SizeHintPMinSize, - MinWidth: uint(minimumWidth), - MinHeight: uint(minimumHeight), - }) - - if window.metrics.height >= minimumHeight && - window.metrics.width >= minimumWidth { - window.child.DrawTo(window.canvas) - } - } else { - window.child.DrawTo(window.canvas) - } + window.child.DrawTo(window.canvas) window.skipChildDrawCallback = false } diff --git a/elements/core/propagator.go b/elements/core/propagator.go index 291d406..2375f5b 100644 --- a/elements/core/propagator.go +++ b/elements/core/propagator.go @@ -326,16 +326,6 @@ func (propagator *Propagator) forFocusable (callback func (child elements.Focusa }) } -func (propagator *Propagator) forFlexible (callback func (child elements.Flexible) bool) { - propagator.forChildren (func (child elements.Element) bool { - typedChild, flexible := child.(elements.Flexible) - if flexible { - if !callback(typedChild) { return false } - } - return true - }) -} - func (propagator *Propagator) firstFocused () int { for index := 0; index < propagator.parent.CountChildren(); index ++ { child, focusable := propagator.parent.Child(index).(elements.Focusable) diff --git a/layouts/basic/dialog.go b/layouts/basic/dialog.go index ed3b45e..b73c987 100644 --- a/layouts/basic/dialog.go +++ b/layouts/basic/dialog.go @@ -3,7 +3,6 @@ package basicLayouts import "image" import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/layouts" -import "git.tebibyte.media/sashakoshka/tomo/elements" // Dialog arranges elements in the form of a dialog box. The first element is // positioned above as the main focus of the dialog, and is set to expand @@ -132,45 +131,6 @@ func (layout Dialog) MinimumSize ( return } -// FlexibleHeightFor Returns the minimum height the layout needs to lay out the -// specified elements at the given width, taking into account flexible elements. -func (layout Dialog) FlexibleHeightFor ( - entries []layouts.LayoutEntry, - margin image.Point, - padding artist.Inset, - width int, -) ( - height int, -) { - if layout.Pad { - width -= padding.Horizontal() - } - - if len(entries) > 0 { - mainChildHeight := 0 - if child, flexible := entries[0].Element.(elements.Flexible); flexible { - mainChildHeight = child.FlexibleHeightFor(width) - } else { - _, mainChildHeight = entries[0].MinimumSize() - } - height += mainChildHeight - } - - if len(entries) > 1 { - if layout.Gap { height += margin.Y } - _, additionalHeight := layout.minimumSizeOfControlRow ( - entries[1:], margin, padding) - height += additionalHeight - } - - if layout.Pad { - height += padding.Vertical() - } - return -} - -// TODO: possibly flatten this method to account for flexible elements within -// the control row. func (layout Dialog) minimumSizeOfControlRow ( entries []layouts.LayoutEntry, margin image.Point, diff --git a/layouts/basic/horizontal.go b/layouts/basic/horizontal.go index e27c3fe..0819241 100644 --- a/layouts/basic/horizontal.go +++ b/layouts/basic/horizontal.go @@ -3,7 +3,6 @@ package basicLayouts import "image" import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/layouts" -import "git.tebibyte.media/sashakoshka/tomo/elements" // Horizontal arranges elements horizontally. Elements at the start of the entry // list will be positioned on the left, and elements at the end of the entry @@ -76,49 +75,6 @@ func (layout Horizontal) MinimumSize ( return } -// FlexibleHeightFor Returns the minimum height the layout needs to lay out the -// specified elements at the given width, taking into account flexible elements. -func (layout Horizontal) FlexibleHeightFor ( - entries []layouts.LayoutEntry, - margin image.Point, - padding artist.Inset, - width int, -) ( - height int, -) { - if layout.Pad { width -= padding.Horizontal() } - - // get width of expanding elements - expandingElementWidth := layout.expandingElementWidth ( - entries, margin, padding, width) - - x, y := 0, 0 - if layout.Pad { - x += padding.Horizontal() - y += padding.Vertical() - } - - // set the size and position of each element - for index, entry := range entries { - entryWidth, entryHeight := entry.MinimumSize() - if entry.Expand { - entryWidth = expandingElementWidth - } - if child, flexible := entry.Element.(elements.Flexible); flexible { - entryHeight = child.FlexibleHeightFor(entryWidth) - } - if entryHeight > height { height = entryHeight } - - x += entryWidth - if index > 0 && layout.Gap { x += margin.X } - } - - if layout.Pad { - height += padding.Vertical() - } - return -} - func (layout Horizontal) expandingElementWidth ( entries []layouts.LayoutEntry, margin image.Point, diff --git a/layouts/basic/vertical.go b/layouts/basic/vertical.go index a66c648..bbcfb9a 100644 --- a/layouts/basic/vertical.go +++ b/layouts/basic/vertical.go @@ -3,7 +3,6 @@ package basicLayouts import "image" import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/layouts" -import "git.tebibyte.media/sashakoshka/tomo/elements" // Vertical arranges elements vertically. Elements at the start of the entry // list will be positioned at the top, and elements at the end of the entry list @@ -32,13 +31,7 @@ func (layout Vertical) Arrange ( minimumHeights := make([]int, len(entries)) expandingElements := 0 for index, entry := range entries { - var entryMinHeight int - - if child, flexible := entry.Element.(elements.Flexible); flexible { - entryMinHeight = child.FlexibleHeightFor(bounds.Dx()) - } else { - _, entryMinHeight = entry.MinimumSize() - } + _, entryMinHeight := entry.MinimumSize() minimumHeights[index] = entryMinHeight if entry.Expand { @@ -101,34 +94,3 @@ func (layout Vertical) MinimumSize ( } return } - -// FlexibleHeightFor Returns the minimum height the layout needs to lay out the -// specified elements at the given width, taking into account flexible elements. -func (layout Vertical) FlexibleHeightFor ( - entries []layouts.LayoutEntry, - margin image.Point, - padding artist.Inset, - width int, -) ( - height int, -) { - if layout.Pad { - width -= padding.Horizontal() - height += padding.Vertical() - } - - for index, entry := range entries { - child, flexible := entry.Element.(elements.Flexible) - if flexible { - height += child.FlexibleHeightFor(width) - } else { - _, entryHeight := entry.MinimumSize() - height += entryHeight - } - - if layout.Gap && index > 0 { - height += margin.Y - } - } - return -} diff --git a/layouts/layout.go b/layouts/layout.go index 786a2b3..d538e5f 100644 --- a/layouts/layout.go +++ b/layouts/layout.go @@ -12,10 +12,6 @@ type LayoutEntry struct { Expand bool } -// TODO: have layouts take in artist.Inset for margin and padding -// TODO: create a layout that only displays the first element and full screen. -// basically a blank layout for containers that only ever have one element. - // Layout is capable of arranging elements within a container. It is also able // to determine the minimum amount of room it needs to do so. type Layout interface { @@ -39,16 +35,4 @@ type Layout interface { ) ( width, height int, ) - - // FlexibleHeightFor Returns the minimum height the layout needs to lay - // out the specified elements at the given width, taking into account - // flexible elements. - FlexibleHeightFor ( - entries []LayoutEntry, - margin image.Point, - padding artist.Inset, - squeeze int, - ) ( - height int, - ) } diff --git a/theme/assets/wintergreen.png b/theme/assets/wintergreen.png index 154a6d8..a0cde5e 100644 Binary files a/theme/assets/wintergreen.png and b/theme/assets/wintergreen.png differ