diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-02-21 22:00:10 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2018-06-22 16:48:46 +0100 |
commit | 41050d282409f86f425ac4a157fc07d889e4b54d (patch) | |
tree | ff0611853ff17214a3c6e3e472b7ee2dfb425107 /platform/gl/gl-app.h | |
parent | bde703f83b83232f830426b45957b10e4e44043d (diff) | |
download | mupdf-41050d282409f86f425ac4a157fc07d889e4b54d.tar.xz |
gl: Add annotation editor.
* Select with right mouse, edit with left mouse.
* Clamp movement to page area.
* Integrate page scroll offset into matrices.
* Edit Ink annotations.
* Initialise important annotation properties when creating them.
* Deselect annotation when pressing ESC.
* Add polygon/polyline annotation editing.
* Tweak polygon editing.
* Edit square/circle annotations.
* Cancel canvas edits on right click.
* Expand selectable areas and grab zones for rects.
* Edit line annotations.
* Edit caret annotations.
* Return true when value has changed (checkbox and slider).
* Add popup menu widget: Menu items are drawn at ui_end to overlay other widgets properly.
* Use popup menu to set icons.
* Fix text selection translation offset.
* Edit quad point annotations.
* Set user and modification date when creating new annotations.
* Add select widget.
* Edit line endings.
* Edit highlight opacity.
* Create properly sized stamp annotations.
* Edit FreeText annotations.
* Trigger list selection on mouse-up instead of mouse-down.
* Use index in ui_select.
* Edit Freetext quadding.
* Fix windows build issues.
* Use 'const void *' for ids.
* Add file dialog to choose file when none given on command line.
* Add save file dialog.
* Add pdfwrite options to save dialog.
* Add error dialog instead of dying silently on exceptions.
* Add password dialog.
* Add warning dialog that does not exit the program.
* Show in title bar when document is modified.
* Separate motion and passive motion callbacks.
* Add /Volumes 'disk' for MacOS X mount points.
* Tweak input focus/blur handling.
* Use popup menu to create annotations instead of big list of buttons.
* Update appearance after canvas edits too.
* Release old grab before checking for new grab and taking focus.
* Set cursor shape depending on hot item.
* Draw prettier widgets.
* Use integers for slider to allow snapping to values.
* Add 'ui.gridsize' to ease layout of buttons and text fields.
* Tweak file dialog layout.
* Bevels around lists and scroll bars.
* Only add new points to the ink list when drawing.
* Use named color constants instead of hardcoding color values.
* Adjust layout and which properties to edit for each annotation.
* Use a panel for search field.
* Add splitter, dialogs, and panel padding.
* Popup menus above the button if they don't fit below it.
* Use triangle strip to draw check mark.
Diffstat (limited to 'platform/gl/gl-app.h')
-rw-r--r-- | platform/gl/gl-app.h | 77 |
1 files changed, 67 insertions, 10 deletions
diff --git a/platform/gl/gl-app.h b/platform/gl/gl-app.h index 6efb1ff7..a966641a 100644 --- a/platform/gl/gl-app.h +++ b/platform/gl/gl-app.h @@ -1,7 +1,6 @@ #ifdef _WIN32 #include <windows.h> void win_install(void); -int win_open_file(char *buf, int len); #endif #include "mupdf/fitz.h" @@ -82,15 +81,23 @@ struct ui int grab_down, grab_middle, grab_right; const void *hot, *active, *focus; + int last_cursor, cursor; int fontsize; int baseline; int lineheight; + int gridsize; struct layout *layout; fz_irect *cavity; struct layout layout_stack[32]; fz_irect cavity_stack[32]; + + struct { fz_irect area; const char *title; } popup[32]; + fz_irect popup_area; + int popup_count; + + void (*dialog)(void); }; extern struct ui ui; @@ -125,9 +132,9 @@ void ui_draw_image(struct texture *tex, float x, float y); enum { - UI_INPUT_CANCEL = -1, - UI_INPUT_ACCEPT = 1, - UI_INPUT_CONTINUE = 0, + UI_INPUT_NONE = 0, + UI_INPUT_EDIT = 1, + UI_INPUT_ACCEPT = 2, }; struct input @@ -154,29 +161,79 @@ fz_irect ui_pack(int slave_w, int slave_h); void ui_pack_push(fz_irect cavity); void ui_pack_pop(void); -void ui_panel_begin(int w, int h, int opaque); +void ui_dialog_begin(int w, int h); +void ui_dialog_end(void); +void ui_panel_begin(int w, int h, int padx, int pady, int opaque); void ui_panel_end(void); void ui_spacer(void); +void ui_splitter(int *x, int min, int max, enum side side); void ui_label(const char *fmt, ...); int ui_button(const char *label); -void ui_checkbox(const char *label, int *value); -void ui_slider(float *value, float min, float max, int width); +int ui_checkbox(const char *label, int *value); +int ui_slider(int *value, int min, int max, int width); +int ui_select(const void *id, const char *current, const char *options[], int n); void ui_input_init(struct input *input, const char *text); int ui_input(struct input *input, int width); void ui_scrollbar(int x0, int y0, int x1, int y1, int *value, int page_size, int max); void ui_list_begin(struct list *list, int count, int req_w, int req_h); -int ui_list_item(struct list *list, void *id, int indent, const char *label, int selected); +int ui_list_item(struct list *list, const void *id, const char *label, int selected); +int ui_list_item_x(struct list *list, const void *id, int indent, const char *label, int selected); void ui_list_end(struct list *list); +int ui_popup(const void *id, const char *title, int is_button, int count); +int ui_popup_item(const char *title); +void ui_popup_end(void); +void ui_draw_popup(void); + +void ui_init_open_file(const char *dir, int (*filter)(const char *fn)); +int ui_open_file(char filename[]); +void ui_init_save_file(const char *path, int (*filter)(const char *fn)); +int ui_save_file(char filename[], void (*extra_panel)(void)); + +void ui_show_warning_dialog(const char *message); +void ui_show_error_dialog(const char *message); + +/* Theming */ + +enum +{ + UI_COLOR_PANEL = 0xc0c0c0, + UI_COLOR_BUTTON = 0xc0c0c0, + UI_COLOR_SCROLLBAR = 0xdfdfdf, + UI_COLOR_TEXT_BG = 0xffffff, + UI_COLOR_TEXT_FG = 0x000000, + UI_COLOR_TEXT_SEL_BG = 0x000080, + UI_COLOR_TEXT_SEL_FG = 0xffffff, + UI_COLOR_BEVEL_1 = 0x000000, + UI_COLOR_BEVEL_2 = 0x808080, + UI_COLOR_BEVEL_3 = 0xdfdfdf, + UI_COLOR_BEVEL_4 = 0xffffff, +}; + +void glColorHex(unsigned int hex); +void ui_draw_bevel(fz_irect area, int depressed); +void ui_draw_ibevel(fz_irect area, int depressed); +void ui_draw_bevel_rect(fz_irect area, unsigned int fill, int depressed); +void ui_draw_ibevel_rect(fz_irect area, unsigned int fill, int depressed); + /* App */ extern fz_context *ctx; extern pdf_document *pdf; extern pdf_page *page; -extern fz_matrix page_ctm, page_inv_ctm; -extern int page_x_ofs, page_y_ofs; +extern fz_stext_page *page_text; +extern pdf_annot *selected_annot; +extern fz_matrix draw_page_ctm, view_page_ctm, view_page_inv_ctm; +extern fz_rect page_bounds, draw_page_bounds, view_page_bounds; +extern fz_irect view_page_area; +extern char filename[]; void run_main_loop(void); +void do_annotate_panel(void); +void do_annotate_canvas(fz_irect canvas_area); +void render_page(void); +void update_title(void); +void reload(void); |