mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
feat: add Shade/Unshade/ToggleShade actions
This builds on the work of @Consolatis in #1018. Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com> Co-authored-by: Andrew J. Hesford <ajh@sideband.org>
This commit is contained in:
parent
722a802de0
commit
e05bedb140
19 changed files with 218 additions and 47 deletions
22
src/snap.c
22
src/snap.c
|
|
@ -37,8 +37,9 @@ snap_get_view_edge(struct view *view)
|
|||
struct border edge = {
|
||||
.left = view->pending.x - margin.left,
|
||||
.top = view->pending.y - margin.top,
|
||||
.right = view->pending.x + view->pending.width + margin.right,
|
||||
.bottom = view->pending.y + view->pending.height + margin.bottom
|
||||
.right = view->pending.x + margin.right + view->pending.width,
|
||||
.bottom = view->pending.y + margin.bottom
|
||||
+ view_effective_height(view, /* use_pending */ true)
|
||||
};
|
||||
return edge;
|
||||
}
|
||||
|
|
@ -52,9 +53,10 @@ snap_get_max_distance(struct view *view)
|
|||
struct border distance = {
|
||||
.left = usable.x + margin.left + rc.gap - view->pending.x,
|
||||
.top = usable.y + margin.top + rc.gap - view->pending.y,
|
||||
.right = usable.x + usable.width - view->pending.width
|
||||
.right = usable.x + usable.width - view->pending.width
|
||||
- margin.right - rc.gap - view->pending.x,
|
||||
.bottom = usable.y + usable.height - view->pending.height
|
||||
.bottom = usable.y + usable.height
|
||||
- view_effective_height(view, /* use_pending */ true)
|
||||
- margin.bottom - rc.gap - view->pending.y
|
||||
};
|
||||
return distance;
|
||||
|
|
@ -115,7 +117,8 @@ _snap_next_edge(struct view *view, int start_pos, const struct snap_search def,
|
|||
vp += def.add_view_x * v->pending.x;
|
||||
vp += def.add_view_y * v->pending.y;
|
||||
vp += def.add_view_width * v->pending.width;
|
||||
vp += def.add_view_height * v->pending.height;
|
||||
vp += def.add_view_height
|
||||
* view_effective_height(v, /* use_pending */ true);
|
||||
vp += gap;
|
||||
|
||||
if (def.search_dir * vp > 0 && def.search_dir * (vp - p) < 0) {
|
||||
|
|
@ -131,12 +134,15 @@ _snap_move_resize_to_edge(struct view *view, enum view_edge direction, enum snap
|
|||
{
|
||||
struct border edge = snap_get_view_edge(view);
|
||||
struct border dmax;
|
||||
|
||||
if (mode == SNAP_MODE_SHRINK) {
|
||||
/* limit to half of current size */
|
||||
int width_max_dx = max(view->pending.width - LAB_MIN_VIEW_WIDTH, 0);
|
||||
int height_max_dy = max(view->pending.height - LAB_MIN_VIEW_HEIGHT, 0);
|
||||
int eff_height =
|
||||
view_effective_height(view, /* use_pending */ true);
|
||||
int width_max_dx = max(view->pending.width - LAB_MIN_VIEW_WIDTH, 0);
|
||||
int height_max_dy = max(eff_height - LAB_MIN_VIEW_HEIGHT, 0);
|
||||
dmax.right = min(width_max_dx, view->pending.width / 2);
|
||||
dmax.bottom = min(height_max_dy, view->pending.height / 2);
|
||||
dmax.bottom = min(height_max_dy, eff_height / 2);
|
||||
dmax.left = -dmax.right;
|
||||
dmax.top = -dmax.bottom;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue