Skip to content

Add horizontal and vertical padding methods.#2655

Merged
hecrj merged 2 commits intoiced-rs:masterfrom
hydra:add-horizontal-and-vertical-padding-to-api
Nov 18, 2025
Merged

Add horizontal and vertical padding methods.#2655
hecrj merged 2 commits intoiced-rs:masterfrom
hydra:add-horizontal-and-vertical-padding-to-api

Conversation

@hydra
Copy link
Contributor

@hydra hydra commented Oct 31, 2024

e.g.

let status_bar = container(text("status bar area"))
    .padding(padding::horizontal(3));

the point of this PR is:

  • to improve the API for everyone.
  • to make is so that the number, 3 in the example above, is only specified once.
  • so that default values do not have to be specified or overridden.

currently the alternatives are as follows:

1 - specification of vertical and horizontal

let status_bar = container(text("status bar area"))
    .padding([0, 3]);
  • the reader does know the order and has to refer to the API docs,
  • the intention is not clear, is the intention to override the default top/bottom to 0 and set the left/right to 3, or is the intention just to add horizontal padding?

2 - use the struct

let status_bar = container(text("status bar area"))
    .padding(Padding { left: 3, right: 3, ..padding::default() });
  • way to verbose
  • not readable
  • used the word 'padding' 3 times on the same line.
  • duplicates the 3 value.

there may be more alternatives, but hopefully the above goes some way to understanding why i feel horizontal and vertical methods are useful.

@hecrj hecrj force-pushed the add-horizontal-and-vertical-padding-to-api branch from 350a945 to 5b029ae Compare November 18, 2025 21:39
@hecrj hecrj added this to the 0.14 milestone Nov 18, 2025
@hecrj hecrj added feature New feature or request layout addition labels Nov 18, 2025
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hecrj hecrj enabled auto-merge November 18, 2025 21:40
@hecrj hecrj merged commit 08d1979 into iced-rs:master Nov 18, 2025
17 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition feature New feature or request layout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants