TImageList / TGlyph の使い方
- 1. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 1
Happy Creation, Play the Development!
スタイルが絶対に必要だと言ったな。
あれは嘘だ
TImageList / TGlyph の使い方
2016/06/13
株式会社シリアルゲームズ
細川 淳
- 2. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 2
Happy Creation, Play the Development!
西都原考古博物館アプリ
• とにかく時間が無かった
• ほとんど宮崎で実装した…!
• 小さな机で実装…!
• スタイル作るの大変だよおお!
⇒スタイル作るのヤーメタ!
- 3. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 3
Happy Creation, Play the Development!
TImageList
• TImageList は画像をまとめて扱うクラス
• VCL版と違ってサイズは自由
- 4. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 4
Happy Creation, Play the Development!
TGlyph
• TImageList の画像を表示するだけのコント
ロール
これ
ImageList
ImageIndex
を指定
- 5. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 5
Happy Creation, Play the Development!
例:イメージボタン
- 6. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 6
Happy Creation, Play the Development!
イメージボタン
• TImageList / TGlyph を使ってボタンを作る
• OnMouseDown / OnMouseUp を使う
• しかし! TGlyph は操作を受け付けない!
– 画像を表示するだけ。HitTest プロパティは無い
⇒TLayout を使う
- 7. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 7
Happy Creation, Play the Development!
• TLayout の OnMouseUp/Down を使う
TLayout
TGlyph
TImageList
ImageIndex
OnMouseUp
OnMouseMove
OnMouseDown
Down/Up でImageIndexを変える
- 8. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 8
Happy Creation, Play the Development!
procedure TGlyphButton.LayoutMouseDown(
Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Single);
begin
// FIndex は通常時の ImageIndex
FGlyph.ImageIndex := FIndex + 1;
end;
- 9. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 9
Happy Creation, Play the Development!
procedure TGlyphButton.LayoutMouseUp(
Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Single);
begin
if (FIndex <> FGlyph.ImageIndex) then
begin
FGlyph.ImageIndex := FIndex; // 戻す
if (Assigned(FOnClick)) then
FOnClick(Self);
end;
end;
- 10. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 10
Happy Creation, Play the Development!
procedure TGlyphButton.LayoutMouseMove(
Sender: TObject;
Shift: TShiftState;
X, Y: Single);
begin
if not (ssLeft in Shift) then
Exit;
// マウスカーソルが範囲内ならダウン画像にする
if TLayout(Sender).PointInObjectLocal(X, Y) then
FGlyph.ImageIndex := FIndex + 1
else
FGlyph.ImageIndex := FIndex
end;
- 11. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 11
Happy Creation, Play the Development!
TImageList / TGlyph
TLayout / TFrame
• これらのコントロールを使うとスタイルを使わ
なくても何とかなる場合も多い!
– TFrame を使えば複雑に組み合わさったコントロー
ルを別のコントロールに載せることも可能…!
- 12. Copyright © 2013 SERIALGAMES inc. All Rights Reserved. PAGE 12
Happy Creation, Play the Development!
まとめ
• 基本は Style
• 時間が無かったりしたら TImageList もアリ