Changeset 565 for trunk/Start.pas


Ignore:
Timestamp:
May 1, 2024, 12:08:20 PM (5 weeks ago)
Author:
chronos
Message:
  • Modified: Start form changed to use Offscreen bitmap for drawing as Qt5 doesn't support copying from form canvas.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Start.pas

    r554 r565  
    66uses
    77  GameServer, Messg, ButtonBase, ButtonA, ButtonC, ButtonB, Area, Types,
    8   LCLIntf, LCLType, SysUtils, Classes,
     8  LCLIntf, LCLType, SysUtils, Classes, BaseWin,
    99  Registry, DrawDlg, Generics.Collections, Protocol, MiniMap, Brain, Translator,
    1010  {$IFDEF DPI}System.UITypes, Dpi.Graphics, Dpi.Controls, Dpi.Forms, Dpi.StdCtrls,
     
    4242  { TStartDlg }
    4343
    44   TStartDlg = class(TDrawDlg)
     44  TStartDlg = class(TBufferedDrawDlg)
    4545    PopupMenu1: TPopupMenu;
    4646    StartBtn: TButtonA;
     
    6262    procedure ListKeyPress(Sender: TObject; var Key: Char);
    6363    procedure StartBtnClick(Sender: TObject);
    64     procedure FormPaint(Sender: TObject);
    6564    procedure FormShow(Sender: TObject);
    6665    procedure FormHide(Sender: TObject);
     
    131130    procedure UnlistBackupFile(FileName: string);
    132131    procedure SmartInvalidate(x0, y0, x1, y1: Integer;
    133       invalidateTab0: Boolean = False); overload;
     132      InvalidateTab0: Boolean = False); overload;
    134133    procedure LoadConfig;
    135134    procedure SaveConfig;
     
    138137    procedure UpdateInterface;
    139138    procedure ShowSettings;
     139  protected
     140    procedure OffscreenPaint; override;
    140141  public
    141142    EmptyPicture: TBitmap;
     
    338339var
    339340  I: Integer;
    340   r0, r1: HRgn;
    341 begin
    342   r0 := CreateRectRgn(x0, y0, x1, y1);
     341  R0, R1: HRgn;
     342begin
     343  OffscreenUser := nil;
     344  R0 := CreateRectRgn(x0, y0, x1, y1);
    343345  for I := 0 to ControlCount - 1 do
    344346    if not (Controls[I] is TArea) and Controls[I].Visible then
    345347    begin
    346348      with Controls[I].BoundsRect do
    347         r1 := CreateRectRgn(Left, Top, Right, Bottom);
    348       CombineRgn(r0, r0, r1, RGN_DIFF);
    349       DeleteObject(r1);
    350     end;
    351   if not invalidateTab0 then begin
    352     r1 := CreateRectRgn(0, 0, 6 + 36, 3 + 38); // tab 0 icon
    353     CombineRgn(r0, r0, r1, RGN_DIFF);
    354     DeleteObject(r1);
    355   end;
    356   InvalidateRgn(Handle, r0, False);
    357   DeleteObject(r0);
     349        R1 := CreateRectRgn(Left, Top, Right, Bottom);
     350      CombineRgn(R0, R0, R1, RGN_DIFF);
     351      DeleteObject(R1);
     352    end;
     353  if not InvalidateTab0 then begin
     354    R1 := CreateRectRgn(0, 0, 6 + 36, 3 + 38); // tab 0 icon
     355    CombineRgn(R0, R0, R1, RGN_DIFF);
     356    DeleteObject(R1);
     357  end;
     358  InvalidateRgn(Handle, R0, False);
     359  DeleteObject(R0);
    358360end;
    359361
     
    536538procedure TStartDlg.DrawAction(Y, IconIndex: Integer; HeaderItem, TextItem: string);
    537539begin
    538   Canvas.Font.Assign(UniFont[ftCaption]);
    539   Canvas.Font.Style := Canvas.Font.Style + [TFontStyle.fsUnderline];
    540   RisedTextOut(Canvas, xAction, Y - 3, Phrases2.Lookup(HeaderItem));
    541   Canvas.Font.Assign(UniFont[ftNormal]);
    542   BiColorTextOut(Canvas, Colors.Canvas.Pixels[clkAge0 - 1, cliDimmedText],
    543     $000000, xAction, Y + 21, Phrases2.Lookup(TextItem));
    544 
    545   UnshareBitmap(DrawBuffer);
    546   DrawBufferEnsureSize(50, 50);
    547   BitBltCanvas(DrawBuffer.Canvas, 0, 0, 50, 50, Canvas,
    548     xActionIcon - 2, Y - 2);
    549   GlowFrame(DrawBuffer, 8, 8, 34, 34, $202020);
    550   BitBltCanvas(Canvas, xActionIcon - 2, Y - 2, 50, 50,
    551     DrawBuffer.Canvas, 0, 0);
    552   BitBltCanvas(Canvas, xActionIcon, Y, 40, 40, BigImp.Canvas,
    553     (IconIndex mod 7) * xSizeBig + 8, (IconIndex div 7) * ySizeBig);
    554   RFrame(Canvas, xActionIcon - 1, Y - 1, xActionIcon + 40, Y + 40,
    555     $000000, $000000);
    556 end;
    557 
    558 procedure TStartDlg.FormPaint(Sender: TObject);
     540  with Offscreen do begin
     541    Canvas.Font.Assign(UniFont[ftCaption]);
     542    Canvas.Font.Style := Canvas.Font.Style + [TFontStyle.fsUnderline];
     543    RisedTextOut(Canvas, xAction, Y - 3, Phrases2.Lookup(HeaderItem));
     544    Canvas.Font.Assign(UniFont[ftNormal]);
     545    BiColorTextOut(Canvas, Colors.Canvas.Pixels[clkAge0 - 1, cliDimmedText],
     546      $000000, xAction, Y + 21, Phrases2.Lookup(TextItem));
     547
     548    UnshareBitmap(DrawBuffer);
     549    DrawBufferEnsureSize(50, 50);
     550    BitBltCanvas(DrawBuffer.Canvas, 0, 0, 50, 50, Canvas,
     551      xActionIcon - 2, Y - 2);
     552    GlowFrame(DrawBuffer, 8, 8, 34, 34, $202020);
     553    BitBltCanvas(Canvas, xActionIcon - 2, Y - 2, 50, 50,
     554      DrawBuffer.Canvas, 0, 0);
     555    BitBltCanvas(Canvas, xActionIcon, Y, 40, 40, BigImp.Canvas,
     556      (IconIndex mod 7) * xSizeBig + 8, (IconIndex div 7) * ySizeBig);
     557    RFrame(Canvas, xActionIcon - 1, Y - 1, xActionIcon + 40, Y + 40,
     558      $000000, $000000);
     559  end;
     560end;
     561
     562procedure TStartDlg.OffscreenPaint;
    559563const
    560564  TabNames: array[TStartTab] of Integer = (0, 11, 3, 4);
     
    565569  MainAction: TMainAction;
    566570begin
    567   PaintBackground(Self, 3, 3, TabOffset + 4 * TabSize - 4, TabHeight - 3);
    568   PaintBackground(Self, 3, TabHeight + 3, ClientWidth - 6,
    569     ClientHeight - TabHeight - 6);
     571  inherited;
     572
     573  with Offscreen do begin
     574  PaintBackground(Canvas, 3, 3, TabOffset + 4 * TabSize - 4, TabHeight - 3,
     575    ClientWidth, ClientHeight);
     576  PaintBackground(Canvas, 3, TabHeight + 3, ClientWidth - 6,
     577    ClientHeight - TabHeight - 6, ClientWidth, ClientHeight);
    570578  with Canvas do
    571579  begin
     
    626634  if Tab = tbMain then
    627635  begin
    628     PaintBackground(Self, 3, TabHeight - 1, TabSize - 4 - 3 + TabOffset + 3, 4);
     636    PaintBackground(Canvas, 3, TabHeight - 1, TabSize - 4 - 3 + TabOffset + 3, 4,
     637      ClientWidth, ClientHeight);
    629638    Canvas.Pixels[2, TabHeight] := MainTexture.ColorBevelLight;
    630639  end
    631640  else
    632641  begin
    633     PaintBackground(Self, TabOffset + 3 + Integer(Tab) * TabSize, TabHeight - 1,
    634       TabSize - 4, 4);
     642    PaintBackground(Canvas, TabOffset + 3 + Integer(Tab) * TabSize, TabHeight - 1,
     643      TabSize - 4, 4, ClientWidth, ClientHeight);
    635644    Canvas.Pixels[TabOffset + Integer(Tab) * TabSize + 2, TabHeight] :=
    636645      MainTexture.ColorBevelLight;
     
    904913        y0Mini - 8, S);
    905914  end;
     915  end;
     916  MarkUsedOffscreen(ClientWidth, ClientHeight);
    906917end;
    907918
     
    14381449    ReplayBtn.Visible := MiniMap.Mode <> mmMultiPlayer;
    14391450  List.Invalidate;
    1440   SmartInvalidate(0, 0, ClientWidth, ClientHeight, invalidateTab0);
     1451  SmartInvalidate(0, 0, ClientWidth, ClientHeight, InvalidateTab0);
    14411452end;
    14421453
Note: See TracChangeset for help on using the changeset viewer.