summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5699a76)
raw | patch | inline | side by side (parent: 5699a76)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 30 Sep 2017 22:13:50 +0000 (01:13 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 2 Oct 2017 23:34:41 +0000 (02:34 +0300) |
src/game/g_holmes.pas | patch | blob | history | |
src/gx/gh_ui.pas | patch | blob | history |
diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 0cac2c7aa30aa5f0b5834b11d49d0a24b37d8001..e23c43563bdc9f86ecea403d1577b74d3b2aae38 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
//winHelp.appendChild(llb);
- winHelp.flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale), trunc(getScrHgt/gh_ui_scale));
uiLayoutCtl(winHelp);
winHelp.centerInScreen();
end;
box: TUIVBox;
begin
winLayers := TUITopWindow.Create('layers');
+ winLayers.flHoriz := false;
winLayers.x0 := 10;
winLayers.y0 := 10;
winLayers.flHoriz := false;
addCheckBox(box, '~foreground', @g_rlayer_fore);
winLayers.appendChild(box);
- winLayers.flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale), trunc(getScrHgt/gh_ui_scale));
uiLayoutCtl(winLayers);
end;
box: TUIVBox;
begin
winOutlines := TUITopWindow.Create('outlines');
+ winOutlines.flHoriz := false;
winOutlines.x0 := 100;
winOutlines.y0 := 30;
winOutlines.flHoriz := false;
addCheckBox(box, 'con~tours', @g_ol_nice);
winOutlines.appendChild(box);
- winOutlines.flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale), trunc(getScrHgt/gh_ui_scale));
uiLayoutCtl(winOutlines);
end;
begin
winOptions := TUITopWindow.Create('Holmes Options');
winOptions.flHoriz := false;
+ winOptions.flHoriz := false;
winOptions.escClose := true;
box := TUIVBox.Create();
addButton(box, '~outline', toggleOutlineWindowCB);
winOptions.appendChild(box);
- winOptions.flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale), trunc(getScrHgt/gh_ui_scale));
uiLayoutCtl(winOptions);
winOptions.centerInScreen();
end;
diff --git a/src/gx/gh_ui.pas b/src/gx/gh_ui.pas
index 9027758fedba90270ae400d49ba50bfd554f0f9a..28311e3a4d3ef80c3cac2457d238d3ee97f678f0 100644 (file)
--- a/src/gx/gh_ui.pas
+++ b/src/gx/gh_ui.pas
mInClose: Boolean;
mFreeOnClose: Boolean; // default: false
mDoCenter: Boolean; // after layouting
+ mFitToScreen: Boolean;
protected
procedure activated (); override;
function parseProperty (const prname: AnsiString; par: TTextParser): Boolean; override;
+ procedure flFitToScreen (); // call this before layouting
+
procedure centerInScreen ();
// `sx` and `sy` are screen coordinates
public
property freeOnClose: Boolean read mFreeOnClose write mFreeOnClose;
+ property fitToScreen: Boolean read mFitToScreen write mFitToScreen;
end;
// ////////////////////////////////////////////////////////////////////// //
function parseProperty (const prname: AnsiString; par: TTextParser): Boolean; override;
+ procedure doAction (); override;
+
procedure drawControl (gx, gy: Integer); override;
procedure mouseEvent (var ev: THMouseEvent); override;
procedure mouseEvent (var ev: THMouseEvent); override;
procedure keyEvent (var ev: THKeyEvent); override;
- procedure keyEventPost (var ev: THKeyEvent); override;
end;
// ////////////////////////////////////////////////////////////////////// //
procedure mouseEvent (var ev: THMouseEvent); override;
procedure keyEvent (var ev: THKeyEvent); override;
- procedure keyEventPost (var ev: THKeyEvent); override;
procedure setVar (pvar: PBoolean);
if (ctl = nil) then exit;
lay := TFlexLayouter.Create();
try
+ if (ctl is TUITopWindow) and (TUITopWindow(ctl).fitToScreen) then TUITopWindow(ctl).flFitToScreen();
+
lay.setup(ctl);
//lay.layout();
procedure TUITopWindow.AfterConstruction ();
begin
inherited;
+ mFitToScreen := true;
mFrameWidth := 8;
mFrameHeight := 8;
if (mWidth < mFrameWidth*2+3*8) then mWidth := mFrameWidth*2+3*8;
end;
+procedure TUITopWindow.flFitToScreen ();
+begin
+ flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale)-mFrameWidth*2-6, trunc(getScrHgt/gh_ui_scale)-mFrameHeight*2-6);
+end;
+
+
procedure TUITopWindow.centerInScreen ();
begin
if (mWidth > 0) and (mHeight > 0) then
end;
-procedure TUITextLabel.keyEventPost (var ev: THKeyEvent);
+procedure TUITextLabel.doAction ();
var
ctl: TUIControl;
+begin
+ if (assigned(actionCB)) then
+ begin
+ actionCB(self);
+ end
+ else
+ begin
+ ctl := topLevel[mLinkId];
+ if (ctl <> nil) then
+ begin
+ if (ctl.canFocus) then ctl.focused := true;
+ end;
+ end;
+end;
+
+
+procedure TUITextLabel.keyEventPost (var ev: THKeyEvent);
begin
if (not enabled) then exit;
- if (mHotChar = #0) or (Length(mLinkId) = 0) then exit;
+ if (mHotChar = #0) then exit;
if (ev.eaten) or (ev.cancelled) or (not ev.press) then exit;
+ if (ev.kstate <> ev.ModAlt) then exit;
if (not ev.isHot(mHotChar)) then exit;
- ctl := topLevel[mLinkId];
- if (ctl <> nil) then
- begin
- ev.eat();
- if (ctl.canFocus) then ctl.focused := true;
- end;
+ ev.eat();
+ if (canFocus) then focused := true;
+ doAction();
end;
end;
-procedure TUIButton.keyEventPost (var ev: THKeyEvent);
-begin
- if (not enabled) then exit;
- if (mHotChar = #0) then exit;
- if (ev.eaten) or (ev.cancelled) or (not ev.press) then exit;
- if (not ev.isHot(mHotChar)) then exit;
- if (not canFocus) then exit;
- ev.eat();
- focused := true;
- doAction();
-end;
-
-
// ////////////////////////////////////////////////////////////////////////// //
procedure TUISwitchBox.AfterConstruction ();
begin
end;
-procedure TUISwitchBox.keyEventPost (var ev: THKeyEvent);
-begin
- if (not enabled) then exit;
- if (mHotChar = #0) then exit;
- if (ev.eaten) or (ev.cancelled) or (not ev.press) then exit;
- if (not ev.isHot(mHotChar)) then exit;
- if (not canFocus) then exit;
- ev.eat();
- focused := true;
- doAction();
-end;
-
-
// ////////////////////////////////////////////////////////////////////////// //
procedure TUICheckBox.AfterConstruction ();
begin