Line data Source code
1 : /* File: gui_marked_set.inl; Copyright and License: see below */ 2 : 3 : #include <assert.h> 4 : 5 0 : static inline data_id_t gui_marked_set_get_focused_obj ( const gui_marked_set_t *this_ ) 6 : { 7 0 : return data_full_id_get_primary_id( &((*this_).focused) ); 8 : } 9 : 10 0 : static inline data_full_id_t gui_marked_set_get_focused ( const gui_marked_set_t *this_ ) 11 : { 12 0 : return (*this_).focused; 13 : } 14 : 15 0 : static inline data_id_t gui_marked_set_get_focused_diagram ( const gui_marked_set_t *this_ ) 16 : { 17 0 : return( (*this_).focused_diagram ); 18 : } 19 : 20 : static inline bool gui_marked_set_has_focus ( const gui_marked_set_t *this_ ) 21 : { 22 : return data_full_id_is_valid( &((*this_).focused) ); 23 : } 24 : 25 0 : static inline void gui_marked_set_request_focused_diagram ( const gui_marked_set_t *this_, data_id_t diagram_wish ) 26 : { 27 0 : (*this_).request_focus_call( (*this_).request_focus_user_data, diagram_wish ); 28 0 : } 29 : 30 0 : static inline data_id_t gui_marked_set_get_highlighted ( const gui_marked_set_t *this_ ) 31 : { 32 0 : return( (*this_).highlighted ); 33 : } 34 : 35 0 : static inline layout_subelement_kind_t gui_marked_set_get_highlighted_kind ( const gui_marked_set_t *this_ ) 36 : { 37 0 : return( (*this_).highlighted_kind ); 38 : } 39 : 40 0 : static inline data_id_t gui_marked_set_get_highlighted_diagram ( const gui_marked_set_t *this_ ) 41 : { 42 0 : return( (*this_).highlighted_diagram ); 43 : } 44 : 45 0 : static inline gui_sketch_action_t gui_marked_set_get_highlighted_button ( const gui_marked_set_t *this_ ) 46 : { 47 0 : return( (*this_).highlighted_button ); 48 : } 49 : 50 0 : static inline const data_small_set_t *gui_marked_set_get_selected_set_const ( const gui_marked_set_t *this_ ) 51 : { 52 0 : return ( &((*this_).selected_set) ); 53 : } 54 : 55 : static inline void gui_marked_set_toggle_selected_obj ( gui_marked_set_t *this_, data_id_t obj_id ) 56 : { 57 : data_small_set_toggle_obj( &((*this_).selected_set), obj_id ); 58 : } 59 : 60 0 : static inline void gui_marked_set_toggle_obj ( gui_marked_set_t *this_, data_full_id_t obj_id, data_id_t diagram_id ) 61 : { 62 0 : assert(( data_id_get_table(&diagram_id) == DATA_TABLE_DIAGRAM )||( data_id_get_table(&diagram_id) == DATA_TABLE_VOID )); 63 0 : const data_id_t *const vis_id = data_full_id_get_primary_id_const( &obj_id ); 64 : 65 : data_id_t model_id; 66 0 : if ( data_full_id_equals( &obj_id, &((*this_).focused) ) ) 67 : { 68 : /* clear focus: */ 69 0 : data_full_id_reinit_void( &((*this_).focused) ); 70 0 : data_id_replace( &((*this_).focused_diagram), &diagram_id ); 71 : /* remove from selection: */ 72 0 : data_small_set_delete_obj( &((*this_).selected_set), *vis_id ); 73 0 : model_id = DATA_ID_VOID; 74 : } 75 : else 76 : { 77 : /* set focus: */ 78 0 : data_full_id_replace( &((*this_).focused), &obj_id ); 79 0 : data_id_replace( &((*this_).focused_diagram), &diagram_id ); 80 : /* add to selection: */ 81 0 : data_small_set_add_obj( &((*this_).selected_set), *vis_id ); 82 : model_id 83 0 : = (DATA_TABLE_DIAGRAMELEMENT == data_id_get_table( vis_id )) 84 0 : ? data_full_id_get_secondary_id( &obj_id ) 85 0 : : *vis_id; 86 : } 87 : 88 : /* notify new focused element */ 89 0 : gui_marked_set_private_notify_listeners( this_, model_id ); 90 0 : } 91 : 92 0 : static inline void gui_marked_set_clear_selected_set ( gui_marked_set_t *this_ ) 93 : { 94 0 : data_small_set_clear( &((*this_).selected_set) ); 95 0 : } 96 : 97 0 : static inline void gui_marked_set_set_focused ( gui_marked_set_t *this_, 98 : data_full_id_t obj_id, 99 : data_id_t diagram_id ) 100 : { 101 0 : assert(( data_id_get_table(&diagram_id) == DATA_TABLE_DIAGRAM )||( data_id_get_table(&diagram_id) == DATA_TABLE_VOID )); 102 : 103 0 : data_full_id_replace( &((*this_).focused ), &obj_id ); 104 0 : data_id_replace( &((*this_).focused_diagram), &diagram_id ); 105 : 106 : /* notify new focused element */ 107 0 : const data_id_t *const vis_id = data_full_id_get_primary_id_const( &obj_id ); 108 0 : const data_id_t model_id 109 0 : = (DATA_TABLE_DIAGRAMELEMENT == data_id_get_table( vis_id )) 110 0 : ? data_full_id_get_secondary_id( &obj_id ) 111 0 : : *vis_id; 112 0 : gui_marked_set_private_notify_listeners( this_, model_id ); 113 0 : } 114 : 115 0 : static inline void gui_marked_set_set_highlighted ( gui_marked_set_t *this_, 116 : data_id_t obj_id, 117 : data_id_t diagram_id ) 118 : { 119 0 : assert(( data_id_get_table(&diagram_id) == DATA_TABLE_DIAGRAM )||( data_id_get_table(&diagram_id) == DATA_TABLE_VOID )); 120 0 : data_id_replace( &((*this_).highlighted), &obj_id ); 121 0 : (*this_).highlighted_kind = LAYOUT_SUBELEMENT_KIND_VOID; 122 0 : data_id_replace( &((*this_).highlighted_diagram), &diagram_id ); 123 0 : (*this_).highlighted_button = GUI_SKETCH_ACTION_NONE; 124 0 : } 125 : 126 0 : static inline void gui_marked_set_set_highlighted_subelement ( gui_marked_set_t *this_, 127 : const layout_subelement_id_t *subelement_id, 128 : data_id_t diagram_id ) 129 : { 130 0 : assert(( data_id_get_table(&diagram_id) == DATA_TABLE_DIAGRAM )||( data_id_get_table(&diagram_id) == DATA_TABLE_VOID )); 131 0 : assert( subelement_id != NULL ); 132 0 : const data_full_id_t *const full_id = layout_subelement_id_get_id_const( subelement_id ); 133 0 : data_id_replace( &((*this_).highlighted), data_full_id_get_primary_id_const( full_id ) ); 134 0 : (*this_).highlighted_kind = layout_subelement_id_get_kind( subelement_id ); 135 0 : data_id_replace( &((*this_).highlighted_diagram), &diagram_id ); 136 0 : (*this_).highlighted_button = GUI_SKETCH_ACTION_NONE; 137 0 : } 138 : 139 0 : static inline void gui_marked_set_set_highlighted_button ( gui_marked_set_t *this_, gui_sketch_action_t button_id ) 140 : { 141 0 : data_id_init_void( &((*this_).highlighted) ); 142 0 : (*this_).highlighted_kind = LAYOUT_SUBELEMENT_KIND_VOID; 143 0 : data_id_init_void( &((*this_).highlighted_diagram) ); 144 0 : (*this_).highlighted_button = button_id; 145 0 : } 146 : 147 0 : static inline void gui_marked_set_clear_focused ( gui_marked_set_t *this_ ) 148 : { 149 0 : data_full_id_reinit_void( &((*this_).focused) ); 150 : 151 : /* notify new focused element */ 152 0 : gui_marked_set_private_notify_listeners( this_, DATA_ID_VOID ); 153 0 : } 154 : 155 0 : static inline void gui_marked_set_clear_highlighted ( gui_marked_set_t *this_ ) 156 : { 157 0 : data_id_reinit_void( &((*this_).highlighted) ); 158 0 : (*this_).highlighted_kind = LAYOUT_SUBELEMENT_KIND_VOID; 159 0 : data_id_reinit_void( &((*this_).highlighted_diagram) ); 160 0 : (*this_).highlighted_button = GUI_SKETCH_ACTION_NONE; 161 0 : } 162 : 163 : 164 : /* 165 : Copyright 2016-2024 Andreas Warnke 166 : 167 : Licensed under the Apache License, Version 2.0 (the "License"); 168 : you may not use this file except in compliance with the License. 169 : You may obtain a copy of the License at 170 : 171 : http://www.apache.org/licenses/LICENSE-2.0 172 : 173 : Unless required by applicable law or agreed to in writing, software 174 : distributed under the License is distributed on an "AS IS" BASIS, 175 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 176 : See the License for the specific language governing permissions and 177 : limitations under the License. 178 : */