aboutsummaryrefslogtreecommitdiff
path: root/examples/dte/frame.h
blob: 022cf2b05806e4fa7345eca593226e514f0a06bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef FRAME_H
#define FRAME_H

#include <stdbool.h>
#include <stddef.h>
#include "util/macros.h"
#include "util/ptr-array.h"
#include "util/string.h"

// A container for other Frames or Windows. Frames and Windows form
// a tree structure, wherein Windows are the terminal (leaf) nodes.
typedef struct Frame {
    struct Frame *parent;
    // Every frame contains either one window or multiple subframes
    PointerArray frames;
    struct Window *window;
    int w; // Width
    int h; // Height
    bool vertical;
    bool equal_size;
} Frame;

typedef enum {
    RESIZE_DIRECTION_AUTO,
    RESIZE_DIRECTION_HORIZONTAL,
    RESIZE_DIRECTION_VERTICAL,
} ResizeDirection;

struct EditorState;

Frame *new_root_frame(struct Window *window);
void set_frame_size(Frame *frame, int w, int h);
void equalize_frame_sizes(Frame *parent);
void add_to_frame_size(Frame *frame, ResizeDirection dir, int amount);
void resize_frame(Frame *frame, ResizeDirection dir, int size);
void update_window_coordinates(Frame *frame);
Frame *split_frame(struct Window *window, bool vertical, bool before);
Frame *split_root_frame(struct EditorState *e, bool vertical, bool before);
void remove_frame(struct EditorState *e, Frame *frame);
void dump_frame(const Frame *frame, size_t level, String *str);

#if DEBUG >= 1
  void debug_frame(const Frame *frame);
#else
  static inline void debug_frame(const Frame* UNUSED_ARG(frame)) {}
#endif

#endif