Package eui
Package eui はEbitenUIコンポーネントに対するスタイル付きのゲーム固有ラッパー関数を提供する。
Overview
euiパッケージは、EbitenUIライブラリの基本コンポーネントに対して
プロジェクト固有のスタイルとデザインを適用したヘルパー関数群を提供します。
エンティティと関わらない、UI表示に特化した基本的なパーツを提供します。
Package Hierarchy
このプロジェクトのUIアーキテクチャは3層構造になっています:
widgets/ ← 業務ロジック付きの高レベルコンポーネント
↓ 使用
eui/ ← プロジェクト固有スタイルの中レベルコンポーネント(このパッケージ)
↓ 使用
ebitenui/ ← 外部ライブラリの低レベルコンポーネント
Responsibilities
euiパッケージの責務:
- EbitenUIコンポーネントのプロジェクト固有スタイル適用
- ゲームリソース(フォント、色、画像)との統合
- 基本的なレイアウトコンテナの提供
- 静的なUI要素のファクトリ関数群
- 一貫したデザインシステムの維持
Usage vs Other Packages
## euiパッケージを使う場合
- 基本的なレイアウトコンテナが欲しい(NewRowContainer, NewVerticalContainer)
- プロジェクト統一スタイルのボタンやテキストが欲しい(NewButton, NewMenuText)
- 静的な表示のみで状態管理は不要
- ゲームリソース(World)を使った表示をしたい
- 簡単なヘルパー関数で十分
## widgetsパッケージを使う場合
- メニュー、ダイアログ、フォームなど複雑な操作が必要
- キーボードナビゲーションが必要
- 状態管理が必要(選択状態、入力データなど)
- ビジネスロジックとの連携が必要
- 単体テストを書きたい
Example
euiパッケージの典型的な使用例:
// 基本的なレイアウト構築
container := eui.NewVerticalContainer()
// プロジェクトスタイルのボタン作成
button := eui.NewButton("クリック", world)
container.AddChild(button)
// ゲーム固有スタイルのテキスト
title := eui.NewMenuText("タイトル", world)
container.AddChild(title)
// 分割レイアウト
leftPanel := eui.NewVerticalContainer()
rightPanel := eui.NewVerticalContainer()
splitContainer := eui.NewWSplitContainer(leftPanel, rightPanel)
Design Principles
- Styling Consistency: プロジェクト全体で一貫したデザイン
- Resource Integration: ゲームリソースとの統合
- Simplicity: シンプルなファクトリ関数
- Stateless: 状態を持たない純粋な関数群
- EbitenUI Compatibility: EbitenUIとの高い互換性
- func BaseRowLayoutOpts() []widget.RowLayoutOpt
- func LoadButtonImage() *widget.ButtonImage
- func LoadFont(world w.World) *text.Face
- func NewBodyText(title string, _ color.RGBA, world w.World) *widget.Text
- func NewButton(text string, world w.World, opts ...widget.ButtonOpt) *widget.Button
- func NewDescriptionText(text string, world w.World) *widget.Text
- func NewItemGridContainer(opts ...widget.ContainerOpt) *widget.Container
- func NewListItemText(text string, textColor color.RGBA, isSelected bool, world w.World) *widget.Container
- func NewMenuText(title string, world w.World) *widget.Text
- func NewMessageList(entries []any, world w.World, opts ...widget.ListOpt) *widget.List
- func NewRowContainer(opts ...widget.ContainerOpt) *widget.Container
- func NewSmallWindow(title *widget.Container, content *widget.Container) *widget.Window
- func NewSubtitleText(text string, world w.World) *widget.Text
- func NewTitleText(text string, world w.World) *widget.Text
- func NewVSplitContainer(top *widget.Container, bottom *widget.Container, opts ...widget.ContainerOpt) *widget.Container
- func NewVerticalContainer(opts ...widget.ContainerOpt) *widget.Container
- func NewWSplitContainer(right *widget.Container, left *widget.Container, opts ...widget.ContainerOpt) *widget.Container
- func NewWindowContainer(world w.World) *widget.Container
- func NewWindowHeaderContainer(title string, world w.World) *widget.Container
Package files
doc.go
eui.go
load.go
func BaseRowLayoutOpts() []widget.RowLayoutOpt
BaseRowLayoutOpts は基本的な行レイアウトオプションを返す
func LoadButtonImage() *widget.ButtonImage
LoadButtonImage はボタンイメージを読み込む
TODO: いい感じにしたい
func LoadFont(world w.World) *text.Face
LoadFont はフォントを読み込む
TODO: いい感じにしたい
func NewBodyText(title string, _ color.RGBA, world w.World) *widget.Text
NewBodyText は本文用テキストを作成する
func NewButton(text string, world w.World, opts ...widget.ButtonOpt) *widget.Button
NewButton はボタンウィジェットを作成する
func NewDescriptionText(text string, world w.World) *widget.Text
NewDescriptionText は説明文用テキストを作成する(小さめ、補助的)
func NewItemGridContainer(opts ...widget.ContainerOpt) *widget.Container
NewItemGridContainer はアイテム系メニューのRootとなる3x3のグリッドコンテナを作成する
func NewListItemText(text string, textColor color.RGBA, isSelected bool, world w.World) *widget.Container
NewListItemText はリスト項目用テキストを作成する(背景色変更で選択状態を表現)
func NewMenuText(title string, world w.World) *widget.Text
NewMenuText は汎用メニューテキストを作成する(既存との互換性のため維持)
func NewMessageList(entries []any, world w.World, opts ...widget.ListOpt) *widget.List
NewMessageList はメッセージ表示用のリストウィジェットを作成する(戦闘ログなど用)
func NewRowContainer(opts ...widget.ContainerOpt) *widget.Container
NewRowContainer は汎用的なrowコンテナを作成する
func NewSmallWindow(title *widget.Container, content *widget.Container) *widget.Window
NewSmallWindow は小さなウィンドウを作成する
func NewSubtitleText(text string, world w.World) *widget.Text
NewSubtitleText はサブタイトル用テキストを作成する(中サイズ)
func NewTitleText(text string, world w.World) *widget.Text
NewTitleText はタイトル用テキストを作成する(大きめ、目立つ)
func NewVSplitContainer(top *widget.Container, bottom *widget.Container, opts ...widget.ContainerOpt) *widget.Container
NewVSplitContainer は縦分割コンテナを作成する
func NewVerticalContainer(opts ...widget.ContainerOpt) *widget.Container
NewVerticalContainer は中身が縦並びのコンテナを作成する
func NewWSplitContainer(right *widget.Container, left *widget.Container, opts ...widget.ContainerOpt) *widget.Container
NewWSplitContainer は横分割コンテナを作成する
func NewWindowContainer(world w.World) *widget.Container
NewWindowContainer はウィンドウの本体を作成する
func NewWindowHeaderContainer(title string, world w.World) *widget.Container
NewWindowHeaderContainer はウィンドウのヘッダーを作成する