summaryrefslogtreecommitdiff
path: root/gui/common.h
blob: a64ab7016ebea6640c67f2e48ac1ea86470a980c (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
 * gui/common.h - Common data structures and declarations
 *
 * Written 2016 by Werner Almesberger
 * Copyright 2016 by Werner Almesberger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef GUI_COMMON_H
#define	GUI_COMMON_H

#include <stdbool.h>

#include <gtk/gtk.h>

#include "gfx/cro.h"
#include "gfx/gfx.h"
#include "file/git-hist.h"
#include "kicad/lib.h"
#include "kicad/sch.h"
#include "gui/aoi.h"
#include "gui/over.h"


struct gui_ctx;
struct gui_hist;

struct gui_sheet {
	const struct sheet *sch;
	struct gui_ctx *gui;	/* back link */
	struct gui_hist *hist;	/* back link */
	struct gfx *gfx;
	struct gfx *gfx_extra;

	int w, h;		/* in eeschema coordinates */
	int xmin, ymin;

	bool rendered;		/* 0 if we still have to render it */

	struct overlay *over;	/* current overlay */
	struct aoi *aois;	/* areas of interest; in schematics coord  */

	/* thumbnails, for index */
	struct gfx *gfx_thumb;		/* NULL if not yet rendered */
	cairo_surface_t *thumb_surf;	/* for caching */
	unsigned thumb_w, thumb_h;	/* size for which we cached */
	struct overlay *thumb_over;	/* thumb overlay */
	bool thumb_yellow;		/* change mark */

	struct gui_sheet *next;
};

struct gui_hist {
	struct gui_ctx *gui;	/* back link */
	struct hist *vcs_hist;	/* NULL if not from repo */
	struct overlay *over;	/* current overlay */
	struct gui_sheet *sheets; /* NULL if failed */
	unsigned age;		/* 0-based; uncommitted or HEAD = 0 */

	struct pl_ctx *pl;	/* NULL if none or failed */

	/* caching support */
	void **oids;		/* file object IDs */
	unsigned libs_open;
	struct sch_ctx sch_ctx;
	struct lib lib;		/* combined library */
	bool identical;		/* identical with previous entry */

	struct gui_hist *next;
};

struct gui_ctx {
	GtkWidget *da;

	float scale;		/* pixels = eeschema * scale */
	int x, y;		/* center, in eeschema coordinates */

	struct gui_hist *hist;	/* revision history; NULL if none */
	struct hist *vcs_hist;	/* underlying VCS data; NULL if none */

	enum gui_mode {
		showing_sheet,
		showing_history,
		showing_index,
	} mode;

	enum selecting {
		sel_only,	/* select the only revision we show */
		sel_split,	/* select revision to compare with */
		sel_new,	/* select the new revision */
		sel_old,	/* select the old revision */
	} selecting;

	struct overlay *sheet_overlays;
	struct overlay *hist_overlays;
	struct overlay *thumb_overlays;

	struct overlay *pop_overlays; /* pop-up dialogs */
	struct overlay *pop_underlays;
	int pop_x, pop_y;
	int pop_dx, pop_dy;
	const void *pop_origin;	/* item that created this pop-up */
	const char *glabel;	/* currenly highlighted glabel, or NULL */

	struct aoi *aois;	/* areas of interest; in canvas coord  */

	struct gui_sheet delta_a;
	struct gui_sheet delta_b;
	struct gui_sheet delta_ab;

	struct gui_sheet *curr_sheet;
				/* current sheet, always on new_hist */

	enum diff_mode {
		diff_new,	/* show only new sheet */
		diff_old,	/* show only old sheet */
		diff_delta,	/* show delta */
	} diff_mode;
	struct gui_hist *new_hist;
	struct gui_hist *old_hist; /* NULL if not comparing */

	int hist_y_offset;	/* history list y offset */

	/* progress bar */
	int hist_size;		/* total number of revisions */
	unsigned progress;	/* progress counter */
	unsigned progress_scale;/* right-shift by this value */
};


#define	GLABEL_STACK_PADDING	5


/* progress.c */

void setup_progress_bar(struct gui_ctx *gui, GtkWidget *window);
void progress_update(struct gui_ctx *gui);

/* render.c */

extern bool use_delta;
extern bool show_extra;


void redraw(const struct gui_ctx *gui);
void render_sheet(struct gui_sheet *sheet);
void render_delta(struct gui_ctx *gui);
void render_setup(struct gui_ctx *gui);

/* glabel.c */

void dehover_glabel(struct gui_ctx *gui);
void add_glabel_aoi(struct gui_sheet *sheet, const struct sch_obj *obj);

/* sheet.c */

void go_to_sheet(struct gui_ctx *gui, struct gui_sheet *sheet);
void zoom_to_extents(struct gui_ctx *gui);
void do_revision_overlays(struct gui_ctx *gui);
void sheet_setup(struct gui_ctx *gui);

/* history.c */

void show_history(struct gui_ctx *gui, enum selecting sel);

/* index.c */

void index_draw_event(const struct gui_ctx *gui, cairo_t *cr);
void index_resize(struct gui_ctx *gui);
void show_index(struct gui_ctx *gui);

/* gui.c */

struct gui_sheet *find_corresponding_sheet(struct gui_sheet *pick_from,
     struct gui_sheet *ref_in, const struct gui_sheet *ref);
void mark_aois(struct gui_ctx *gui, struct gui_sheet *sheet);

#endif /* !GUI_COMMON_H */