mirror of
https://github.com/labwc/labwc.git
synced 2026-03-01 01:40:24 -05:00
edges: limit edge attraction and resistance...
...to edges actually encountered by motion during interactive moves and resizes. In addition, ignore edge resistance and attraction for minimized views.
This commit is contained in:
parent
14f5733584
commit
cf34e60240
6 changed files with 233 additions and 67 deletions
|
|
@ -10,11 +10,16 @@
|
|||
#include "view.h"
|
||||
|
||||
static void
|
||||
check_edge(int *next, int current, int target,
|
||||
int oppose, int align, bool lesser, int tolerance)
|
||||
check_edge(int *next, struct edge current, struct edge target,
|
||||
struct edge oppose, struct edge align, int tolerance)
|
||||
{
|
||||
int cur = current.offset;
|
||||
int tgt = target.offset;
|
||||
int opp = oppose.offset;
|
||||
int aln = align.offset;
|
||||
|
||||
/* Ignore non-moving edges */
|
||||
if (current == target) {
|
||||
if (cur == tgt) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -32,56 +37,56 @@ check_edge(int *next, int current, int target,
|
|||
*/
|
||||
|
||||
/* Direction of motion for the edge */
|
||||
const bool decreasing = target < current;
|
||||
const bool decreasing = tgt < cur;
|
||||
|
||||
/* Check the opposing edge */
|
||||
bool valid = false;
|
||||
if (decreasing) {
|
||||
const int lo = clipped_sub(oppose, abs(tolerance));
|
||||
const int hi = clipped_sub(oppose, MIN(tolerance, 0));
|
||||
valid = target >= lo && target < hi;
|
||||
const int lo = clipped_sub(opp, abs(tolerance));
|
||||
const int hi = clipped_sub(opp, MIN(tolerance, 0));
|
||||
valid = tgt >= lo && tgt < hi;
|
||||
} else {
|
||||
/* Check for increasing movement across opposing edge */
|
||||
const int lo = clipped_add(oppose, MIN(tolerance, 0));
|
||||
const int hi = clipped_add(oppose, abs(tolerance));
|
||||
valid = target > lo && target <= hi;
|
||||
const int lo = clipped_add(opp, MIN(tolerance, 0));
|
||||
const int hi = clipped_add(opp, abs(tolerance));
|
||||
valid = tgt > lo && tgt <= hi;
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
*next = edge_get_best(*next, oppose, decreasing);
|
||||
if (valid && edges_traverse_edge(current, target, oppose)) {
|
||||
*next = edge_get_best(*next, opp, decreasing);
|
||||
}
|
||||
|
||||
/* Check the aligned edge */
|
||||
valid = false;
|
||||
if (decreasing) {
|
||||
const int lo = clipped_sub(align, abs(tolerance));
|
||||
const int hi = clipped_sub(align, MIN(tolerance, 0));
|
||||
valid = target >= lo && target < hi;
|
||||
const int lo = clipped_sub(aln, abs(tolerance));
|
||||
const int hi = clipped_sub(aln, MIN(tolerance, 0));
|
||||
valid = tgt >= lo && tgt < hi;
|
||||
} else {
|
||||
const int lo = clipped_add(align, MIN(tolerance, 0));
|
||||
const int hi = clipped_add(align, abs(tolerance));
|
||||
valid = target > lo && target <= hi;
|
||||
const int lo = clipped_add(aln, MIN(tolerance, 0));
|
||||
const int hi = clipped_add(aln, abs(tolerance));
|
||||
valid = tgt > lo && tgt <= hi;
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
*next = edge_get_best(*next, align, decreasing);
|
||||
if (valid && edges_traverse_edge(current, target, align)) {
|
||||
*next = edge_get_best(*next, aln, decreasing);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_edge_output(int *next, int current, int target,
|
||||
int oppose, int align, bool lesser)
|
||||
check_edge_output(int *next, struct edge current, struct edge target,
|
||||
struct edge oppose, struct edge align)
|
||||
{
|
||||
check_edge(next, current, target,
|
||||
oppose, align, lesser, rc.screen_edge_strength);
|
||||
oppose, align, rc.screen_edge_strength);
|
||||
}
|
||||
|
||||
static void
|
||||
check_edge_window(int *next, int current, int target,
|
||||
int oppose, int align, bool lesser)
|
||||
check_edge_window(int *next, struct edge current, struct edge target,
|
||||
struct edge oppose, struct edge align)
|
||||
{
|
||||
check_edge(next, current, target,
|
||||
oppose, align, lesser, rc.window_edge_strength);
|
||||
oppose, align, rc.window_edge_strength);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue