Skip to content

Commit

Permalink
Linkbar release 1.6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ATGH15102AFMLD committed Mar 24, 2018
1 parent 94afd87 commit 8236616
Show file tree
Hide file tree
Showing 45 changed files with 4,226 additions and 2,129 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


![Delphi](https://img.shields.io/badge/Delphi-XE3-red.svg)
![Windows](https://img.shields.io/badge/Windiws-Vista--10-blue.svg)
![Windows](https://img.shields.io/badge/Windows-Vista--10-blue.svg)
![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)


Expand Down
2 changes: 1 addition & 1 deletion components/ColorPicker/ColorPicker.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object frmColorPicker: TfrmColorPicker
Left = 32
Top = 5
Width = 137
Height = 21
Height = 24
Alignment = taCenter
CharCase = ecUpperCase
MaxLength = 8
Expand Down
45 changes: 20 additions & 25 deletions components/ColorPicker/ColorPicker.pas
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{*******************************************************}
{ Linkbar - Windows desktop toolbar }
{ Copyright (c) 2010-2017 Asaq }
{ Copyright (c) 2010-2018 Asaq }
{*******************************************************}

unit ColorPicker;

interface

{$R-}

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ImgList, StdCtrls, Math, Buttons;
Expand Down Expand Up @@ -205,9 +207,6 @@ procedure TfrmColorPicker.PaintColorPnl;

PaintAlphaColor;

imgColor.Canvas.Pen.Color := clBlack;
imgColor.Canvas.Brush.Style := bsClear;

if not TextEnter
then editColor.Text := IntToHex(Cardinal(NewColor), 8);
end;
Expand Down Expand Up @@ -253,12 +252,7 @@ procedure TfrmColorPicker.L10n;
end;

procedure TfrmColorPicker.FormCreate(Sender: TObject);
const
Colors: array[0..15] of TColor = (clBlack, clWhite, clGray, clSilver,
clMaroon, clRed, clGreen, clLime, clOlive, clYellow, clNavy, clBlue,
clPurple, clFuchsia, clTeal, clAqua);
var
i: Integer;
var i: Integer;
begin
L10n;

Expand Down Expand Up @@ -449,7 +443,8 @@ procedure TfrmColorPicker.imgColorMouseDown(Sender: TObject;
procedure TfrmColorPicker.PaintColorHue;
var
Row: PRGBArray;
slMain, slSize, slPtr: Integer;
slMain, slPtr: UIntPtr;
slSize: IntPtr;
x, y, w, h: Integer;
m1, q1, q2, q3, s1, s2: Integer;
r, g, b: Byte;
Expand All @@ -466,8 +461,8 @@ procedure TfrmColorPicker.PaintColorHue;
SetLength(LUT, w + 1);
for x := 0 to w do
LUT[x] := MulDiv(255, x, w);
slMain := Integer(HBoxBmp.ScanLine[0]);
slSize := Integer(HBoxBmp.ScanLine[1]) - slMain;
slMain := UIntPtr(HBoxBmp.ScanLine[0]);
slSize := UIntPtr(HBoxBmp.ScanLine[1]) - slMain;
slPtr := slMain;
for y := 0 to h do
begin
Expand Down Expand Up @@ -511,7 +506,7 @@ procedure TfrmColorPicker.PaintHueBar;
procedure TfrmColorPicker.PaintAlphaColor;
var
Row: PRGBArray;
RowOff: Integer;
RowOff: IntPtr;
x, y, a: Integer;
bool: Boolean;
c1, c2, c3: TRGB;
Expand All @@ -523,7 +518,7 @@ procedure TfrmColorPicker.PaintAlphaColor;
c2.G := 255;
c2.B := 255;
Row := PRGBArray(ColorBmp.ScanLine[0]);
RowOff := Integer(ColorBmp.ScanLine[1]) - Integer(ColorBmp.ScanLine[0]);
RowOff := UIntPtr(ColorBmp.ScanLine[1]) - UIntPtr(Row);
a := 255 - OldColor.A;
c3.b := OldColor.B;
c3.g := OldColor.G;
Expand All @@ -538,9 +533,9 @@ procedure TfrmColorPicker.PaintAlphaColor;
c3.g := NewColor.G;
c3.b := NewColor.B;
end;
c1.R := a * (0 - c3.r) shr 8 + c3.r;
c1.G := a * (0 - c3.g) shr 8 + c3.g;
c1.B := a * (0 - c3.b) shr 8 + c3.b;
c1.R := a * (164 - c3.r) shr 8 + c3.r;
c1.G := a * (164 - c3.g) shr 8 + c3.g;
c1.B := a * (164 - c3.b) shr 8 + c3.b;
c2.R := a * (255 - c3.r) shr 8 + c3.r;
c2.G := a * (255 - c3.g) shr 8 + c3.g;
c2.B := a * (255 - c3.b) shr 8 + c3.b;
Expand All @@ -553,7 +548,7 @@ procedure TfrmColorPicker.PaintAlphaColor;
else
Row[x] := c2;
end;
Row := PRGBArray(Integer(Row) + RowOff);
Row := PRGBArray(UIntPtr(Row) + RowOff);
end;

imgColor.Canvas.StretchDraw(Rect(0, 0, imgColor.Width, imgColor.Height), ColorBmp);
Expand All @@ -562,7 +557,7 @@ procedure TfrmColorPicker.PaintAlphaColor;
procedure TfrmColorPicker.PaintAlphaBar;
var
Row: PRGBArray;
RowOff: Integer;
RowOff: IntPtr;
x, y, a: Integer;
bool: Boolean;
c1, c2: TRGB;
Expand All @@ -574,14 +569,14 @@ procedure TfrmColorPicker.PaintAlphaBar;
c2.G := 255;
c2.B := 255;
Row := PRGBArray(ABarBmp.ScanLine[0]);
RowOff := Integer(ABarBmp.ScanLine[1]) - Integer(ABarBmp.ScanLine[0]);
RowOff := UIntPtr(ABarBmp.ScanLine[1]) - UIntPtr(Row);
for y := 0 to ABarBmp.Height - 1 do
begin
bool := (y and 4 = 0);
a := 255 - MulDiv(255, y, AlpBarHeight);
c1.R := a * (0 - NewColor.R) shr 8 + NewColor.r;
c1.G := a * (0 - NewColor.G) shr 8 + NewColor.g;
c1.B := a * (0 - NewColor.B) shr 8 + NewColor.b;
c1.R := a * (164 - NewColor.R) shr 8 + NewColor.r;
c1.G := a * (164 - NewColor.G) shr 8 + NewColor.g;
c1.B := a * (164 - NewColor.B) shr 8 + NewColor.b;
c2.R := a * (255 - NewColor.r) shr 8 + NewColor.r;
c2.G := a * (255 - NewColor.g) shr 8 + NewColor.g;
c2.B := a * (255 - NewColor.b) shr 8 + NewColor.b;
Expand All @@ -594,7 +589,7 @@ procedure TfrmColorPicker.PaintAlphaBar;
else
Row[x] := c2;
end;
Row := PRGBArray(Integer(Row) + RowOff);
Row := PRGBArray(UIntPtr(Row) + RowOff);
end;

imgAlpha.Canvas.StretchDraw(Rect(0, 0, imgAlpha.Width, imgAlpha.Height), ABarBmp);
Expand Down
89 changes: 49 additions & 40 deletions components/ColorPicker/ColorUtils.pas
Original file line number Diff line number Diff line change
@@ -1,79 +1,88 @@
{*******************************************************}
{ Linkbar - Windows desktop toolbar }
{ Copyright (c) 2010-2017 Asaq }
{ Copyright (c) 2010-2018 Asaq }
{*******************************************************}

unit ColorUtils;

interface

uses
Graphics;
Vcl.Graphics;

procedure RGBtoHSB (const cRed, cGreen, cBlue: Byte; var H,S,B: Word);
procedure HSBtoRGB (const H,S,B: Word; var cRed, cGreen, cBlue : Byte);
procedure RGBtoHSB(const cRed, cGreen, cBlue: Byte; var H,S,B: Word);
procedure HSBtoRGB(const H,S,B: Word; var cRed, cGreen, cBlue : Byte);

implementation

procedure MinMax(const i,j,k: Byte; var min: Integer; var max: Word); Inline;
begin
if i > j then begin
if i > j
then begin
if i > k then max := i else max := k;
if j < k then min := j else min := k
end else begin
end
else begin
if j > k then max := j else max := k;
if i < k then min := i else min := k
end;
end;

procedure RGBtoHSB (const cRed, cGreen, cBlue: Byte; var H, S, B: Word);
var
Delta, MinValue, tmpH: Integer;
procedure RGBtoHSB(const cRed, cGreen, cBlue: Byte; var H, S, B: Word);
var Delta, MinValue, tmpH: Integer;
begin
tmpH:= 0;
MinMax(cRed, cGreen, cBlue, MinValue, B);
Delta := B - MinValue;
if B = 0 then S := 0 else S := (255 * Delta) div B;
if S = 0 then tmpH := 0
if (B = 0)
then S := 0
else S := (255 * Delta) div B;
if (S = 0)
then tmpH := 0
else begin
if cRed = B then tmpH := (60 * (cGreen - cBlue)) div Delta
else
if cGreen = B then tmpH := 120 + (60 * (cBlue - cRed)) div Delta
else
if cBlue = B then tmpH := 240 + (60 * (cRed - cGreen)) div Delta;
if tmpH < 0 then tmpH := tmpH + 360;
if (cRed = B)
then tmpH := (60 * (cGreen - cBlue)) div Delta
else if (cGreen = B)
then tmpH := 120 + (60 * (cBlue - cRed)) div Delta
else if (cBlue = B)
then tmpH := 240 + (60 * (cRed - cGreen)) div Delta;

if (tmpH < 0)
then tmpH := tmpH + 360;
end;
H := tmpH;
end;

procedure HSBtoRGB (const H, S, B: Word; var cRed, cGreen, cBlue : Byte);
const
divisor: Integer = 255*60;
var
f : Integer;
hTemp: Integer;
p,q,t: Integer;
VS : Integer;
procedure HSBtoRGB(const H, S, B: Word; var cRed, cGreen, cBlue : Byte);
const divisor: Integer = 255*60;
var f: Integer;
hTemp: Integer;
p, q, t: Integer;
VS: Integer;
begin
if s = 0 then begin
if (s = 0)
then begin
cRed:= B;
cGreen:= B;
cBlue:= B;
end else begin
if H = 360 then hTemp:= 0 else hTemp:= H;
f:= hTemp mod 60;
VS:= B*S;
p:= B - VS div 255;
q:= B - (VS*f) div divisor;
t:= B - (VS*(60 - f)) div divisor;
hTemp:= hTemp div 60;
end
else begin
if (H = 360)
then hTemp := 0
else hTemp := H;
f := hTemp mod 60;
VS := B * S;
p := B - VS div 255;
q := B - (VS * f) div divisor;
t := B - (VS * (60 - f)) div divisor;
hTemp := hTemp div 60;
case hTemp of
0: begin cRed := B; cGreen := t; cBlue := p end;
1: begin cRed := q; cGreen := B; cBlue := p end;
2: begin cRed := p; cGreen := B; cBlue := t end;
3: begin cRed := p; cGreen := q; cBlue := B end;
4: begin cRed := t; cGreen := p; cBlue := B end;
5: begin cRed := B; cGreen := p; cBlue := q end;
0: begin cRed := B; cGreen := t; cBlue := p end;
1: begin cRed := q; cGreen := B; cBlue := p end;
2: begin cRed := p; cGreen := B; cBlue := t end;
3: begin cRed := p; cGreen := q; cBlue := B end;
4: begin cRed := t; cGreen := p; cBlue := B end;
5: begin cRed := B; cGreen := p; cBlue := q end;
end;
end;
end;
Expand Down
10 changes: 5 additions & 5 deletions components/DirWatch/Cromis.DirectoryWatch.pas
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interface
const
cShutdownTimeout = 3000;
cFileWaitTimeout = 0;

type
// the filters that control when the watch is triggered
TWatchOption = (woFileName, woDirName, woAttributes, woSize, woLastWrite,
Expand Down Expand Up @@ -217,8 +217,8 @@ procedure WaitForFileReady(const FileName: string; const Timeout: Cardinal);

function ErrorCodeToMessage(AErrorCode: Cardinal): string; inline;
begin
//Result := SysErrorMessage(AErrorCode);
Result := ':(';
Result := SysErrorMessage(AErrorCode);
//Result := ':(';
end;

procedure TDirWatchThread.Execute;
Expand Down Expand Up @@ -366,9 +366,9 @@ destructor TDirWatchThread.Destroy;

CancelIo(FDirHandle);

if FDirHandle <> INVALID_HANDLE_VALUE
if FDirHandle <> INVALID_HANDLE_VALUE
then CloseHandle(FDirHandle);
if Assigned(FIOResult)
if Assigned(FIOResult)
then FreeMemory(FIOResult);

inherited Destroy;
Expand Down
Loading

0 comments on commit 8236616

Please sign in to comment.