Recent

Author Topic: Follow up on New component SuperPanel  (Read 902 times)

Josh

  • Hero Member
  • *****
  • Posts: 1363
Follow up on New component SuperPanel
« on: January 29, 2025, 12:03:46 pm »
Hi
Following on from my initial SuperPanel
https://forum.lazarus.freepascal.org/index.php/topic,69908.msg544109.html#msg544109

Runtime resizeable, dragable, heading, min/max/close buttons, lots of coloring options etc.

I have added quite a bit more, min,max,close buttons can be on right or left side.
Resize controls can be on right or both sides, can adjust many parameters.

I have only tested on Windows, so other OS's & widgetset tests would be very helpful.
Any bugs, ideas also welcome.

Enjoy

edit
Just noticed the the zip didnt attach, so trying again.
pic of  test1, multiple panels, if panel has a heading and user moveable is true you can drag it around, if panel has diag lines bottom right then it is resizeable.
it appears in standard palletee red icon.
« Last Edit: January 30, 2025, 02:40:06 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1363
Re: Follow up on New component SuperPanel
« Reply #1 on: January 30, 2025, 02:31:24 pm »
Found a Bug, when buttons did not have a border drawn around them, the hover effect did not work

Fixed version 0.2.12
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

lainz

  • Hero Member
  • *****
  • Posts: 4691
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: Follow up on New component SuperPanel
« Reply #2 on: January 30, 2025, 02:37:57 pm »
Hi. Maybe you can create a github repository for the package?

Josh

  • Hero Member
  • *****
  • Posts: 1363
Re: Follow up on New component SuperPanel
« Reply #3 on: February 05, 2025, 07:18:32 pm »
Hi

Update of SuperPanel.

The close button now has its own event triggered when clicked.

added macos style of buttons options, which are filled circles drawn using a modified Xiaolin Wu's algorithm for antialliasing.

Example 1 is in the pcakage.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

d2010

  • Full Member
  • ***
  • Posts: 120
Re: Follow up on New component SuperPanel
« Reply #4 on: February 05, 2025, 07:54:59 pm »
You make these update
Code: [Select]
var
  radius,dx,xl,yl,p,cx,cy:Integer;
  r,g,b:Byte;
  DarkenFactor,Distance,py:Double;
Begin
You can make update/add.
Code: [Select]
Begin
     radius:=00;
     dx:=00;
     p:=000;
     cx:=00;
    cy:=000'
End;
This Line
  radius:=Min((x2-x1) div 2,(y2-y1) div 2);
With Line
  radius:=Min(x2-x1), (y2-y1));
  radius:=radius div 2;
This Line
    dx:=Round(Sqrt(Sqr(radius)-Sqr(yl)));
  for yl:=-radius to radius do
  begin
    py:=Sqr(yl);
    dx:=Round(Sqrt(Sqr(radius)-Sqr(yl)));
    for xl:=-dx to dx do
With Line
   dx:=Round(Sqrt(Sqr(radius)-py));

This Line
  for yl:=-radius to radius do
  begin
    py:=Sqr(yl);
    dx:=Round(Sqrt(Sqr(radius)-Sqr(yl)));
    for xl:=-dx to dx do
      Begin ...
     End
With Line
  for yl:=-radius to radius do
  begin
    py:=Sqr(yl);
    dx:=Round(Sqrt(Sqr(radius)-Sqr(yl)));
   if  (cy+yl>=y1) and (cy+yl<=y2) then for xl:=-dx to dx do 
    begin  ....

This Line...
// Fill a circle using a modified Xiaolin Wu's algorithm
With Line
  MyAbout:='About DB "Fill a circle using a modified Xiaolin Wu's algorithm"';

« Last Edit: February 05, 2025, 07:56:49 pm by d2010 »

Josh

  • Hero Member
  • *****
  • Posts: 1363
Re: Follow up on New component SuperPanel
« Reply #5 on: February 05, 2025, 08:28:24 pm »
Hi
Moded proc should be better optimized and better var names.
Code: Pascal  [Select][+][-]
  1. procedure TSuperPanel.DrawWuCircle(X1,Y1,X2,Y2:Integer;AColor:TColor);
  2. // Fill a circle using a modified Xiaolin Wu's algorithm
  3. var
  4.   Radius,PreComputeMaximumX,xLoop,yLoop,CenterX,CenterY:Integer;
  5.   R,G,B:Byte;
  6.   DarkenFactor,Distance,DistanceFromCenter,PreComputeDistanceFromCenterY:Double;
  7. begin
  8.   RedGreenBlue(Acolor,R,G,B);
  9.   CenterX:=(X1+X2) div 2;
  10.   CenterY:=(Y1+Y2) div 2;
  11.   Radius:=Min((X2-X1) div 2,(Y2-Y1) div 2);
  12.   for yLoop:=-Radius to Radius do
  13.   begin
  14.     PreComputeDistanceFromCenterY:=Sqr(yLoop);
  15.     PreComputeMaximumX:=Round(Sqrt(Sqr(Radius)-PreComputeDistanceFromCenterY));
  16.     for xLoop:=-PreComputeMaximumX to PreComputeMaximumX do
  17.     begin
  18.       DistanceFromCenter:=Sqrt(Sqr(xLoop)+PreComputeDistanceFromCenterY);
  19.       if round(DistanceFromCenter)<=Radius then
  20.       begin
  21.         Distance:=DistanceFromCenter/Radius;
  22.         DarkenFactor:=1-(0.25*Distance);
  23.         if (CenterX+xLoop>=X1) and (CenterX+xLoop<=X2) and (CenterY+yLoop>=Y1) and (CenterY+yLoop<=Y2) then Canvas.Pixels[CenterX+xLoop,CenterY+yLoop]:=RGBToColor(Round(R*DarkenFactor),Round(G*DarkenFactor),Round(B*DarkenFactor));
  24.       end;
  25.     end;
  26.   end;
  27. end;
« Last Edit: February 05, 2025, 09:02:15 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

 

TinyPortal © 2005-2018