You've already forked lazarus-ccr
tvplanit/Drag&Drop: Introduce DragMarkerColor.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8915 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -181,6 +181,8 @@ type
|
|||||||
TVpMouseOverItemEvent = procedure(Sender: TObject; Item: TVpNavBtnItem) of object;
|
TVpMouseOverItemEvent = procedure(Sender: TObject; Item: TVpNavBtnItem) of object;
|
||||||
|
|
||||||
TVpCustomNavBar = class(TVpCustomControl)
|
TVpCustomNavBar = class(TVpCustomControl)
|
||||||
|
private
|
||||||
|
FDragMarkerColor: TColor;
|
||||||
protected {private}
|
protected {private}
|
||||||
{property variables}
|
{property variables}
|
||||||
FActiveFolder: Integer;
|
FActiveFolder: Integer;
|
||||||
@ -409,6 +411,7 @@ type
|
|||||||
|
|
||||||
property ActiveItem: Integer read FActiveItem;
|
property ActiveItem: Integer read FActiveItem;
|
||||||
property Containers[Index: Integer]: TVpFolderContainer read GetContainer;
|
property Containers[Index: Integer]: TVpFolderContainer read GetContainer;
|
||||||
|
property DragMarkerColor: TColor read FDragMarkerColor write FDragMarkerColor default clBlack;
|
||||||
property Folders[Index: Integer]: TVpNavFolder read GetFolder;
|
property Folders[Index: Integer]: TVpNavFolder read GetFolder;
|
||||||
property FolderCount: Integer read GetFolderCount;
|
property FolderCount: Integer read GetFolderCount;
|
||||||
property PreviousFolder : Integer read FPreviousFolder;
|
property PreviousFolder : Integer read FPreviousFolder;
|
||||||
@ -428,6 +431,7 @@ type
|
|||||||
property BackgroundMethod;
|
property BackgroundMethod;
|
||||||
property BorderStyle default bsNone;
|
property BorderStyle default bsNone;
|
||||||
property ButtonHeight;
|
property ButtonHeight;
|
||||||
|
property DragMarkerColor;
|
||||||
property DrawingStyle;
|
property DrawingStyle;
|
||||||
property FolderCollection;
|
property FolderCollection;
|
||||||
property Images;
|
property Images;
|
||||||
@ -1103,6 +1107,7 @@ begin
|
|||||||
FBackgroundColor := clWindow;
|
FBackgroundColor := clWindow;
|
||||||
FBackgroundImage := TBitmap.Create;
|
FBackgroundImage := TBitmap.Create;
|
||||||
FBackgroundMethod := bmNormal;
|
FBackgroundMethod := bmNormal;
|
||||||
|
FDragMarkerColor := clBlack;
|
||||||
// FBorderStyle := bsSingle;
|
// FBorderStyle := bsSingle;
|
||||||
FButtonHeight := 0;
|
FButtonHeight := 0;
|
||||||
FActiveFolder := -1;
|
FActiveFolder := -1;
|
||||||
|
@ -46,6 +46,10 @@ type
|
|||||||
nabScrollUpBtn: TSpeedButton;
|
nabScrollUpBtn: TSpeedButton;
|
||||||
nabScrollDownBtn: TSpeedButton;
|
nabScrollDownBtn: TSpeedButton;
|
||||||
nabTopItem: Integer;
|
nabTopItem: Integer;
|
||||||
|
nabDropY: Integer;
|
||||||
|
nabExternalDrag: Boolean;
|
||||||
|
nabFolderAccept: Boolean;
|
||||||
|
nabCursorOverItem: Boolean;
|
||||||
|
|
||||||
FFolderArea: TRect;
|
FFolderArea: TRect;
|
||||||
|
|
||||||
@ -76,6 +80,7 @@ type
|
|||||||
procedure DrawActiveFolderItems(Canvas: TCanvas; var CurPos: Integer);
|
procedure DrawActiveFolderItems(Canvas: TCanvas; var CurPos: Integer);
|
||||||
procedure DrawBottomFolderButtons(Canvas: TCanvas; ARect: TRect;
|
procedure DrawBottomFolderButtons(Canvas: TCanvas; ARect: TRect;
|
||||||
var CurPos: Integer);
|
var CurPos: Integer);
|
||||||
|
procedure DrawDragMarker(Canvas: TCanvas);
|
||||||
procedure DrawTab(Canvas: TCanvas; R: TRect; ATabIndex: Integer);
|
procedure DrawTab(Canvas: TCanvas; R: TRect; ATabIndex: Integer);
|
||||||
procedure DrawTopFolderButtons(Canvas: TCanvas; ARect: TRect;
|
procedure DrawTopFolderButtons(Canvas: TCanvas; ARect: TRect;
|
||||||
DrawFolder: Boolean; var CurPos: Integer);
|
DrawFolder: Boolean; var CurPos: Integer);
|
||||||
@ -129,6 +134,10 @@ begin
|
|||||||
nabScrollUpBtn := TVpNavBarOpener(FNavBar).nabScrollUpBtn;
|
nabScrollUpBtn := TVpNavBarOpener(FNavBar).nabScrollUpBtn;
|
||||||
nabScrollDownBtn := TVpNavBarOpener(FNavBar).nabScrollDownBtn;
|
nabScrollDownBtn := TVpNavBarOpener(FNavBar).nabScrollDownBtn;
|
||||||
nabTopItem := TVpNavBarOpener(FNavBar).nabTopItem;
|
nabTopItem := TVpNavBarOpener(FNavBar).nabTopItem;
|
||||||
|
nabDropY := TVpNavBarOpener(FNavBar).nabDropY;
|
||||||
|
nabExternalDrag := TVpNavBarOpener(FNavBar).nabExternalDrag;
|
||||||
|
nabFolderAccept := TVpNavBarOpener(FNavBar).nabFolderAccept;
|
||||||
|
nabCursorOverItem := TVpNavBarOpener(FNavBar).nabCursorOverItem;
|
||||||
|
|
||||||
FFolderArea := TVpNavBarOpener(FNavBar).nabGetFolderArea(FActiveFolder);
|
FFolderArea := TVpNavBarOpener(FNavBar).nabGetFolderArea(FActiveFolder);
|
||||||
end;
|
end;
|
||||||
@ -491,6 +500,42 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TVpNavBarPainter.DrawDragMarker(Canvas: TCanvas);
|
||||||
|
const
|
||||||
|
MARKERSIZE = 4;
|
||||||
|
MARKERPOS = 3;
|
||||||
|
var
|
||||||
|
scaledMARKERSIZE: Integer;
|
||||||
|
scaledMARKERPOS: Integer;
|
||||||
|
begin
|
||||||
|
if FNavBar.Dragging and (nabDropY <> -1) then
|
||||||
|
begin
|
||||||
|
{ Don't draw the drag marker if we're doing external dragging and the
|
||||||
|
cursor is over an item. }
|
||||||
|
if nabExternalDrag then
|
||||||
|
if not nabFolderAccept or nabCursorOverItem then
|
||||||
|
exit;
|
||||||
|
scaledMARKERSIZE := FNavBar.Scale96ToFont(MARKERSIZE);
|
||||||
|
scaledMARKERPOS := FNavBar.Scale96ToFont(MARKERPOS);
|
||||||
|
Canvas.Pen.Color := FNavBar.DragMarkerColor;
|
||||||
|
Canvas.Brush.Color := FNavBar.DragMarkerColor;
|
||||||
|
Canvas.MoveTo(scaledMARKERSIZE + 1, nabDropY);
|
||||||
|
Canvas.LineTo(FNavBar.ClientWidth - scaledMARKERSIZE - 1, nabDropY);
|
||||||
|
|
||||||
|
//Canvas.Polygon([Point(3, nabDropY+4), Point(7, nabDropY), Point(3, nabDropY-4)]);
|
||||||
|
Canvas.Polygon([
|
||||||
|
Point(scaledMARKERPOS, nabDropY + scaledMARKERSIZE),
|
||||||
|
Point(scaledMARKERPOS + scaledMARKERSIZE, nabDropy),
|
||||||
|
Point(scaledMARKERPOS, nabDropY - scaledMARKERSIZE)
|
||||||
|
]);
|
||||||
|
Canvas.Polygon([
|
||||||
|
Point(FNavBar.ClientWidth - scaledMARKERPOS, nabDropY + scaledMARKERSIZE),
|
||||||
|
Point(FNavBar.ClientWidth - scaledMARKERPOS - scaledMARKERSIZE, nabDropY),
|
||||||
|
Point(FNavBar.ClientWidth - scaledMARKERPOS, nabDropY - scaledMARKERSIZE)
|
||||||
|
]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ Draw regular etched (Win98 style) buttons
|
{ Draw regular etched (Win98 style) buttons
|
||||||
Returns the usable text area inside the tab rect.}
|
Returns the usable text area inside the tab rect.}
|
||||||
function TVpNavBarPainter.DrawEtchedButton(Canvas: TCanvas; R: TRect;
|
function TVpNavBarPainter.DrawEtchedButton(Canvas: TCanvas; R: TRect;
|
||||||
@ -661,7 +706,7 @@ begin
|
|||||||
AItem.IconRect := R;
|
AItem.IconRect := R;
|
||||||
|
|
||||||
if FShowButtons then begin
|
if FShowButtons then begin
|
||||||
DrawItemHighlight(Canvas, R, FActiveItem = AItem.Index);
|
DrawItemHighlight(Canvas, R, (FActiveItem = AItem.Index) and (not FNavBar.Dragging));
|
||||||
if Assigned(FImages) and (AItem.IconIndex >= 0) and (AItem.IconIndex < FImages.Count) then
|
if Assigned(FImages) and (AItem.IconIndex >= 0) and (AItem.IconIndex < FImages.Count) then
|
||||||
begin
|
begin
|
||||||
{$IFDEF LCL}{$IF LCL_FullVersion >= 1090000}
|
{$IFDEF LCL}{$IF LCL_FullVersion >= 1090000}
|
||||||
@ -713,7 +758,7 @@ begin
|
|||||||
Exit; // Returns false
|
Exit; // Returns false
|
||||||
|
|
||||||
if FShowButtons then begin
|
if FShowButtons then begin
|
||||||
DrawItemHighlight(Canvas, R, FActiveItem = AItem.Index);
|
DrawItemHighlight(Canvas, R, (FActiveItem = AItem.Index) and (not FNavBar.Dragging));
|
||||||
if Assigned(FImages) then begin
|
if Assigned(FImages) then begin
|
||||||
{$IFDEF LCL}{$IF LCL_FullVersion >= 1090000}
|
{$IFDEF LCL}{$IF LCL_FullVersion >= 1090000}
|
||||||
with TVpNavBarOpener(FNavBar) do begin
|
with TVpNavBarOpener(FNavBar) do begin
|
||||||
@ -1030,6 +1075,9 @@ begin
|
|||||||
{ Draw the folder buttons at the bottom }
|
{ Draw the folder buttons at the bottom }
|
||||||
DrawBottomFolderButtons(DrawBmp.Canvas, MyRect, CurPos);
|
DrawBottomFolderButtons(DrawBmp.Canvas, MyRect, CurPos);
|
||||||
|
|
||||||
|
{ Draw the drag marker }
|
||||||
|
DrawDragMarker(DrawBmp.Canvas);
|
||||||
|
|
||||||
{ Copy the buffer bitmap to the control }
|
{ Copy the buffer bitmap to the control }
|
||||||
FNavBar.Canvas.CopyMode := cmSrcCopy;
|
FNavBar.Canvas.CopyMode := cmSrcCopy;
|
||||||
FNavBar.Canvas.CopyRect(MyRect, DrawBmp.Canvas, Rect(0, 0, DrawBmp.Width, DrawBmp.Height));
|
FNavBar.Canvas.CopyRect(MyRect, DrawBmp.Canvas, Rect(0, 0, DrawBmp.Width, DrawBmp.Height));
|
||||||
|
Reference in New Issue
Block a user