summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 73dcd47)
raw | patch | inline | side by side (parent: 73dcd47)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 22 Sep 2017 22:06:13 +0000 (01:06 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 22 Sep 2017 22:06:45 +0000 (01:06 +0300) |
src/game/Doom2DF.dpr | patch | blob | history | |
src/gx/gh_ui.pas | patch | blob | history | |
src/gx/gh_ui_common.pas | [new file with mode: 0644] | patch | blob |
diff --git a/src/game/Doom2DF.dpr b/src/game/Doom2DF.dpr
index 67dcc034b11edef519f01fba9dafce860e53b3e0..7daaaea83727b95ee5252ab62194eaee6e8ce732 100644 (file)
--- a/src/game/Doom2DF.dpr
+++ b/src/game/Doom2DF.dpr
ImagingUtility,
sdlcarcass in '../gx/sdlcarcass.pas',
glgfx in '../gx/glgfx.pas',
+ gh_ui_common in '../gx/gh_ui_common.pas',
gh_ui in '../gx/gh_ui.pas';
{$IFDEF WINDOWS}
diff --git a/src/gx/gh_ui.pas b/src/gx/gh_ui.pas
index aa94e62f463e57e405215ee6d7d938e506a4b725..f67757acd82a2ddebb790b1b73378c22bd8ca75a 100644 (file)
--- a/src/gx/gh_ui.pas
+++ b/src/gx/gh_ui.pas
uses
SysUtils, Classes,
GL, GLExt, SDL2,
+ gh_ui_common,
sdlcarcass, glgfx;
public
actionCB: TActionCB;
+ private
+ mSize: TLaySize; // default size
+ mMaxSize: TLaySize; // maximum size
+ mActSize: TLaySize; // actual (calculated) size
+ mActPos: TLayPos; // actual (calculated) position
+ mFlex: Integer;
+ mHoriz: Boolean;
+ mCanWrap: Boolean;
+ mLineStart: Boolean;
+ mHGroup: AnsiString;
+ mVGroup: AnsiString;
+
+ public
+ // layouter interface
+ function getSize (): TLaySize; inline; // default size; <0: use max size
+ procedure setSize (constref sz: TLaySize); inline; // default size; <0: use max size
+ function getMaxSize (): TLaySize; inline; // max size; <0: set to some huge value
+ procedure setMaxSize (constref sz: TLaySize); inline; // max size; <0: set to some huge value
+ function getFlex (): Integer; inline; // <=0: not flexible
+ function isHorizBox (): Boolean; inline; // horizontal layout for children?
+ procedure setHorizBox (v: Boolean); inline; // horizontal layout for children?
+ function canWrap (): Boolean; inline; // for horizontal boxes: can wrap children? for child: `false` means 'nonbreakable at *next* ctl'
+ procedure setCanWrap (v: Boolean); inline; // for horizontal boxes: can wrap children? for child: `false` means 'nonbreakable at *next* ctl'
+ function isLineStart (): Boolean; inline; // `true` if this ctl should start a new line; ignored for vertical boxes
+ procedure setLineStart (v: Boolean); inline; // `true` if this ctl should start a new line; ignored for vertical boxes
+ procedure setActualSizePos (constref apos: TLayPos; constref asize: TLaySize); inline;
+ function getHGroup (): AnsiString; inline; // empty: not grouped
+ procedure setHGroup (const v: AnsiString); inline; // empty: not grouped
+ function getVGroup (): AnsiString; inline; // empty: not grouped
+ procedure setVGroup (const v: AnsiString); inline; // empty: not grouped
+ function hasSibling (): Boolean; inline;
+ //function nextSibling (): THControl; inline;
+ function hasChildren (): Boolean; inline;
+ //function firstChild (): THControl; inline;
+
+ property flex: Integer read mFlex write mFlex;
+
public
constructor Create (ax, ay, aw, ah: Integer; aparent: THControl=nil);
destructor Destroy (); override;
scallowed := false;
mDrawShadow := false;
actionCB := nil;
+ // layouter interface
+ mSize := TLaySize.Create(64, 10); // default size
+ mMaxSize := TLaySize.Create(-1, -1); // maximum size
+ mActSize := TLaySize.Create(0, 0); // actual (calculated) size
+ mActPos := TLayPos.Create(0, 0); // actual (calculated) position
+ mFlex := 0;
+ mHoriz := true;
+ mCanWrap := false;
+ mLineStart := false;
+ mHGroup := '';
+ mVGroup := '';
end;
end;
+function THControl.getSize (): TLaySize; inline; begin result := mSize; end;
+procedure THControl.setSize (constref sz: TLaySize); inline; begin mSize := sz; end;
+function THControl.getMaxSize (): TLaySize; inline; begin result := mMaxSize; end;
+procedure THControl.setMaxSize (constref sz: TLaySize); inline; begin mMaxSize := sz; end;
+function THControl.getFlex (): Integer; inline; begin result := mFlex; end;
+function THControl.isHorizBox (): Boolean; inline; begin result := mHoriz; end;
+procedure THControl.setHorizBox (v: Boolean); inline; begin mHoriz := v; end;
+function THControl.canWrap (): Boolean; inline; begin result := mCanWrap; end;
+procedure THControl.setCanWrap (v: Boolean); inline; begin mCanWrap := v; end;
+function THControl.isLineStart (): Boolean; inline; begin result := mLineStart; end;
+procedure THControl.setLineStart (v: Boolean); inline; begin mLineStart := v; end;
+procedure THControl.setActualSizePos (constref apos: TLayPos; constref asize: TLaySize); inline; begin mActPos := apos; mActSize := asize; end;
+function THControl.getHGroup (): AnsiString; inline; begin result := mHGroup; end;
+procedure THControl.setHGroup (const v: AnsiString); inline; begin mHGroup := v; end;
+function THControl.getVGroup (): AnsiString; inline; begin result := mVGroup; end;
+procedure THControl.setVGroup (const v: AnsiString); inline; begin mVGroup := v; end;
+function THControl.hasSibling (): Boolean; inline; begin result := (nextSibling <> nil) end;
+//function THControl.nextSibling (): THControl; inline; begin result := nextSibling; end;
+function THControl.hasChildren (): Boolean; inline; begin result := (firstChild <> nil); end;
+//function THControl.firstChild (): THControl; inline; begin result := firstChild; end;
+
+
procedure THControl.activated ();
begin
end;
diff --git a/src/gx/gh_ui_common.pas b/src/gx/gh_ui_common.pas
--- /dev/null
+++ b/src/gx/gh_ui_common.pas
@@ -0,0 +1,82 @@
+(* Copyright (C) DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE ../shared/a_modes.inc}
+unit gh_ui_common;
+
+interface
+
+
+// ////////////////////////////////////////////////////////////////////////// //
+type
+ TLaySize = record
+ public
+ w, h: Integer;
+
+ private
+ function getIdx (idx: Integer): Integer; inline;
+ procedure setIdx (idx, v: Integer); inline;
+
+ public
+ constructor Create (aw, ah: Integer);
+
+ function toString (): AnsiString;
+
+ function equals (constref a: TLaySize): Boolean; inline;
+ public
+ property item[idx: Integer]: Integer read getIdx write setIdx; default;
+ end;
+
+ TLayPos = record
+ public
+ x, y: Integer;
+
+ private
+ function getIdx (idx: Integer): Integer; inline;
+ procedure setIdx (idx, v: Integer); inline;
+
+ public
+ constructor Create (ax, ay: Integer);
+
+ function toString (): AnsiString;
+
+ function equals (constref a: TLayPos): Boolean; inline;
+
+ public
+ property item[idx: Integer]: Integer read getIdx write setIdx; default;
+ end;
+
+
+implementation
+
+uses
+ utils;
+
+
+// ////////////////////////////////////////////////////////////////////////// //
+constructor TLaySize.Create (aw, ah: Integer); begin w := aw; h := ah; end;
+function TLaySize.getIdx (idx: Integer): Integer; inline; begin if (idx = 0) then result := w else if (idx = 1) then result := h else result := -1; end;
+procedure TLaySize.setIdx (idx, v: Integer); inline; begin if (idx = 0) then w := v else if (idx = 1) then h := v; end;
+function TLaySize.toString (): AnsiString; begin result := formatstrf('[%d,%d]', [w, h]); end;
+function TLaySize.equals (constref a: TLaySize): Boolean; inline; begin result := (w = a.w) and (h = a.h); end;
+
+constructor TLayPos.Create (ax, ay: Integer); begin x := ax; y := ay; end;
+function TLayPos.getIdx (idx: Integer): Integer; inline; begin if (idx = 0) then result := x else if (idx = 1) then result := y else result := -1; end;
+procedure TLayPos.setIdx (idx, v: Integer); inline; begin if (idx = 0) then x := v else if (idx = 1) then y := v; end;
+function TLayPos.toString (): AnsiString; begin result := formatstrf('(%d,%d)', [x, y]); end;
+function TLayPos.equals (constref a: TLayPos): Boolean; inline; begin result := (x = a.x) and (y = a.y); end;
+
+
+end.