Changeset 617 for trunk/Packages


Ignore:
Timestamp:
Sep 15, 2024, 1:31:30 PM (2 months ago)
Author:
chronos
Message:
  • Fixed: City screen rename right mouse click didn't work on Windows due to window title are. Change to behave the same way as on Linux.
  • Fixed: Allow full screen switching in editor and movie mode.
  • Modified: Precalculate scaling coefficients also for from native values conversions for faster speed.
Location:
trunk/Packages
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CevoComponents/DrawDlg.pas

    r565 r617  
    2525    procedure InitButtons;
    2626    procedure OnEraseBkgnd(var Msg: TMessage); message WM_ERASEBKGND;
    27     procedure OnHitTest(var Msg: TMessage); message WM_NCHITTEST;
    2827    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    2928      override;
     
    9291end;
    9392
    94 procedure TDrawDlg.OnHitTest(var Msg: TMessage);
    95 var
    96   I: integer;
    97   ControlBounds: TRect;
    98   Pos: TPoint;
    99 begin
    100   if BorderStyle <> TBorderStyle.bsNone then
    101     inherited
    102   else
    103   begin
    104     Pos := Point(ScaleFromNative(Integer(Msg.LParam and $ffff)),
    105       ScaleFromNative(Integer((Msg.LParam shr 16) and $ffff)));
    106     if Pos.Y >= Top + TitleHeight then
    107       Msg.Result := HTCLIENT
    108     else
    109     begin
    110       for I := 0 to ControlCount - 1 do
    111         if Controls[I].Visible then
    112         begin
    113           ControlBounds := Controls[I].BoundsRect;
    114           if (Pos.X >= Left + ControlBounds.Left) and
    115             (Pos.X < Left + ControlBounds.Right) and
    116             (Pos.Y >= Top + ControlBounds.Top) and
    117             (Pos.Y < Top + ControlBounds.Bottom) then
    118           begin
    119             Msg.result := HTCLIENT;
    120             Exit;
    121           end;
    122         end;
    123       Msg.Result := HTCAPTION;
    124     end;
    125   end;
    126 end;
    127 
    12893procedure TDrawDlg.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
    12994  Y: Integer);
     
    13196  MousePos1: TPoint;
    13297  MousePos2: TPoint;
    133 {$IFDEF UNIX}
    13498  NewFormPos: TPoint;
    135 {$ENDIF}
    13699begin
    137100  MousePos1 := Mouse.CursorPos;
    138101  inherited;
    139102  MousePos2 := Mouse.CursorPos;
    140   {$IFDEF UNIX}
    141   // Only if client is not doing own mouse move handling
    142103  if not Assigned(OnMouseDown) or not Assigned(OnMouseMove) or not Assigned(OnMouseUp) then begin
    143     // HitTest is not supported under Linux GTK2 so use form inside move mechanizm
    144104    NewFormPos := ScreenToClient(Mouse.CursorPos);
    145105    if (NewFormPos.X >= 0) and (NewFormPos.X < Width) and
     
    154114    end else MoveActive := False;
    155115  end;
    156   {$ENDIF}
    157116end;
    158117
     
    163122  inherited;
    164123  if MoveActive then begin
    165     MousePos := ClientToScreen(Point(X, Y));
     124    MousePos := Mouse.CursorPos;
    166125    SetBounds(MoveFormPos.X + MousePos.X - MoveMousePos.X,
    167       MoveFormPos.Y + MousePos.Y - MoveMousePos.Y,
    168       Width, Height);
     126      MoveFormPos.Y + MousePos.Y - MoveMousePos.Y, Width, Height);
    169127  end;
    170128end;
  • trunk/Packages/DpiControls/Dpi.Common.pas

    r608 r617  
    225225function ScaleToNative(Value: Integer): Integer; inline;
    226226begin
    227   Result := ScreenInfo.Lookup[Value];
     227  Result := ScreenInfo.LookupToNative[Value];
    228228  // Round and Trunc are fast. Ceil and Floor are slow.
    229229  // Without lookup table we would use:
     
    238238function ScaleFromNative(Value: Integer): Integer;
    239239begin
    240   Result := Trunc(Value * ScreenInfo.FromNative);
     240  Result := ScreenInfo.LookupFromNative[Value];
     241  // Round and Trunc are fast. Ceil and Floor are slow.
     242  // Without lookup table we would use:
     243  // Result := Floor(Value * ScreenInfo.FromNative);
    241244end;
    242245
  • trunk/Packages/DpiControls/Dpi.Graphics.pas

    r568 r617  
    354354    ToNative: Double;
    355355    FromNative: Double;
    356     Lookup: array[-10000..10000] of Integer; // Should be sufficient for 8K screens
     356    LookupToNative: array[-10000..10000] of Integer; // Should be sufficient for 8K screens
     357    LookupFromNative: array[-10000..10000] of Integer; // Should be sufficient for 8K screens
    357358    property Dpi: Integer read FDpi write SetDpi;
    358359  end;
     
    13531354  if FDpi = AValue then Exit;
    13541355  FDpi := AValue;
     1356
     1357  // Precalculate scaling coefficients
    13551358  ToNative := ScreenInfo.Dpi / 96;
    1356 
    1357   // Precalculate scaling coefficients
     1359  for I := Low(LookupToNative) to High(LookupToNative) do
     1360    LookupToNative[I] := Ceil(I * ToNative);
    13581361  FromNative := 96 / ScreenInfo.Dpi;
    1359   for I := Low(Lookup) to High(Lookup) do
    1360     Lookup[I] := Ceil(I * ToNative);
     1362  for I := Low(LookupFromNative) to High(LookupFromNative) do
     1363    LookupFromNative[I] := Floor(I * FromNative);
    13611364end;
    13621365
Note: See TracChangeset for help on using the changeset viewer.