fix(android): the Copy buttons were ellipses, not pills

A fixed radius of 26 on a button only 40 tall makes the corners meet, and the shape stops being a rounded rectangle at all. The radius is now recomputed from the height whenever it changes - the height is set after creation, which is why a constant could never be right.

And the small row buttons take a moderate radius rather than the full pill: they are low and wide, and a stadium shape read as an oval. The fully rounded form stays where the reference puts it, on the main actions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-08-16 22:06:09 +01:00
parent 27a7a322d6
commit 2e2ded1146
2 changed files with 36 additions and 4 deletions
+33 -4
View File
@@ -52,6 +52,10 @@ procedure ApplyDarkTheme;
function FlatButton(AParent: TFmxObject; const AText: string;
AOnClick: TNotifyEvent; APrimary: Boolean = False): TRectangle;
/// Fixe un arrondi choisi, au lieu de la pilule automatique. Pour les petits
/// boutons de ligne, qu'une pilule rendrait presque ovales.
procedure SetCornerRadius(AButton: TRectangle; AValue: Single);
/// Le libelle est un enfant du bouton, retenu par TagObject.
procedure SetButtonText(AButton: TRectangle; const AText: string);
procedure SetButtonEnabled(AButton: TRectangle; AEnabled: Boolean);
@@ -101,6 +105,10 @@ type
procedure Up(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
X, Y: Single);
procedure Leave(Sender: TObject);
/// L'arrondi se recalcule a chaque changement de taille : la hauteur est
/// posee APRES la creation, et un arrondi fixe superieur a la moitie de
/// celle-ci transforme le bouton en ellipse.
procedure Resized(Sender: TObject);
end;
procedure TPressFeedback.Down(Sender: TObject; Button: TMouseButton;
@@ -120,6 +128,16 @@ begin
if Sender is TRectangle then TRectangle(Sender).Opacity := 1;
end;
procedure TPressFeedback.Resized(Sender: TObject);
var
LR: TRectangle;
begin
if not (Sender is TRectangle) then Exit;
LR := TRectangle(Sender);
LR.XRadius := LR.Height / 2;
LR.YRadius := LR.Height / 2;
end;
function Surface(AParent: TFmxObject): TRectangle;
begin
Result := TRectangle.Create(AParent);
@@ -160,10 +178,9 @@ var
begin
Result := TRectangle.Create(AParent);
Result.Parent := AParent;
// Pilule : l'arrondi vaut la moitie de la hauteur usuelle d'un bouton. Tout
// ce qui se touche est arrondi ainsi dans la reference.
Result.XRadius := 26;
Result.YRadius := 26;
// Pilule : l'arrondi vaut exactement la moitie de la hauteur, et se
// recalcule quand elle change (voir TPressFeedback.Resized). Tout ce qui se
// touche est arrondi ainsi dans la reference.
Result.Cursor := crHandPoint;
Result.Stroke.Kind := TBrushKind.None;
// La difference entre principal et secondaire tient a l'opacite du blanc,
@@ -191,6 +208,18 @@ begin
Result.OnMouseDown := LFeedback.Down;
Result.OnMouseUp := LFeedback.Up;
Result.OnMouseLeave := LFeedback.Leave;
Result.OnResize := LFeedback.Resized;
LFeedback.Resized(Result);
end;
procedure SetCornerRadius(AButton: TRectangle; AValue: Single);
begin
if AButton = nil then Exit;
// Detache le recalcul automatique, sinon la prochaine mise en page le
// ramenerait a la pilule.
AButton.OnResize := nil;
AButton.XRadius := AValue;
AButton.YRadius := AValue;
end;
procedure SetButtonText(AButton: TRectangle; const AText: string);