- This topic has 2 replies, 2 voices, and was last updated 9 years, 3 months ago by Support.
-
AuthorPosts
-
August 6, 2015 at 2:48 pm #36622JM-DGParticipant
Hi!
I found one annoying thing with the new ShowProgress feature of tsTrackBar.
You can't set a custom value for the progress origin.
It has to be either left or right (depending on either you have reversed true or false).
So I got my hands dirty and implemented it in the sTrackBar.pas file.
Exemple of use : balance, equalizer, etc… Look at picture attached to understand.
If you think this is a good idea to implement in the official release of AlphaControls, pm me for the modified .pas file.
August 6, 2015 at 6:47 pm #53801JM-DGParticipantIf you want to modify the file yourself, here are the modifications :
Code:private
FShowProgressFrom: Integer;
procedure SetShowProgressFrom(Value: Integer);published
property ShowProgressFrom: Integer read FShowProgressFrom write SetShowProgressFrom default 0;Add to TsTrackBar.Create
Code:FShowProgressFrom := 0;Replace procedure TsTrackBar.PaintBar with
Code:procedure TsTrackBar.PaintBar;
var
w, h, i, j, pos: integer;
aRect, sRect: TRect;
CI: TCacheInfo;
begin
aRect := ChannelRect;
i := SkinData.SkinManager.GetMaskIndex(TrackBarNdx, s_SliderChannelMask);
if SkinData.SkinManager.IsValidImgIndex(i) then begin
CI := MakeCacheInfo(FCommonData.FCacheBmp);
pos := SendMessage(Handle, TBM_GETPOS, 0, 0);case Orientation of
trHorizontal: begin
h := HeightOfImage(SkinData.SkinManager.ma) – 1;
w := HeightOf(aRect);
aRect.Top := aRect.Top + (w – h) div 2;
aRect.Bottom := aRect.Top + h;
InflateRect(aRect, -1, 0);
DrawSkinRect(FCommonData.FCacheBmp, aRect, CI, SkinData.SkinManager.ma, integer(ControlIsActive(FCommonData)), True);
if ShowProgress then begin
sRect := aRect;
i := Round(WidthOf(aRect) * (pos – Min) / (Max – Min));
j := Round(WidthOf(aRect) * (ShowProgressFrom – Min) / (Max – Min));
if reversed then
begin
if(pos < ShowProgressFrom)then
begin
sRect.Left := sRect.Right – j;
sRect.Right := sRect.Right – i;
end else
begin
sRect.Left := sRect.Right – i;
sRect.Right := sRect.Right – j;
end;
end else
begin
if(pos < ShowProgressFrom)then
begin
sRect.Right := sRect.Left + j;
sRect.Left := sRect.Left + i;
end else
begin
sRect.Right := sRect.Left + i;
sRect.Left := sRect.Left + j;
end;
end;PaintProgress(sRect, True);
end;
end;trVertical: begin
h := WidthOfImage(SkinData.SkinManager.ma) – 1;
w := WidthOf(aRect);
aRect.Left := aRect.Left + (w – h) div 2;
aRect.Right := aRect.Left + h;
InflateRect(aRect, 0, -1);
DrawSkinRect(FCommonData.FCacheBmp, aRect, CI, SkinData.SkinManager.ma, integer(ControlIsActive(FCommonData)), True);
if ShowProgress then begin
sRect := aRect;
i := Round(HeightOf(aRect) * (pos – Min) / (Max – Min));
j := Round(HeightOf(aRect) * (ShowProgressFrom – Min) / (Max – Min));
if Reversed then
begin
if(pos < ShowProgressFrom)then
begin
sRect.Top := sRect.Bottom – j;
sRect.Bottom := sRect.Bottom – i;
end else
begin
sRect.Top := sRect.Bottom – i;
sRect.Bottom := sRect.Bottom – j;
end;
end else begin
if(pos < ShowProgressFrom)then
begin
sRect.Bottom := sRect.Top + j;
sRect.Top := sRect.Top + i;
end else
begin
sRect.Bottom := sRect.Top + i;
sRect.Top := sRect.Top + j;
end;
end;PaintProgress(sRect, False);
end;
end;
end;
end;if Orientation = trHorizontal then
PaintTicksHor
else
PaintTicksVer;
end;Replace procedure TsTrackBar.StdPaintBar with
Code:procedure TsTrackBar.StdPaintBar(Bmp: TBitmap);
var
i, j, pos: integer;
aRect, sRect: TRect;
{$IFDEF DELPHI7UP}
Details: TThemedElementDetails;
te: TThemedTrackBar;
{$ENDIF}
begin
aRect := ChannelRect;
{$IFDEF DELPHI7UP}
if acThemesEnabled then begin
if Orientation = trVertical then
te := ttbTrack
else
te := ttbTrackVert;Details := acThemeServices.GetElementDetails(te);
acThemeServices.DrawElement(Bmp.Canvas.Handle, Details, aRect);
InflateRect(aRect, -1, -1);
end
else
{$ENDIF}
begin
Frame3D(Bmp.Canvas, aRect, clBtnShadow, clBtnHighlight, 1);
Frame3D(Bmp.Canvas, aRect, cl3DDkShadow, cl3DLight, 1);
FillDC(Bmp.Canvas.Handle, aRect, clWindow);
end;
if ShowProgress then begin
sRect := aRect;
pos := SendMessage(Handle, TBM_GETPOS, 0, 0);
if Orientation = trVertical then begin
i := Round(HeightOf(aRect) * (pos – Min) / (Max – Min));
j := Round(HeightOf(aRect) * (ShowProgressFrom – Min) / (Max – Min));
if Reversed then
begin
if(pos < ShowProgressFrom)then
begin
sRect.Top := sRect.Bottom – j;
sRect.Bottom := sRect.Bottom – i;
end else
begin
sRect.Top := sRect.Bottom – i;
sRect.Bottom := sRect.Bottom – j;
end;
end else begin
if(pos < ShowProgressFrom)then
begin
sRect.Bottom := sRect.Top + j;
sRect.Top := sRect.Top + i;
end else
begin
sRect.Bottom := sRect.Top + i;
sRect.Top := sRect.Top + j;
end;
end;
end
else begin
i := Round(WidthOf(aRect) * (pos – Min) / (Max – Min));
j := Round(WidthOf(aRect) * (ShowProgressFrom – Min) / (Max – Min));
if reversed then
begin
if(pos < ShowProgressFrom)then
begin
sRect.Left := sRect.Right – j;
sRect.Right := sRect.Right – i;
end else
begin
sRect.Left := sRect.Right – i;
sRect.Right := sRect.Right – j;
end;
end else
begin
if(pos < ShowProgressFrom)then
begin
sRect.Right := sRect.Left + j;
sRect.Left := sRect.Left + i;
end else
begin
sRect.Right := sRect.Left + i;
sRect.Left := sRect.Left + j;
end;
end;
end;FillRect32(Bmp, sRect, ColorToRGB(clHighLight));
end;
if Orientation = trHorizontal then
PaintTicksHor
else
PaintTicksVer;
end;Add this procedure
Code:procedure TsTrackBar.SetShowProgressFrom(Value: Integer);
begin
if FShowProgressFrom Value then begin
if Value < Min then Value := Min;
if Value > Max then Value := Max;
FShowProgressFrom := Value;
if not (csLoading in ComponentState) and SkinData.Skinned then
SkinData.Invalidate
end;
end;August 10, 2015 at 3:50 pm #53818SupportKeymasterThank you for a code, I will add it in the nearest release.
-
AuthorPosts
- You must be logged in to reply to this topic.