Преглед на файлове

GUI: remove page-bar in grid when only 1 page

Herman Schoenfeld преди 7 години
родител
ревизия
7afa372472
променени са 5 файла, в които са добавени 85 реда и са изтрити 26 реда
  1. 0 1
      src/gui/UCTRLWallet.lfm
  2. 2 3
      src/gui/UCTRLWallet.pas
  3. 14 13
      src/gui/wizards/UWIZSendPASC_Start.lfm
  4. 1 1
      src/gui/wizards/UWIZSendPASC_Start.pas
  5. 68 8
      src/libraries/sphere10/UVisualGrid.pas

+ 0 - 1
src/gui/UCTRLWallet.lfm

@@ -10,7 +10,6 @@ object CTRLWallet: TCTRLWallet
   ClientWidth = 1151
   OnCreate = FormCreate
   OnResize = FormResize
-  LCLVersion = '1.8.1.0'
   Visible = False
   object PairSplitter1: TPairSplitter
     Left = 0

+ 2 - 3
src/gui/UCTRLWallet.pas

@@ -118,7 +118,7 @@ begin
   FAccountsGrid.AutoPageSize := True;
   FAccountsGrid.SelectionType := stMultiRow;
   FAccountsGrid.DeselectionType := dtDefault;
-  FAccountsGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone];
+  FAccountsGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone, vgoAutoHidePaging];
   FAccountsGrid.DefaultColumnWidths :=
     TArray<integer>.Create(100,                   // Account
     CT_VISUALGRID_STRETCH, // Name
@@ -135,7 +135,7 @@ begin
   FOperationsGrid.AutoPageSize := True;
   FOperationsGrid.SelectionType := stRow;
   FOperationsGrid.DeselectionType := dtDefault;
-  FOperationsGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone];
+  FOperationsGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone, vgoAutoHidePaging];
   FOperationsGrid.DefaultColumnWidths :=
     TArray<integer>.Create(130,                   // Time
     CT_VISUALGRID_DEFAULT, // Block
@@ -183,7 +183,6 @@ begin
 
 end;
 
-
 procedure TCTRLWallet.ActivateFirstTime;
 begin
 

+ 14 - 13
src/gui/wizards/UWIZSendPASC_Start.lfm

@@ -1,27 +1,28 @@
 object WIZSendPASC_Start: TWIZSendPASC_Start
   Left = 0
-  Height = 253
+  Height = 261
   Top = 0
-  Width = 429
+  Width = 474
   Caption = 'WIZSendPASC_Start'
-  ClientHeight = 253
-  ClientWidth = 429
+  ClientHeight = 261
+  ClientWidth = 474
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gpSender: TGroupBox
-    Left = 9
-    Height = 240
-    Top = 5
-    Width = 410
+    Left = 4
+    Height = 256
+    Top = 0
+    Width = 462
     Anchors = [akTop, akLeft, akRight, akBottom]
     Caption = 'Sender Accounts'
-    ClientHeight = 220
-    ClientWidth = 406
+    ClientHeight = 236
+    ClientWidth = 458
     TabOrder = 0
     object paGrid: TPanel
       Left = 8
-      Height = 198
-      Top = 8
-      Width = 388
+      Height = 214
+      Top = 16
+      Width = 440
       Anchors = [akTop, akLeft, akRight, akBottom]
       BevelOuter = bvNone
       Caption = 'GRID PANEL'

+ 1 - 1
src/gui/wizards/UWIZSendPASC_Start.pas

@@ -71,7 +71,7 @@ begin
   FSendersGrid.FetchDataInThread := False;
   FSendersGrid.AutoPageSize := True;
   FSendersGrid.SelectionType := stNone;
-  FSendersGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone];
+  FSendersGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone, vgoAutoHidePaging];
   FSendersGrid.DefaultColumnWidths :=
     TArray<integer>.Create(
     CT_VISUALGRID_STRETCH, // Account

+ 68 - 8
src/libraries/sphere10/UVisualGrid.pas

@@ -97,7 +97,7 @@ type
 
   { TVisualGridOptions }
 
-  TVisualGridOptions = set of (vgoColAutoFill, vgoColSizing,
+  TVisualGridOptions = set of (vgoColAutoFill, vgoColSizing, vgoAutoHidePaging,
     vgoMultiSearchCheckComboBox, vgoSortDirectionAllowNone);
 
   { TSortMode }
@@ -238,7 +238,7 @@ type
     FActiveThread: TThread;
     FOnPreparePopupMenu: TPreparePopupMenuEvent;
     FOnSelection: TSelectionEvent;
-    FFinishedUpdating: TNotifyEvent;
+    FOnFinishedUpdating: TNotifyEvent;
     FOptions: TVisualGridOptions;
     FSortMode: TSortMode;
     FSearchMode : TSearchMode;
@@ -366,7 +366,7 @@ type
     property OnDrawVisualCell: TDrawVisualCellEvent read FOnDrawVisualCell write FOnDrawVisualCell;
     property OnSelection: TSelectionEvent read FOnSelection write FOnSelection;
     property OnPreparePopupMenu: TPreparePopupMenuEvent read FOnPreparePopupMenu write FOnPreparePopupMenu;
-    property OnFinishedUpdating : TNotifyEvent read FFinishedUpdating write FFinishedUpdating;
+    property OnFinishedUpdating : TNotifyEvent read FOnFinishedUpdating write FOnFinishedUpdating;
 
     property WidgetControl: TControl read FWidgetControl write SetWidgetControl;
 
@@ -1274,7 +1274,14 @@ begin
     Exit;
   FDelayedBoundsChangeTimer.Enabled:=false;
   if AutoPageSize then
-    PageSize := ClientRowCount;
+  begin
+    // for vgoAutoHidePaging and AutoPageSize more space may be available
+    // and paging panel may be hidden
+    if (PageSize = ClientRowCount) and (vgoAutoHidePaging in FOptions) and FAutoPageSize then
+      RefreshPageIndexAndGridInterface
+    else
+      PageSize := ClientRowCount;
+  end;
 end;
 
 procedure TCustomVisualGrid.FetchDataThreadProgress(Sender: TObject);
@@ -1643,9 +1650,11 @@ end;
 procedure TCustomVisualGrid.SetOptions(AValue: TVisualGridOptions);
 var
   LSortDirectionAllowNone: boolean;
+  LAutoHidePaging: boolean;
 begin
   if FOptions=AValue then Exit;
   LSortDirectionAllowNone := vgoSortDirectionAllowNone in FOptions;
+  LAutoHidePaging := vgoAutoHidePaging in FOptions;
 
   FOptions:=AValue;
   if vgoColSizing in FOptions then
@@ -1659,6 +1668,9 @@ begin
   // refresh for sort direction graphic
   if LSortDirectionAllowNone <> (vgoSortDirectionAllowNone in AValue) then
     SortDirectionGlyphRefresh;
+  // try to hide paging panel
+  if LAutoHidePaging <>  (vgoAutoHidePaging in AValue) then
+    RefreshPageIndexAndGridInterface;
 end;
 
 procedure TCustomVisualGrid.SetRows(ARow: Integer; AValue: Variant);
@@ -1699,6 +1711,9 @@ begin
     FDrawGrid.ScrollBars:=ssAutoBoth;
 
   PageSize := ClientRowCount;
+
+  // for proper handling of vgoAutoHidePaging we need to refresh
+  RefreshPageIndexAndGridInterface;
 end;
 
 procedure TCustomVisualGrid.SetCanPage(AValue: boolean);
@@ -1798,12 +1813,53 @@ begin
 end;
 
 procedure TCustomVisualGrid.RefreshPageIndexAndGridInterface;
+var
+  LCountOnPage2, LCount: Integer;
+  LGridUnusedHeight: integer;
 begin
   SetPageIndexEditText(IntToStr(Succ(FPageIndex)));
   FPageCountLabel.Caption := Format('/%d',[FPageCount]);
+
+  if not FFetchDataThreadTimer.Enabled then
+  if (vgoAutoHidePaging in FOptions) and (FPageCount in [1,2]) and (FPageIndex = 0) then
+    case FPageCount of
+      // simple situation - just hide bottom panel
+      1:
+        FBottomPanel.Visible := False;
+      // for PageCount = 2 may be also possible but more complicated especially for AutoPageSize
+      2:
+        if AutoPageSize then
+        begin
+          LCountOnPage2 := FTotalDataCount - ClientRowCount;
+          LGridUnusedHeight := FDrawGrid.ClientHeight - FDrawGrid.GridHeight;
+          if FBottomPanel.Visible
+           and (FDrawGrid.DefaultRowHeight * LCountOnPage2 <= FBottomPanel.Height + LGridUnusedHeight) then
+          begin
+            FBottomPanel.Visible := False;
+            PageSize := PageSize + LCountOnPage2;
+            Exit;
+          end else
+          begin
+            if FCanPage then
+            begin
+              FBottomPanel.Visible := true;
+              LCount := ClientRowCount;
+              if LCount <> PageSize then
+              begin
+                PageSize := LCount;
+                Exit;
+              end;
+            end;
+          end;
+        end else
+          FBottomPanel.Visible := FCanPage
+    end
+  else
+    FBottomPanel.Visible := FCanPage;
+
   FDrawGrid.Refresh;
-  if Assigned(FFinishedUpdating) then
-    FFinishedUpdating(Self);
+  if Assigned(FOnFinishedUpdating) then
+    FOnFinishedUpdating(Self);
 end;
 
 procedure TCustomVisualGrid.ReloadColumns;
@@ -1894,7 +1950,6 @@ begin
   Result := ((FDrawGrid.ClientHeight - FDrawGrid.GridLineWidth) div FDrawGrid.DefaultRowHeight) - FDrawGrid.FixedRows;
   if Result = 0 then
     Result := 1;
-  FDrawGrid.VisibleRowCount;
 end;
 
 procedure TCustomVisualGrid.HidePageSizeControls(AVisible: boolean);
@@ -1945,7 +2000,12 @@ begin
     Exit;
 
   FPageIndex := Value;
-  RefreshPageIndexData(false)
+  if FDeselectionType <> dtNone then
+  begin
+    ResetLastSelection;
+    UpdateSelection(stNone);
+  end;
+  RefreshPageIndexData(false);
 end;
 
 procedure TCustomVisualGrid.SetPageIndexEditText(const AStr: utf8string);