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:
@@ -52,6 +52,10 @@ procedure ApplyDarkTheme;
|
|||||||
function FlatButton(AParent: TFmxObject; const AText: string;
|
function FlatButton(AParent: TFmxObject; const AText: string;
|
||||||
AOnClick: TNotifyEvent; APrimary: Boolean = False): TRectangle;
|
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.
|
/// Le libelle est un enfant du bouton, retenu par TagObject.
|
||||||
procedure SetButtonText(AButton: TRectangle; const AText: string);
|
procedure SetButtonText(AButton: TRectangle; const AText: string);
|
||||||
procedure SetButtonEnabled(AButton: TRectangle; AEnabled: Boolean);
|
procedure SetButtonEnabled(AButton: TRectangle; AEnabled: Boolean);
|
||||||
@@ -101,6 +105,10 @@ type
|
|||||||
procedure Up(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
|
procedure Up(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
|
||||||
X, Y: Single);
|
X, Y: Single);
|
||||||
procedure Leave(Sender: TObject);
|
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;
|
end;
|
||||||
|
|
||||||
procedure TPressFeedback.Down(Sender: TObject; Button: TMouseButton;
|
procedure TPressFeedback.Down(Sender: TObject; Button: TMouseButton;
|
||||||
@@ -120,6 +128,16 @@ begin
|
|||||||
if Sender is TRectangle then TRectangle(Sender).Opacity := 1;
|
if Sender is TRectangle then TRectangle(Sender).Opacity := 1;
|
||||||
end;
|
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;
|
function Surface(AParent: TFmxObject): TRectangle;
|
||||||
begin
|
begin
|
||||||
Result := TRectangle.Create(AParent);
|
Result := TRectangle.Create(AParent);
|
||||||
@@ -160,10 +178,9 @@ var
|
|||||||
begin
|
begin
|
||||||
Result := TRectangle.Create(AParent);
|
Result := TRectangle.Create(AParent);
|
||||||
Result.Parent := AParent;
|
Result.Parent := AParent;
|
||||||
// Pilule : l'arrondi vaut la moitie de la hauteur usuelle d'un bouton. Tout
|
// Pilule : l'arrondi vaut exactement la moitie de la hauteur, et se
|
||||||
// ce qui se touche est arrondi ainsi dans la reference.
|
// recalcule quand elle change (voir TPressFeedback.Resized). Tout ce qui se
|
||||||
Result.XRadius := 26;
|
// touche est arrondi ainsi dans la reference.
|
||||||
Result.YRadius := 26;
|
|
||||||
Result.Cursor := crHandPoint;
|
Result.Cursor := crHandPoint;
|
||||||
Result.Stroke.Kind := TBrushKind.None;
|
Result.Stroke.Kind := TBrushKind.None;
|
||||||
// La difference entre principal et secondaire tient a l'opacite du blanc,
|
// La difference entre principal et secondaire tient a l'opacite du blanc,
|
||||||
@@ -191,6 +208,18 @@ begin
|
|||||||
Result.OnMouseDown := LFeedback.Down;
|
Result.OnMouseDown := LFeedback.Down;
|
||||||
Result.OnMouseUp := LFeedback.Up;
|
Result.OnMouseUp := LFeedback.Up;
|
||||||
Result.OnMouseLeave := LFeedback.Leave;
|
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;
|
end;
|
||||||
|
|
||||||
procedure SetButtonText(AButton: TRectangle; const AText: string);
|
procedure SetButtonText(AButton: TRectangle; const AText: string);
|
||||||
|
|||||||
@@ -571,6 +571,9 @@ begin
|
|||||||
Result.Margins.Rect := RectF(8, 6, 0, 6);
|
Result.Margins.Rect := RectF(8, 6, 0, 6);
|
||||||
Result.Width := 96;
|
Result.Width := 96;
|
||||||
Result.Tag := ATag;
|
Result.Tag := ATag;
|
||||||
|
// Arrondi modere : ces boutons sont bas et larges, une pilule les rendait
|
||||||
|
// ovales. La forme pleinement arrondie reste aux actions principales.
|
||||||
|
SetCornerRadius(Result, 14);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm8.BuildDetail;
|
procedure TForm8.BuildDetail;
|
||||||
|
|||||||
Reference in New Issue
Block a user