index 476d74909df582c9eecd5b07672e6a646b83bbd2..e543fc0e7023a9700a08ddf705f83f439aa8958c 100644 (file)
*
* 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
*
* 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.
+ * the Free Software Foundation, version 3 of the License ONLY.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
interface
uses
interface
uses
+ {$INCLUDE ../nogl/noGLuses.inc}
SysUtils, Classes,
SysUtils, Classes,
- GL, GLExt, SDL2,
+ SDL2,
sdlcarcass,
fui_common, fui_events;
sdlcarcass,
fui_common, fui_events;
function combineClip (constref aclip: TGxRect): TGxRect; // returns previous clip
function combineClip (constref aclip: TGxRect): TGxRect; // returns previous clip
+ // vertical scrollbar
+ procedure drawVSBar (x, y, wdt, hgt: Integer; cur, min, max: Integer; constref clrfull, clrempty: TGxRGBA);
+ // horizontal scrollbar
+ procedure drawHSBar (x, y, wdt, hgt: Integer; cur, min, max: Integer; constref clrfull, clrempty: TGxRGBA);
+
+ class function sbarFilled (wh: Integer; cur, min, max: Integer): Integer;
+ class function sbarPos (cxy: Integer; xy, wh: Integer; min, max: Integer): Integer;
+
public //HACK!
procedure glSetScale (ascale: Single);
procedure glSetTrans (ax, ay: Single);
public //HACK!
procedure glSetScale (ascale: Single);
procedure glSetTrans (ax, ay: Single);
function isScaled (): Boolean;
var
function isScaled (): Boolean;
var
- mt: packed array [0..15] of Double;
+ mt: packed array [0..15] of GLfloat;
begin
begin
- glGetDoublev(GL_MODELVIEW_MATRIX, @mt[0]);
+ glGetFloatv(GL_MODELVIEW_MATRIX, @mt[0]);
result := (mt[0] <> 1.0) or (mt[1*4+1] <> 1.0);
end;
result := (mt[0] <> 1.0) or (mt[1*4+1] <> 1.0);
end;
// set active context; `ctx` can be `nil`
procedure gxSetContextInternal (ctx: TGxContext; ascale: Single; domatrix: Boolean);
var
// set active context; `ctx` can be `nil`
procedure gxSetContextInternal (ctx: TGxContext; ascale: Single; domatrix: Boolean);
var
- mt: packed array [0..15] of Double;
+ mt: packed array [0..15] of GLfloat;
begin
if (savedGLState.saved) then savedGLState.restore();
begin
if (savedGLState.saved) then savedGLState.restore();
else
begin
// assume uniform scale
else
begin
// assume uniform scale
- glGetDoublev(GL_MODELVIEW_MATRIX, @mt[0]);
+ glGetFloatv(GL_MODELVIEW_MATRIX, @mt[0]);
ctx.mScaled := (mt[0] <> 1.0) or (mt[1*4+1] <> 1.0);
ctx.mScale := mt[0];
oglSetup2DState();
ctx.mScaled := (mt[0] <> 1.0) or (mt[1*4+1] <> 1.0);
ctx.mScale := mt[0];
oglSetup2DState();
end;
end;
+// vertical scroll bar
+procedure TGxContext.drawVSBar (x, y, wdt, hgt: Integer; cur, min, max: Integer; constref clrfull, clrempty: TGxRGBA);
+var
+ filled: Integer;
+begin
+ if (wdt < 1) or (hgt < 1) then exit;
+ filled := sbarFilled(hgt, cur, min, max);
+ color := clrfull;
+ fillRect(x, y, wdt, filled);
+ color := clrempty;
+ fillRect(x, y+filled, wdt, hgt-filled);
+end;
+
+
+// horizontal scrollbar
+procedure TGxContext.drawHSBar (x, y, wdt, hgt: Integer; cur, min, max: Integer; constref clrfull, clrempty: TGxRGBA);
+var
+ filled: Integer;
+begin
+ if (wdt < 1) or (hgt < 1) then exit;
+ filled := sbarFilled(wdt, cur, min, max);
+ color := clrfull;
+ fillRect(x, y, filled, hgt);
+ color := clrempty;
+ fillRect(x+filled, y, wdt-filled, hgt);
+end;
+
+
+class function TGxContext.sbarFilled (wh: Integer; cur, min, max: Integer): Integer;
+begin
+ if (wh < 1) then result := 0
+ else if (min > max) then result := 0
+ else if (min = max) then result := wh
+ else
+ begin
+ if (cur < min) then cur := min else if (cur > max) then cur := max;
+ result := wh*(cur-min) div (max-min);
+ end;
+end;
+
+
+class function TGxContext.sbarPos (cxy: Integer; xy, wh: Integer; min, max: Integer): Integer;
+begin
+ if (wh < 1) then begin result := 0; exit; end;
+ if (min > max) then begin result := 0; exit; end;
+ if (min = max) then begin result := max; exit; end;
+ if (cxy < xy) then begin result := min; exit; end;
+ if (cxy >= xy+wh) then begin result := max; exit; end;
+ result := min+((max-min)*(cxy-xy) div wh);
+ assert((result >= min) and (result <= max));
+end;
+
+
+
+
// ////////////////////////////////////////////////////////////////////////// //
(*
procedure oglRestoreMode (doClear: Boolean);
// ////////////////////////////////////////////////////////////////////////// //
(*
procedure oglRestoreMode (doClear: Boolean);
*)
*)
-//procedure onWinFocus (); begin end;
-//procedure onWinBlur (); begin fuiResetKMState(true); end;
+//procedure onWinFocus (); begin uiFocus(); end;
+//procedure onWinBlur (); begin fuiResetKMState(true); uiBlur(); end;
//procedure onPreRender (); begin oglRestoreMode(gGfxDoClear); end;
procedure onPostRender (); begin oglDrawCursor(); end;
//procedure onPreRender (); begin oglRestoreMode(gGfxDoClear); end;
procedure onPostRender (); begin oglDrawCursor(); end;