| 1 | /* File: gui_sketch_background.h; Copyright and License: see below */ |
| 2 | |
| 3 | #ifndef GUI_SKETCH_BACKGROUND_H |
| 4 | #define GUI_SKETCH_BACKGROUND_H |
| 5 | |
| 6 | /* public file for the doxygen documentation: */ |
| 7 | /*! |
| 8 | * \file |
| 9 | * \brief Draws background graphics below diagrams |
| 10 | */ |
| 11 | |
| 12 | #include "gui_resources.h" |
| 13 | #include "sketch/gui_sketch_texture.h" |
| 14 | #include "shape/shape_int_rectangle.h" |
| 15 | #include "gui_gtk.h" |
| 16 | #include <stdbool.h> |
| 17 | |
| 18 | /*! |
| 19 | * \brief attributes of the sketch background |
| 20 | */ |
| 21 | struct gui_sketch_background_struct { |
| 22 | shape_int_rectangle_t card_bounds; /*!< bounding box of the background of the cards area */ |
| 23 | shape_int_rectangle_t label_bounds; /*!< bounding box of the background of the nav_tree or the search result list */ |
| 24 | const gui_resources_t *resources; /*!< pointer to external resources */ |
| 25 | gui_sketch_texture_t *texture_downloader; /*!< pointer to external gui_sketch_texture_t */ |
| 26 | }; |
| 27 | |
| 28 | typedef struct gui_sketch_background_struct gui_sketch_background_t; |
| 29 | |
| 30 | /*! |
| 31 | * \brief initializes the sketch background |
| 32 | * |
| 33 | * \param this_ pointer to own object attributes |
| 34 | * \param resources pointer to a resource provider |
| 35 | * \param texture_downloader pointer to a gui_sketch_texture_t that can draw a texture onto a cairo drawing context |
| 36 | */ |
| 37 | void gui_sketch_background_init( gui_sketch_background_t *this_, |
| 38 | const gui_resources_t *resources, |
| 39 | gui_sketch_texture_t *texture_downloader |
| 40 | ); |
| 41 | |
| 42 | /*! |
| 43 | * \brief destroys the sketch background |
| 44 | * |
| 45 | * \param this_ pointer to own object attributes |
| 46 | */ |
| 47 | void gui_sketch_background_destroy( gui_sketch_background_t *this_ ); |
| 48 | |
| 49 | /*! |
| 50 | * \brief gets the bounds rectangle of the cards area |
| 51 | * |
| 52 | * \param this_ pointer to own object attributes |
| 53 | * \return returns the bounding box of this sketch areas card area |
| 54 | */ |
| 55 | static inline const shape_int_rectangle_t *gui_sketch_background_get_card_bounds( gui_sketch_background_t *this_ ); |
| 56 | |
| 57 | /*! |
| 58 | * \brief gets the bounds rectangle of the list labels |
| 59 | * |
| 60 | * \param this_ pointer to own object attributes |
| 61 | * \return returns the bounding box of this sketch areas list label area |
| 62 | */ |
| 63 | static inline const shape_int_rectangle_t *gui_sketch_background_get_label_bounds( gui_sketch_background_t *this_ ); |
| 64 | |
| 65 | /*! |
| 66 | * \brief sets the bounds rectangle |
| 67 | * |
| 68 | * \param this_ pointer to own object attributes |
| 69 | * \param card_bounds bounding box of this sketch areas card area |
| 70 | * \param label_bounds bounding box of this sketch areas list label area |
| 71 | */ |
| 72 | static inline void gui_sketch_background_set_bounds( gui_sketch_background_t *this_, |
| 73 | const shape_int_rectangle_t *card_bounds, |
| 74 | const shape_int_rectangle_t *label_bounds |
| 75 | ); |
| 76 | |
| 77 | /*! |
| 78 | * \brief draws background graphics to the cairo context, including the introduction |
| 79 | * |
| 80 | * \param this_ pointer to own object attributes |
| 81 | * \param cr cairo drawing context |
| 82 | */ |
| 83 | void gui_sketch_background_draw_introduction( gui_sketch_background_t *this_, |
| 84 | cairo_t *cr |
| 85 | ); |
| 86 | |
| 87 | /*! |
| 88 | * \brief draws background graphics to the cairo context for navigation mode |
| 89 | * |
| 90 | * \param this_ pointer to own object attributes |
| 91 | * \param tree_depth depth of the current diagram in the tree. 0 represents the root node or no valid diagram. |
| 92 | * \param num_children number of children at the current diagram. |
| 93 | * \param cr cairo drawing context |
| 94 | */ |
| 95 | void gui_sketch_background_draw_navigation( gui_sketch_background_t *this_, |
| 96 | unsigned int tree_depth, |
| 97 | unsigned int num_children, |
| 98 | cairo_t *cr |
| 99 | ); |
| 100 | |
| 101 | /*! |
| 102 | * \brief draws background graphics to the cairo context for search mode |
| 103 | * |
| 104 | * \param this_ pointer to own object attributes |
| 105 | * \param cr cairo drawing context |
| 106 | */ |
| 107 | void gui_sketch_background_draw_search( gui_sketch_background_t *this_, cairo_t *cr ); |
| 108 | |
| 109 | /*! |
| 110 | * \brief draws background graphics to the cairo context for edit mode |
| 111 | * |
| 112 | * \param this_ pointer to own object attributes |
| 113 | * \param cr cairo drawing context |
| 114 | */ |
| 115 | void gui_sketch_background_draw_edit( gui_sketch_background_t *this_, cairo_t *cr ); |
| 116 | |
| 117 | /*! |
| 118 | * \brief draws background graphics to the cairo context for create mode |
| 119 | * |
| 120 | * \param this_ pointer to own object attributes |
| 121 | * \param cr cairo drawing context |
| 122 | */ |
| 123 | void gui_sketch_background_draw_create( gui_sketch_background_t *this_, cairo_t *cr ); |
| 124 | |
| 125 | /*! |
| 126 | * \brief draws a connector line from the object box to the diagram card box |
| 127 | * |
| 128 | * \param this_ pointer to own object attributes |
| 129 | * \param label_box bounding box of icon and label of the object |
| 130 | * \param card_box bounding box of the diagram card |
| 131 | * \param cr cairo drawing context |
| 132 | */ |
| 133 | void gui_sketch_background_draw_appears_link( gui_sketch_background_t *this_, |
| 134 | const shape_int_rectangle_t *label_box, |
| 135 | const shape_int_rectangle_t *card_box, |
| 136 | cairo_t *cr |
| 137 | ); |
| 138 | |
| 139 | /*! |
| 140 | * \brief draws a quick-introduction to the cairo context |
| 141 | * |
| 142 | * \param this_ pointer to own object attributes |
| 143 | * \param cr cairo drawing context |
| 144 | */ |
| 145 | void gui_sketch_background_private_draw_quick_introduction( gui_sketch_background_t *this_, cairo_t *cr ); |
| 146 | |
| 147 | /*! |
| 148 | * \brief draws an icon and two lines of text |
| 149 | * |
| 150 | * \param this_ pointer to own object attributes |
| 151 | * \param icon_1 a pointer to an icon |
| 152 | * \param text_1 a pointer to a text message, line 1 |
| 153 | * \param text_2 a pointer to a text message, line 2 |
| 154 | * \param x coordinate of the output location |
| 155 | * \param y coordinate of the output location |
| 156 | * \param cr cairo drawing context |
| 157 | */ |
| 158 | void gui_sketch_background_private_draw_icon_and_message( gui_sketch_background_t *this_, |
| 159 | GdkTexture *icon_1, |
| 160 | const char *text_1, |
| 161 | const char *text_2, |
| 162 | int x, |
| 163 | int y, |
| 164 | cairo_t *cr |
| 165 | ); |
| 166 | |
| 167 | #include "gui_sketch_background.inl" |
| 168 | |
| 169 | #endif /* GUI_SKETCH_BACKGROUND_H */ |
| 170 | |
| 171 | |
| 172 | /* |
| 173 | Copyright 2017-2026 Andreas Warnke |
| 174 | |
| 175 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 176 | you may not use this file except in compliance with the License. |
| 177 | You may obtain a copy of the License at |
| 178 | |
| 179 | http://www.apache.org/licenses/LICENSE-2.0 |
| 180 | |
| 181 | Unless required by applicable law or agreed to in writing, software |
| 182 | distributed under the License is distributed on an "AS IS" BASIS, |
| 183 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 184 | See the License for the specific language governing permissions and |
| 185 | limitations under the License. |
| 186 | */ |