Skip to content

Large diffs are not rendered by default.

348 changes: 109 additions & 239 deletions Packages/macOS/CmuxNext/Sources/CmuxNextLayout/Views/ClosingPanes.swift

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,121 @@ CmuxScrollEffects cmux_scroll_page(CmuxScroll *scroll, CmuxScrollSpring *spring,
CmuxScrollStatus cmux_scroll_status(const CmuxScroll *scroll);
uint8_t cmux_scroll_gesture_active(const CmuxScroll *scroll); /* per frame: no focus lookup */

/*
* The springing-close rules (cmux-layout-reducer closing_panes; FRAME OWNER
* S3c/S3d): which panes border a closing pane and the gaps it keeps, the panes
* nothing moves over, where every closing pane shows this frame (per display
* frame during a close), the strip's carries and a row column's stop, and a
* taken-back close. One handle per screen; panes, scroll areas and row columns
* are numbers the caller hands out (0: none). No JSON; a call allocates
* nothing once the handle's buffers have grown.
*
* Return codes: begin and remove return 1 when they answer and 0 when they do
* not, with nothing written. 1 and 0 are answers, not
* CMUX_LAYOUT_REDUCER_OK (also 0): check for 1. settle and rects return
* CMUX_LAYOUT_REDUCER_OK and write a list that borrows the handle's buffer,
* valid until the next call on the same handle. Any call returns ERR_NULL,
* ERR_INVALID (an unknown handle kind) or ERR_PANIC with nothing written.
* Each input array holds `count` elements; an `out` pointer must not overlap
* an input array or the handle. One thread at a time per handle.
*/
typedef struct CmuxClosingPanes CmuxClosingPanes;

#define CMUX_CLOSING_HANDLE_SPLIT 0
#define CMUX_CLOSING_HANDLE_COLUMN_EDGE 1
#define CMUX_CLOSING_HANDLE_ROW_EDGE 2

typedef struct CmuxClosingEdges {
double min_x;
double max_x;
double min_y;
double max_y;
} CmuxClosingEdges;

typedef struct CmuxClosingRect {
double x;
double y;
double width;
double height;
} CmuxClosingRect;

typedef struct CmuxClosingPane {
uint64_t id;
uint64_t area;
uint64_t row_column;
CmuxClosingEdges edges;
uint8_t scrolls;
uint8_t reserved[7];
} CmuxClosingPane;

typedef struct CmuxClosingHandle {
CmuxClosingEdges hit;
double mid_x;
double mid_y;
uint64_t area; /* a split's scroll area (0: none) */
uint64_t column; /* a row edge's column */
uint8_t kind; /* CMUX_CLOSING_HANDLE_* */
uint8_t horizontal;
uint8_t kept;
uint8_t fixed_split;
uint8_t docked;
uint8_t reserved[3];
} CmuxClosingHandle;

typedef struct CmuxClosingFrame {
uint64_t id;
CmuxClosingEdges now;
CmuxClosingEdges target;
double vx;
double vy;
double vw;
double vh;
uint8_t moving;
uint8_t reserved[7];
} CmuxClosingFrame;

typedef struct CmuxClosingRow {
uint64_t column;
double now;
double target;
} CmuxClosingRow;

typedef struct CmuxClosingPlaced {
uint64_t pane;
CmuxClosingRect rect;
} CmuxClosingPlaced;

typedef struct CmuxClosingTaken {
CmuxClosingRect rect;
double vx;
double vw;
double vy;
double vh;
} CmuxClosingTaken;

typedef struct CmuxClosingIds {
const uint64_t *ids;
size_t count;
} CmuxClosingIds;

typedef struct CmuxClosingPlacedList {
const CmuxClosingPlaced *placed;
size_t count;
} CmuxClosingPlacedList;

CmuxClosingPanes *cmux_closing_panes_new(void);
void cmux_closing_panes_free(CmuxClosingPanes *closing);
int32_t cmux_closing_panes_begin(CmuxClosingPanes *closing, uint64_t pane, const CmuxClosingEdges *shown, const CmuxClosingPane *panes, size_t pane_count, const CmuxClosingHandle *handles, size_t handle_count, double max_gap, uint8_t has_view_shift, double view_shift);
int32_t cmux_closing_panes_settle(CmuxClosingPanes *closing, const CmuxClosingFrame *frames, size_t frame_count, const CmuxClosingRow *rows, size_t row_count, CmuxClosingIds *out);
int32_t cmux_closing_panes_rects(CmuxClosingPanes *closing, const CmuxClosingFrame *frames, size_t frame_count, const CmuxClosingRow *rows, size_t row_count, CmuxClosingPlacedList *out);
int32_t cmux_closing_panes_carry(CmuxClosingPanes *closing, double drift, uint8_t has_view_shift, double view_shift);
int32_t cmux_closing_panes_settle_carried(CmuxClosingPanes *closing, double strip_shift);
int32_t cmux_closing_panes_shift_y(CmuxClosingPanes *closing, uint64_t column, double delta);
int32_t cmux_closing_panes_remove(CmuxClosingPanes *closing, uint64_t pane, const CmuxClosingFrame *frames, size_t frame_count, CmuxClosingTaken *out);
int32_t cmux_closing_panes_drop(CmuxClosingPanes *closing, uint64_t pane);
uint8_t cmux_closing_panes_has_awaiting(const CmuxClosingPanes *closing);
uint64_t cmux_closing_panes_state_hash(const CmuxClosingPanes *closing); /* tests: the whole state, hashed */

/*
* The sidebar row face (cmux-layout-reducer sidebar_face): which tab a
* workspace's row stands for and is named for, its folder line and Group by
Expand Down
Loading
Loading