From 0abdb4de1ed716c0d3ed1a20e82eb7f0516eb443 Mon Sep 17 00:00:00 2001 From: rich2014 Date: Tue, 13 Aug 2024 13:38:40 +0800 Subject: [PATCH 1/3] Cocoa/ListView: Icon settings Improved --- lcl/interfaces/cocoa/cocoacollectionview.pas | 3 ++- lcl/interfaces/cocoa/cocoatables.pas | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoacollectionview.pas b/lcl/interfaces/cocoa/cocoacollectionview.pas index 0a660bc1f8..f76b9840ba 100644 --- a/lcl/interfaces/cocoa/cocoacollectionview.pas +++ b/lcl/interfaces/cocoa/cocoacollectionview.pas @@ -619,7 +619,7 @@ begin itemView.item:= self; imageControl:= NSImageView.alloc.initWithFrame( NSZeroRect ); - imageControl.cell.setImageScaling( NSImageScaleProportionallyUpOrDown ); + imageControl.setImageScaling( NSImageScaleProportionallyUpOrDown ); self.setImageView( imageControl ); itemView.addSubview( imageControl ); @@ -647,6 +647,7 @@ begin _checkBox:= nil; end; + self.imageView.setImage( nil ); self.view.removeFromSuperview; end; diff --git a/lcl/interfaces/cocoa/cocoatables.pas b/lcl/interfaces/cocoa/cocoatables.pas index 39b862665f..8102fc9928 100644 --- a/lcl/interfaces/cocoa/cocoatables.pas +++ b/lcl/interfaces/cocoa/cocoatables.pas @@ -975,7 +975,7 @@ begin Exit; imageControl:= NSImageView.alloc.initWithFrame( NSZeroRect ); - imageControl.cell.setImageScaling( NSImageScaleProportionallyUpOrDown ); + imageControl.setImageScaling( NSImageScaleProportionallyUpOrDown ); self.setImageView( imageControl ); self.addSubview( imageControl ); end; From 692a8519757c34ab05cd7b7b3b88c7bbacf98f11 Mon Sep 17 00:00:00 2001 From: rich2014 Date: Tue, 13 Aug 2024 13:47:07 +0800 Subject: [PATCH 2/3] Cocoa/ListView: focus the ListView after clicking the checkBox --- lcl/interfaces/cocoa/cocoacollectionview.pas | 4 +++- lcl/interfaces/cocoa/cocoatables.pas | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoacollectionview.pas b/lcl/interfaces/cocoa/cocoacollectionview.pas index f76b9840ba..a063b9496f 100644 --- a/lcl/interfaces/cocoa/cocoacollectionview.pas +++ b/lcl/interfaces/cocoa/cocoacollectionview.pas @@ -605,8 +605,10 @@ begin indexPath:= cv.indexPathForItem( self ); row:= indexPath.item; cv.callback.SetItemCheckedAt( row, 0, sender.state ); - if sender.state = NSOnState then + if sender.state = NSOnState then begin cv.selectOneItemByIndex( row, True ); + self.view.window.makeFirstResponder( self.collectionView ); + end; end; procedure TCocoaCollectionItem.loadView; diff --git a/lcl/interfaces/cocoa/cocoatables.pas b/lcl/interfaces/cocoa/cocoatables.pas index 8102fc9928..5516aee4a8 100644 --- a/lcl/interfaces/cocoa/cocoatables.pas +++ b/lcl/interfaces/cocoa/cocoatables.pas @@ -1184,8 +1184,8 @@ begin callback.SetItemCheckedAt(row, 0, sender.state); if sender.state = NSOnState then begin self.selectOneItemByIndex(row, True); + self.window.makeFirstResponder( self ); end; - reloadDataForRow_column(row, 0); end; { TCocoaWSListView_TableViewHandler } From 15feb49e175fa23b1a12d8cc74635c5a43d9e08b Mon Sep 17 00:00:00 2001 From: rich2014 Date: Tue, 13 Aug 2024 14:41:03 +0800 Subject: [PATCH 3/3] Cocoa/ListView: in vsIcon, item layout improved --- lcl/interfaces/cocoa/cocoacollectionview.pas | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoacollectionview.pas b/lcl/interfaces/cocoa/cocoacollectionview.pas index a063b9496f..1132e725d1 100644 --- a/lcl/interfaces/cocoa/cocoacollectionview.pas +++ b/lcl/interfaces/cocoa/cocoacollectionview.pas @@ -351,8 +351,8 @@ begin if cv.iconSize.Height < 32 then cv.iconSize.Height:= 32; - cv.itemSize.Width:= 10 + baseSize.Width + 10; - cv.itemSize.Height:= 10 + baseSize.Height + 2 + 14 + 10; + cv.itemSize.Width:= 10 + cv.iconSize.Width + 10; + cv.itemSize.Height:= 10 + cv.iconSize.Height + 2 + 14 + 10; if cv.itemSize.Width < 64 then cv.itemSize.Width:= 64; if cv.itemSize.Height < 68 then @@ -384,7 +384,7 @@ begin aFrame.size.height:= 15; if Assigned(checkBox) then aFrame.origin.x:= aFrame.origin.x + 24; - aFrame.size.width:= cv.itemSize.Width - aFrame.origin.x - 4; + aFrame.size.width:= cv.itemSize.Width - aFrame.origin.x; cocoaItem.textField.setAlignment( NSTextAlignmentCenter ); cocoaItem.textField.setFrame( aFrame ); @@ -401,7 +401,8 @@ procedure TCocoaListView_CollectionView_LargeIconHandler.onAdjustTextEditorRect( var aFrame: NSRect); begin aFrame.origin.y:= aFrame.origin.y - 1; - aFrame.size.width:= aFrame.size.width + 2; + aFrame.origin.x:= aFrame.origin.x + 2; + aFrame.size.width:= aFrame.size.width - 4; end; { TCocoaListView_CollectionView_SmallIconHandler }