Skip to content

FloatingButton: Rework content sizing, styling, add fully-round mode

ivan tkachenko requested to merge work/ratijas/floating-button into master

As it currently stands, FloatingButton is a little bit rounded, but not a full circle. Forcing it into being a circle without adjusting padding leads to poor visuals, as content icon would "stick" to the radius. Manual padding adjustments need to be accompanied by insets as well, or else content would become misaligned from background. Next, this component is designed to be used at various view edges (e.g. top-left), so in order to adhere to Fitts's law it should use internal spacing instead of external anchors.margins to separate itself from an edge while increasing clickable area; but doing so through manipulations with both padding and inset is hard and error-prone.

Thus, here is a rewrite of FloatingButton's sizing model that solves all of the above problems at once. Making it fully round but with smart geometrical padding is now just a matter of settings radius to Infinity, and increasing clickable area external to content/background graphics is as simple as setting margins -- the new cascading set of properties.

Default icon size is kept intact, but overall the control is slightly larger now because it started relying on its implicit size instead of hard-coding it to a semi-random value.

New background styling bits allow it omitting extra hover effects when focusPolicy is set to special value Qt.NoFocus which is suitable for cases when such button duplicates an action accessible via other means, like Previous/Next buttons for gallery of images.

Merge request reports