瀏覽代碼

Libraries: visual grid bug fix

Herman Schoenfeld 7 年之前
父節點
當前提交
edc897032a
共有 1 個文件被更改,包括 18 次插入3 次删除
  1. 18 3
      src/libraries/sphere10/UVisualGrid.pas

+ 18 - 3
src/libraries/sphere10/UVisualGrid.pas

@@ -397,7 +397,6 @@ uses
     property Options: TVisualGridOptions read FOptions write SetOptions;
     property Canvas: TCanvas read GetCanvas;
     property SelectionType: TSelectionType read FSelectionType write SetSelectionType;
-    // IMPORTANT: set DeselectionType before SelectionType to avoid auto-selected first row
     property DeselectionType: TDeselectionType read FDeselectionType write SetDeselectionType;
     property Selection: TVisualGridSelection read GetSelection;
     property SelectedRows : TArray<Variant> read GetSelectedRows;
@@ -1983,6 +1982,7 @@ var
   LCountOnPage2: Integer;
   LGridUnusedHeight, LPotentialHeight: integer;
   LWasVisible: boolean;
+  LHasFilter: boolean;
 
   function RecalcPageCount: boolean;
   var
@@ -1994,7 +1994,21 @@ var
       PageSize := LCount;
   end;
 
+  function FindProperFilter: boolean;
+  var
+    f: ^TColumnFilter;
+  begin
+    for f in FFilters.Ptr^ do
+      if f.Filter <> vgfSortable then
+        Exit(true);
+    Result := false;
+  end;
+
 begin
+  // if filter is active then vgoAutoHideSearchPanel should be not considered.
+  // Note: vgfSortable is not considered as 'real' filter
+  LHasFilter := (FSearchEdit.Text <> '') and (FFilters.Count > 0) and FindProperFilter;
+
   SetPageIndexEditText(IntToStr(Succ(FPageIndex)));
   FPageCountLabel.Caption := Format('/%d',[FPageCount]);
 
@@ -2012,7 +2026,8 @@ begin
           LGridUnusedHeight := FDrawGrid.ClientHeight - FDrawGrid.GridHeight;
           LPotentialHeight := FBottomPanel.Height + LGridUnusedHeight;
           // vgoAutoHideSearchPanel + AutoPageSize + vgoAutoHidePaging is killer combo :P
-          if (vgoAutoHideSearchPanel in FOptions) and FTopPanel.Visible and not Assigned(FWidgetControl) then
+          if (vgoAutoHideSearchPanel in FOptions) and FTopPanel.Visible and not Assigned(FWidgetControl)
+           and not LHasFilter then
             LPotentialHeight := LPotentialHeight + FTopPanel.Height;
           if FBottomPanel.Visible
            and (FDrawGrid.DefaultRowHeight * LCountOnPage2 <= LPotentialHeight) then
@@ -2041,7 +2056,7 @@ begin
   end;
 
   // show or hide Search Panel (related to option vgoAutoHideSearchPanel)
-  if (vgoAutoHideSearchPanel in FOptions) and (FPageCount in [0,1]) then
+  if (vgoAutoHideSearchPanel in FOptions) and (FPageCount in [0,1]) and not LHasFilter then
   begin
     if FCanSearch then
     begin