Line data Source code
1 : package menuframe
2 :
3 : import (
4 : "image"
5 :
6 : "github.com/kijimaD/ruins/internal/resources"
7 : "github.com/kijimaD/ruins/internal/widgets/styled"
8 : "github.com/kijimaD/ruins/internal/widgets/theme"
9 : "github.com/kijimaD/ruins/internal/widgets/uicore"
10 : w "github.com/kijimaD/ruins/internal/world"
11 : )
12 :
13 : // 見出しと左右2枠を持つ全画面の寸法。画面はこれらを知らない
14 : const (
15 : splitTitleTop = 24 // 見出しの上端
16 : splitTitleH = 36 // 見出し行の高さ
17 : splitBodyTop = 80 // 左右の枠の上端
18 : splitSideMargin = 40 // 画面左右の余白
19 : splitLeftW = 180 // 左枠の幅
20 : splitGutter = 20 // 左枠と右枠の間隔
21 : splitFooterH = 72 // 下に空ける高さ。説明とヒントの2行ぶん
22 : splitLineGap = 8 // 下部の行と行の間隔
23 : splitBottomMargin = 16 // 画面下端の余白
24 : )
25 :
26 : // SplitScreen は見出し・左の一覧・右の詳細枠・下の説明とヒントを持つ全画面を組む。
27 : // 左右の枠は上端をそろえ、下は説明の手前で止まる。寸法と余白は部品が持ち、
28 : // 画面は中身の widget と文言だけを渡す。
29 : func SplitScreen(world w.World, res resources.UIResources, title string, left, right uicore.Widget, description, hint string) uicore.Widget {
30 1 : sd := world.Resources.ScreenDimensions
31 1 :
32 1 : titleText := newCenteredText(title, res.Text.TitleFontFace, theme.TextPrimary)
33 1 : titleText.Layout(image.Rect(0, splitTitleTop, sd.Width, splitTitleTop+splitTitleH))
34 1 :
35 1 : bodyBottom := sd.Height - splitFooterH
36 1 : leftX := splitSideMargin
37 1 : left.Layout(image.Rect(leftX, splitBodyTop, leftX+splitLeftW, bodyBottom))
38 1 : right.Layout(image.Rect(leftX+splitLeftW+splitGutter, splitBodyTop, sd.Width-splitSideMargin, bodyBottom))
39 1 :
40 : // 説明とヒントは下端から積み上げる
41 1 : descTop := sd.Height - noteRowH*2 - splitLineGap - splitBottomMargin
42 1 : descText := newCenteredText(description, res.Text.SmallFace, theme.TextAccent)
43 1 : descText.Layout(image.Rect(0, descTop, sd.Width, descTop+noteRowH))
44 1 : hintTop := descTop + noteRowH + splitLineGap
45 1 : hintText := newCenteredText(hint, res.Text.SmallFace, theme.TextAccent)
46 1 : hintText.Layout(image.Rect(0, hintTop, sd.Width, hintTop+noteRowH))
47 1 :
48 1 : root := uicore.NewGroup(titleText, left, right, descText, hintText)
49 1 : root.Layout(image.Rect(0, 0, sd.Width, sd.Height))
50 1 : return root
51 1 : }
52 :
53 : // SplitList は SplitScreen の左枠に載せる一覧を組む。単一ページの一覧で、ページ表示は持たない。
54 : func SplitList(itemIndex int, rows []Row, res resources.UIResources) uicore.Widget {
55 1 : listRows, _ := RenderList(itemIndex, rows, styled.Cols(styled.Name()), ListOpts{}, res)
56 1 : return uicore.VBox(theme.MenuPanelRowH, uicore.Placeable(listRows)...)
57 1 : }
|