mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
common/box: add box_fit_within()
Factor out common math from ssd's get_scale_box() for use elsewhere.
This commit is contained in:
parent
465aac5514
commit
22e50aa4e2
3 changed files with 46 additions and 28 deletions
|
|
@ -4,14 +4,23 @@
|
|||
|
||||
#include <wlr/util/box.h>
|
||||
|
||||
bool
|
||||
box_contains(struct wlr_box *box_super, struct wlr_box *box_sub);
|
||||
bool box_contains(struct wlr_box *box_super, struct wlr_box *box_sub);
|
||||
|
||||
bool
|
||||
box_intersects(struct wlr_box *box_a, struct wlr_box *box_b);
|
||||
bool box_intersects(struct wlr_box *box_a, struct wlr_box *box_b);
|
||||
|
||||
/* Returns the bounding box of 2 boxes */
|
||||
void
|
||||
box_union(struct wlr_box *box_dest, struct wlr_box *box_a, struct wlr_box *box_b);
|
||||
void box_union(struct wlr_box *box_dest, struct wlr_box *box_a,
|
||||
struct wlr_box *box_b);
|
||||
|
||||
/*
|
||||
* Fits and centers a content box (width & height) within a bounding box
|
||||
* (max_width & max_height). The content box is downscaled if necessary
|
||||
* (preserving aspect ratio) but not upscaled.
|
||||
*
|
||||
* The returned x & y coordinates are the centered content position
|
||||
* relative to the top-left corner of the bounding box.
|
||||
*/
|
||||
struct wlr_box box_fit_within(int width, int height, int max_width,
|
||||
int max_height);
|
||||
|
||||
#endif /* LABWC_BOX_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue