DEADSOFTWARE

FlexUI: don't change window size in "fit to screen" mode if size was already set
[d2df-sdl.git] / src / gx / gh_ui_common.pas
index 7143501e947dc2e78f7e8463a6aa380c59e92e93..de719d9d0a16267a2bf642cad70ac1f3eb9d45d9 100644 (file)
@@ -1,4 +1,5 @@
-(* Copyright (C)  DooM 2D:Forever Developers
+(* coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
+ * Understanding is not required. Only obedience.
  *
  * 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
@@ -11,7 +12,7 @@
  * 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/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  *)
 {$INCLUDE ../shared/a_modes.inc}
 unit gh_ui_common;
@@ -58,6 +59,19 @@ type
     property item[idx: Integer]: Integer read getIdx write setIdx; default;
   end;
 
+  TLayMargins = record
+  public
+    top, right, bottom, left: Integer;
+
+  public
+    constructor Create (atop, aright, abottom, aleft: Integer);
+
+    function toString (): AnsiString;
+
+    function horiz (): Integer; inline;
+    function vert (): Integer; inline;
+  end;
+
 
 implementation
 
@@ -78,5 +92,20 @@ procedure TLayPos.setIdx (idx, v: Integer); inline; begin if (idx = 0) then x :=
 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;
 
+constructor TLayMargins.Create (atop, aright, abottom, aleft: Integer);
+begin
+  if (atop < 0) then atop := 0;
+  if (aright < 0) then aright := 0;
+  if (abottom < 0) then abottom := 0;
+  if (aleft < 0) then aleft := 0;
+  left := aleft;
+  right := aright;
+  top := atop;
+  bottom := abottom;
+end;
+function TLayMargins.toString (): AnsiString; begin result := formatstrf('(%s,%s,%s,%s)', [top, right, bottom, left]); end;
+function TLayMargins.horiz (): Integer; inline; begin result := left+right; end;
+function TLayMargins.vert (): Integer; inline; begin result := top+bottom; end;
+
 
 end.