summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4d5a94c)
raw | patch | inline | side by side (parent: 4d5a94c)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 4 Oct 2017 13:25:11 +0000 (16:25 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 4 Oct 2017 13:27:00 +0000 (16:27 +0300) |
src/flexui/fui_ctls.pas | patch | blob | history |
index cdcad343b9bdfe8db4fd59c27bb05d1c623de87f..50a73f13b8f736be4339ba2118fadc85404277e2 100644 (file)
--- a/src/flexui/fui_ctls.pas
+++ b/src/flexui/fui_ctls.pas
//WARNING! do not call scissor functions outside `.draw*()` API!
// set scissor to this rect (in local coords)
procedure setScissor (lx, ly, lw, lh: Integer); // valid only in `draw*()` calls
+ procedure resetScissor (); inline; // only client area, w/o frame
+ procedure resetScissorNC (); inline; // full drawing area, with frame
public
actionCB: TActionCB;
procedure AfterConstruction (); override; // so it will be correctly initialized when created from parser
function parseProperty (const prname: AnsiString; par: TTextParser): Boolean; override;
-
- procedure drawControl (gx, gy: Integer); override;
end;
// ////////////////////////////////////////////////////////////////////// //
//uiContext.clip := TGxRect.Create(gx, gy, wdt, hgt);
end;
+procedure TUIControl.resetScissorNC (); inline;
+begin
+ setScissor(0, 0, mWidth, mHeight);
+end;
+
+procedure TUIControl.resetScissor (); inline;
+begin
+ if ((mFrameWidth <= 0) and (mFrameHeight <= 0)) then
+ begin
+ resetScissorNC();
+ end
+ else
+ begin
+ setScissor(mFrameWidth, mFrameHeight, mWidth-mFrameWidth*2, mHeight-mFrameHeight*2);
+ end;
+end;
// ////////////////////////////////////////////////////////////////////////// //
f: Integer;
gx, gy: Integer;
- procedure resetScissor (fullArea: Boolean); inline;
- begin
- uiContext.clip := savedClip;
- if (fullArea) or ((mFrameWidth = 0) and (mFrameHeight = 0)) then
- begin
- setScissor(0, 0, mWidth, mHeight);
- end
- else
- begin
- //writeln('frm: (', mFrameWidth, 'x', mFrameHeight, ')');
- setScissor(mFrameWidth, mFrameHeight, mWidth-mFrameWidth*2, mHeight-mFrameHeight*2);
- end;
- end;
-
begin
if (mWidth < 1) or (mHeight < 1) or (uiContext = nil) or (not uiContext.active) then exit;
toGlobal(0, 0, gx, gy);
savedClip := uiContext.clip;
try
- resetScissor(true); // full area
+ resetScissorNC();
drawControl(gx, gy);
- resetScissor(false); // client area
+ resetScissor();
for f := 0 to High(mChildren) do mChildren[f].draw();
- resetScissor(true); // full area
- if (self is TUISwitchBox) then
- begin
- uiContext.color := TGxRGBA.Create(255, 0, 0, 255);
- //uiContext.fillRect(gx, gy, mWidth, mHeight);
- //writeln('frm: (', mFrameWidth, 'x', mFrameHeight, '); sz=(', mWidth, 'x', mHeight, '); clip=', uiContext.clip.toString);
- end;
- if false and (mId = 'cbtest') then
- begin
- uiContext.color := TGxRGBA.Create(255, 127, 0, 96);
- uiContext.fillRect(gx, gy, mWidth, mHeight);
- if (mFrameWidth > 0) and (mFrameHeight > 0) then
- begin
- uiContext.color := TGxRGBA.Create(255, 255, 0, 96);
- uiContext.fillRect(gx+mFrameWidth, gy+mFrameHeight, mWidth-mFrameWidth*2, mHeight-mFrameHeight*2);
- end;
- end
- else if false and (self is TUISwitchBox) then
- begin
- uiContext.color := TGxRGBA.Create(255, 0, 0, 255);
- uiContext.fillRect(gx, gy, mWidth, mHeight);
- //writeln('frm: (', mFrameWidth, 'x', mFrameHeight, ')');
- end;
+ resetScissorNC();
drawControlPost(gx, gy);
finally
uiContext.clip := savedClip;
procedure TUIControl.drawControl (gx, gy: Integer);
begin
- //if (mParent = nil) then darkenRect(gx, gy, mWidth, mHeight, 64);
end;
procedure TUIControl.drawControlPost (gx, gy: Integer);
begin
- // shadow
+ // shadow for top-level controls
if (mParent = nil) and (mDrawShadow) and (mWidth > 0) and (mHeight > 0) then
begin
- //setScissorGLInternal(gx+8, gy+8, mWidth, mHeight);
uiContext.resetClip();
uiContext.darkenRect(gx+mWidth, gy+8, 8, mHeight, 128);
uiContext.darkenRect(gx+8, gy+mHeight, mWidth-8, 8, 128);
end;
+// ////////////////////////////////////////////////////////////////////////// //
procedure TUITopWindow.drawControl (gx, gy: Integer);
begin
uiContext.color := mBackColor[getColorIndex];
iwdt := uiContext.iconWinWidth(TGxContext.TWinIcon.Close);
if (mDragScroll = TXMode.Drag) then
begin
- //uiContext.color := mFrameColor[cidx];
drawFrame(gx, gy, iwdt, 0, mTitle, false);
end
else
begin
ihgt := uiContext.iconWinHeight(TGxContext.TWinIcon.Close);
- //uiContext.color := mFrameColor[cidx];
drawFrame(gx, gy, iwdt, 0, mTitle, true);
// vertical scroll bar
vhgt := mHeight-mFrameHeight*2;
if (mFullSize.h > vhgt) then
begin
ybot := mScrollY+vhgt;
- setScissor(0, 0, mWidth, mHeight);
+ resetScissorNC();
uiContext.drawVSBar(gx+mWidth-mFrameWidth+1, gy+mFrameHeight-1, mFrameWidth-3, vhgt+2, ybot, 0, mFullSize.h, mSBarFullColor[cidx], mSBarEmptyColor[cidx]);
end;
// horizontal scroll bar
if (mFullSize.w > vwdt) then
begin
xend := mScrollX+vwdt;
- setScissor(0, 0, mWidth, mHeight);
+ resetScissorNC();
uiContext.drawHSBar(gx+mFrameWidth+1, gy+mHeight-mFrameHeight+1, vwdt-2, mFrameHeight-3, xend, 0, mFullSize.w, mSBarFullColor[cidx], mSBarEmptyColor[cidx]);
end;
// frame icon
uiContext.color := mFrameIconColor[cidx];
uiContext.drawIconWin(TGxContext.TWinIcon.Close, gx+mFrameWidth, gy, mInClose);
end;
- // shadow
+ // shadow (no need to reset scissor, as draw should do it)
inherited drawControlPost(gx, gy);
end;
+// ////////////////////////////////////////////////////////////////////////// //
procedure TUITopWindow.activated ();
begin
if (mFocused = nil) or (mFocused = self) then
procedure TUIBox.drawControl (gx, gy: Integer);
var
cidx: Integer;
- xpos: Integer;
+ //xpos: Integer;
begin
cidx := getColorIndex;
uiContext.color := mBackColor[cidx];
if (mHasFrame) then
begin
// draw frame
- drawFrame(gx, gy, 0, -1, mCaption, false);
- //uiContext.color := mFrameColor[cidx];
- //uiContext.rect(gx+3, gy+3, mWidth-6, mHeight-6);
- end
+ drawFrame(gx, gy, 0, mHAlign, mCaption, false);
+ end;
+ // no frame -- no caption
+ {
else if (Length(mCaption) > 0) then
begin
// draw caption
xpos += gx+mFrameWidth;
setScissor(mFrameWidth+1, 0, mWidth-mFrameWidth-2, uiContext.textHeight(mCaption));
- {
- if (mHasFrame) then
- begin
- uiContext.color := mBackColor[cidx];
- uiContext.fillRect(xpos-3, gy, uiContext.textWidth(mCaption)+4, 8);
- end;
- }
uiContext.color := mFrameTextColor[cidx];
uiContext.drawText(xpos, gy, mCaption);
end;
+ }
end;
end;
-procedure TUISpan.drawControl (gx, gy: Integer);
-begin
-end;
-
-
// ////////////////////////////////////////////////////////////////////// //
procedure TUILine.AfterConstruction ();
begin
procedure TUIButton.drawControl (gx, gy: Integer);
var
wdt, hgt: Integer;
- xpos, ypos, xofsl, xofsr{, sofs}: Integer;
+ xpos, ypos, xofsl, xofsr, sofs: Integer;
cidx: Integer;
lch, rch: AnsiChar;
lstr, rstr: AnsiString;
hgt := mHeight-mShadowSize;
if (mPushed) {or (cidx = ClrIdxActive)} then
begin
- //sofs := mShadowSize;
+ sofs := mShadowSize;
gx += mShadowSize;
gy += mShadowSize;
end
else
begin
- //sofs := 0;
+ sofs := 0;
if (mShadowSize > 0) then
begin
uiContext.darkenRect(gx+mShadowSize, gy+hgt, wdt, mShadowSize, 96);
end;
uiContext.color := mBackColor[cidx];
- //setScissor(sofs, sofs, wdt, hgt);
uiContext.fillRect(gx, gy, wdt, hgt);
if (mVAlign < 0) then ypos := 0
else begin xpos := wdt-xofsl-xofsr-uiContext.textWidth(mText); if (mHAlign = 0) then xpos := xpos div 2; end;
xpos += xofsl;
- //setScissor(xofsl+sofs, sofs, wdt-xofsl-xofsr, hgt);
+ setScissor(sofs+xofsl, sofs, wdt-xofsl-xofsr, hgt);
uiContext.drawText(gx+xpos, ypos, mText);
if (mHotChar <> #0) and (mHotChar <> ' ') then