Root/
| 1 | /* |
| 2 | * gui/common.h - Common data structures and declarations |
| 3 | * |
| 4 | * Written 2016 by Werner Almesberger |
| 5 | * Copyright 2016 by Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #ifndef GUI_COMMON_H |
| 14 | #define GUI_COMMON_H |
| 15 | |
| 16 | #include <stdbool.h> |
| 17 | |
| 18 | #include <gtk/gtk.h> |
| 19 | |
| 20 | #include "gfx/cro.h" |
| 21 | #include "file/git-hist.h" |
| 22 | #include "kicad/lib.h" |
| 23 | #include "kicad/sch.h" |
| 24 | #include "gui/aoi.h" |
| 25 | #include "gui/over.h" |
| 26 | |
| 27 | |
| 28 | struct gui_ctx; |
| 29 | struct gui_hist; |
| 30 | |
| 31 | struct gui_sheet { |
| 32 | const struct sheet *sch; |
| 33 | struct gui_ctx *ctx; /* back link */ |
| 34 | struct gui_hist *hist; /* back link */ |
| 35 | struct cro_ctx *gfx_ctx; |
| 36 | |
| 37 | int w, h; /* in eeschema coordinates */ |
| 38 | int xmin, ymin; |
| 39 | |
| 40 | bool rendered; /* 0 if still have to render it */ |
| 41 | |
| 42 | struct overlay *over; /* current overlay */ |
| 43 | struct aoi *aois; /* areas of interest; in schematics coord */ |
| 44 | |
| 45 | struct gui_sheet *next; |
| 46 | }; |
| 47 | |
| 48 | struct gui_hist { |
| 49 | struct gui_ctx *ctx; /* back link */ |
| 50 | struct hist *vcs_hist; /* NULL if not from repo */ |
| 51 | struct overlay *over; /* current overlay */ |
| 52 | struct gui_sheet *sheets; /* NULL if failed */ |
| 53 | unsigned age; /* 0-based; uncommitted or HEAD = 0 */ |
| 54 | |
| 55 | struct pl_ctx *pl; /* NULL if none or failed */ |
| 56 | |
| 57 | /* caching support */ |
| 58 | void **oids; /* file object IDs */ |
| 59 | unsigned libs_open; |
| 60 | struct sch_ctx sch_ctx; |
| 61 | struct lib lib; /* combined library */ |
| 62 | bool identical; /* identical with previous entry */ |
| 63 | |
| 64 | struct gui_hist *next; |
| 65 | }; |
| 66 | |
| 67 | struct gui_ctx { |
| 68 | GtkWidget *da; |
| 69 | |
| 70 | float scale; /* pixels = eeschema * scale */ |
| 71 | int x, y; /* center, in eeschema coordinates */ |
| 72 | |
| 73 | struct gui_hist *hist; /* revision history; NULL if none */ |
| 74 | struct hist *vcs_hist; /* underlying VCS data; NULL if none */ |
| 75 | |
| 76 | bool showing_history; |
| 77 | enum selecting { |
| 78 | sel_only, /* select the only revision we show */ |
| 79 | sel_split, /* select revision to compare with */ |
| 80 | sel_new, /* select the new revision */ |
| 81 | sel_old, /* select the old revision */ |
| 82 | } selecting; |
| 83 | |
| 84 | struct overlay *sheet_overlays; |
| 85 | struct overlay *hist_overlays; |
| 86 | |
| 87 | struct overlay *pop_overlays; /* pop-up dialogs */ |
| 88 | struct overlay *pop_underlays; |
| 89 | int pop_x, pop_y; |
| 90 | int pop_dx, pop_dy; |
| 91 | const void *pop_origin; /* item that created this pop-up */ |
| 92 | const char *glabel; /* currenly highlighted glabel, or NULL */ |
| 93 | |
| 94 | struct aoi *aois; /* areas of interest; in canvas coord */ |
| 95 | |
| 96 | struct gui_sheet delta_a; |
| 97 | struct gui_sheet delta_b; |
| 98 | struct gui_sheet delta_ab; |
| 99 | |
| 100 | struct gui_sheet *curr_sheet; |
| 101 | /* current sheet, always on new_hist */ |
| 102 | |
| 103 | enum diff_mode { |
| 104 | diff_new, /* show only new sheet */ |
| 105 | diff_old, /* show only old sheet */ |
| 106 | diff_delta, /* show delta */ |
| 107 | } diff_mode; |
| 108 | struct gui_hist *new_hist; |
| 109 | struct gui_hist *old_hist; /* NULL if not comparing */ |
| 110 | |
| 111 | int hist_y_offset; /* history list y offset */ |
| 112 | |
| 113 | /* progress bar */ |
| 114 | int hist_size; /* total number of revisions */ |
| 115 | unsigned progress; /* progress counter */ |
| 116 | unsigned progress_scale;/* right-shift by this value */ |
| 117 | }; |
| 118 | |
| 119 | |
| 120 | #define GLABEL_STACK_PADDING 5 |
| 121 | |
| 122 | |
| 123 | /* progress.c */ |
| 124 | |
| 125 | void setup_progress_bar(struct gui_ctx *ctx, GtkWidget *window); |
| 126 | void progress_update(struct gui_ctx *ctx); |
| 127 | |
| 128 | /* render.c */ |
| 129 | |
| 130 | void redraw(const struct gui_ctx *ctx); |
| 131 | void render_sheet(struct gui_sheet *sheet); |
| 132 | void render_delta(struct gui_ctx *ctx); |
| 133 | void render_setup(struct gui_ctx *ctx); |
| 134 | |
| 135 | /* glabel.c */ |
| 136 | |
| 137 | void dehover_glabel(struct gui_ctx *ctx); |
| 138 | void add_glabel_aoi(struct gui_sheet *sheet, const struct sch_obj *obj); |
| 139 | |
| 140 | /* sheet.c */ |
| 141 | |
| 142 | void go_to_sheet(struct gui_ctx *ctx, struct gui_sheet *sheet); |
| 143 | void do_revision_overlays(struct gui_ctx *ctx); |
| 144 | void sheet_setup(struct gui_ctx *ctx); |
| 145 | |
| 146 | /* history.c */ |
| 147 | |
| 148 | void show_history(struct gui_ctx *ctx, enum selecting sel); |
| 149 | |
| 150 | /* gui.c */ |
| 151 | |
| 152 | extern bool use_delta; |
| 153 | |
| 154 | struct gui_sheet *find_corresponding_sheet(struct gui_sheet *pick_from, |
| 155 | struct gui_sheet *ref_in, const struct gui_sheet *ref); |
| 156 | void mark_aois(struct gui_ctx *ctx, struct gui_sheet *sheet); |
| 157 | |
| 158 | #endif /* !GUI_COMMON_H */ |
| 159 |
Branches:
master
