// Draw implements gruid.Model.Draw. It returns the grid slice that was drawn.
Draw implements gruid.Model.Draw. It returns the grid slice that was drawn.
// Draw implements gruid . Model . Draw . It returns the grid slice that was drawn .
func (m *Menu) Draw() gruid.Grid {
	if !m.dirty {
		return m.drawn
	}
	grid := m.pageGrid()
	if m.box != nil {
		pg := m.table[m.active].page
		var lnumtext string
		if m.pages.X == 0 && m.pages.Y == 0 {
		} else if m.pages.X == 0 {
			lnumtext = fmt.Sprintf("%d/%d", pg.Y, m.pages.Y)
		} else if m.pages.Y == 0 {
			lnumtext = fmt.Sprintf("%d/%d", pg.X, m.pages.X)
		} else {
			lnumtext = fmt.Sprintf("%d,%d/%d,%d", pg.X, pg.Y, m.pages.X, m.pages.Y)
		}
		foot := m.box.Footer
		if foot.Text() == "" {
			m.box.Footer = NewStyledText(lnumtext, m.style.PageNum)
		}
		m.box.Draw(grid)
		m.box.Footer = foot
	}
	activeItem := m.table[m.active]
	for p, it := range m.table {
		if it.page != activeItem.page {
			continue
		}
		i := it.i
		c := m.entries[i]
		st := c.Text.Style()
		if !c.Disabled {
			if p == m.active {
				if m.style.Active.Fg != gruid.ColorDefault {
					st.Fg = m.style.Active.Fg
				}
				if m.style.Active.Bg != gruid.ColorDefault {
					st.Bg = m.style.Active.Bg
				}
				if m.style.Active.Attrs != gruid.AttrsDefault {
					st.Attrs = m.style.Active.Attrs
				}
			}
			cell := gruid.Cell{Rune: ' ', Style: st}
			it.grid.Fill(cell)
			c.Text.WithStyle(st).Draw(it.grid)
		} else {
			cell := gruid.Cell{Rune: ' ', Style: st}
			it.grid.Fill(cell)
			c.Text.Draw(it.grid)
		}
	}
	m.dirty = false
	m.drawn = grid
	return m.drawn
}
func ( m * Menu ) Draw ( ) gruid . Grid { if ! m . dirty { return m . drawn } grid := m . pageGrid ( ) if m . box != nil { pg := m . table [ m . active ] . page var lnumtext string if m . pages . X == 0 && m . pages . Y == 0 { } else if m . pages . X == 0 { lnumtext = fmt . Sprintf ( " " , pg . Y , m . pages . Y ) } else if m . pages . Y == 0 { lnumtext = fmt . Sprintf ( " " , pg . X , m . pages . X ) } else { lnumtext = fmt . Sprintf ( " " , pg . X , pg . Y , m . pages . X , m . pages . Y ) } foot := m . box . Footer if foot . Text ( ) == " " { m . box . Footer = NewStyledText ( lnumtext , m . style . PageNum ) } m . box . Draw ( grid ) m . box . Footer = foot } activeItem := m . table [ m . active ] for p , it := range m . table { if it . page != activeItem . page { continue } i := it . i c := m . entries [ i ] st := c . Text . Style ( ) if ! c . Disabled { if p == m . active { if m . style . Active . Fg != gruid . ColorDefault { st . Fg = m . style . Active . Fg } if m . style . Active . Bg != gruid . ColorDefault { st . Bg = m . style . Active . Bg } if m . style . Active . Attrs != gruid . AttrsDefault { st . Attrs = m . style . Active . Attrs } } cell := gruid . Cell { Rune : ' ' , Style : st } it . grid . Fill ( cell ) c . Text . WithStyle ( st ) . Draw ( it . grid ) } else { cell := gruid . Cell { Rune : ' ' , Style : st } it . grid . Fill ( cell ) c . Text . Draw ( it . grid ) } } m . dirty = false m . drawn = grid return m . drawn }
Draw implements gruid.Model.Draw.
Draw implements gruid . Model . Draw .