LCOV - code coverage report
Current view: top level - gui/include - gui_marked_set.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 0 63 0.0 %
Date: 2024-04-07 11:14:42 Functions: 0 14 0.0 %

          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 data_id_t gui_marked_set_get_highlighted ( const gui_marked_set_t *this_ )
      26             : {
      27           0 :     return( (*this_).highlighted );
      28             : }
      29             : 
      30           0 : static inline data_id_t gui_marked_set_get_highlighted_diagram ( const gui_marked_set_t *this_ )
      31             : {
      32           0 :     return( (*this_).highlighted_diagram );
      33             : }
      34             : 
      35           0 : static inline gui_sketch_action_t gui_marked_set_get_highlighted_button ( const gui_marked_set_t *this_ )
      36             : {
      37           0 :     return( (*this_).highlighted_button );
      38             : }
      39             : 
      40           0 : static inline const data_small_set_t *gui_marked_set_get_selected_set_const ( const gui_marked_set_t *this_ )
      41             : {
      42           0 :     return ( &((*this_).selected_set) );
      43             : }
      44             : 
      45             : static inline void gui_marked_set_toggle_selected_obj ( gui_marked_set_t *this_, data_id_t obj_id )
      46             : {
      47             :     data_small_set_toggle_obj( &((*this_).selected_set), obj_id );
      48             : }
      49             : 
      50           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 )
      51             : {
      52           0 :     assert(( data_id_get_table(&diagram_id) == DATA_TABLE_DIAGRAM )||( data_id_get_table(&diagram_id) == DATA_TABLE_VOID ));
      53           0 :     const data_id_t *const vis_id = data_full_id_get_primary_id_ptr( &obj_id );
      54             : 
      55             :     data_id_t model_id;
      56           0 :     if ( data_full_id_equals( &obj_id, &((*this_).focused) ) )
      57             :     {
      58             :         /* clear focus: */
      59           0 :         data_full_id_reinit_void( &((*this_).focused) );
      60           0 :         data_id_replace( &((*this_).focused_diagram), &diagram_id );
      61             :         /* remove from selection: */
      62           0 :         data_small_set_delete_obj( &((*this_).selected_set), *vis_id );
      63           0 :         model_id = DATA_ID_VOID;
      64             :     }
      65             :     else
      66             :     {
      67             :         /* set focus: */
      68           0 :         data_full_id_replace( &((*this_).focused), &obj_id );
      69           0 :         data_id_replace( &((*this_).focused_diagram), &diagram_id );
      70             :         /* add to selection: */
      71           0 :         data_small_set_add_obj( &((*this_).selected_set), *vis_id );
      72             :         model_id
      73           0 :             = (DATA_TABLE_DIAGRAMELEMENT == data_id_get_table( vis_id ))
      74           0 :             ? data_full_id_get_secondary_id( &obj_id )
      75           0 :             : *vis_id;
      76             :     }
      77             : 
      78             :     /* notify new focused element */
      79           0 :     gui_marked_set_private_notify_listeners( this_, model_id );
      80           0 : }
      81             : 
      82           0 : static inline void gui_marked_set_clear_selected_set ( gui_marked_set_t *this_ )
      83             : {
      84           0 :     data_small_set_clear( &((*this_).selected_set) );
      85           0 : }
      86             : 
      87           0 : static inline void gui_marked_set_set_focused ( gui_marked_set_t *this_,
      88             :                                                 data_full_id_t obj_id,
      89             :                                                 data_id_t diagram_id  )
      90             : {
      91           0 :     assert(( data_id_get_table(&diagram_id) == DATA_TABLE_DIAGRAM )||( data_id_get_table(&diagram_id) == DATA_TABLE_VOID ));
      92             : 
      93           0 :     data_full_id_replace( &((*this_).focused ), &obj_id );
      94           0 :     data_id_replace( &((*this_).focused_diagram), &diagram_id );
      95             : 
      96             :     /* notify new focused element */
      97           0 :     const data_id_t *const vis_id = data_full_id_get_primary_id_ptr( &obj_id );
      98           0 :     const data_id_t model_id
      99           0 :         = (DATA_TABLE_DIAGRAMELEMENT == data_id_get_table( vis_id ))
     100           0 :         ? data_full_id_get_secondary_id( &obj_id )
     101           0 :         : *vis_id;
     102           0 :     gui_marked_set_private_notify_listeners( this_, model_id );
     103           0 : }
     104             : 
     105           0 : static inline void gui_marked_set_set_highlighted ( gui_marked_set_t *this_,
     106             :                                                     data_id_t obj_id,
     107             :                                                     data_id_t diagram_id  )
     108             : {
     109           0 :     assert(( data_id_get_table(&diagram_id) == DATA_TABLE_DIAGRAM )||( data_id_get_table(&diagram_id) == DATA_TABLE_VOID ));
     110           0 :     data_id_replace( &((*this_).highlighted), &obj_id );
     111           0 :     data_id_replace( &((*this_).highlighted_diagram), &diagram_id );
     112           0 :     (*this_).highlighted_button = GUI_SKETCH_ACTION_NONE;
     113           0 : }
     114             : 
     115           0 : static inline void gui_marked_set_set_highlighted_button ( gui_marked_set_t *this_, gui_sketch_action_t button_id )
     116             : {
     117           0 :     data_id_init_void( &((*this_).highlighted) );
     118           0 :     data_id_init_void( &((*this_).highlighted_diagram) );
     119           0 :     (*this_).highlighted_button = button_id;
     120           0 : }
     121             : 
     122           0 : static inline void gui_marked_set_clear_focused ( gui_marked_set_t *this_ )
     123             : {
     124           0 :     data_full_id_reinit_void( &((*this_).focused) );
     125             : 
     126             :     /* notify new focused element */
     127           0 :     gui_marked_set_private_notify_listeners( this_, DATA_ID_VOID );
     128           0 : }
     129             : 
     130           0 : static inline void gui_marked_set_clear_highlighted ( gui_marked_set_t *this_ )
     131             : {
     132           0 :     data_id_reinit_void( &((*this_).highlighted) );
     133           0 :     data_id_reinit_void( &((*this_).highlighted_diagram) );
     134           0 : }
     135             : 
     136             : 
     137             : /*
     138             : Copyright 2016-2024 Andreas Warnke
     139             : 
     140             : Licensed under the Apache License, Version 2.0 (the "License");
     141             : you may not use this file except in compliance with the License.
     142             : You may obtain a copy of the License at
     143             : 
     144             :     http://www.apache.org/licenses/LICENSE-2.0
     145             : 
     146             : Unless required by applicable law or agreed to in writing, software
     147             : distributed under the License is distributed on an "AS IS" BASIS,
     148             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     149             : See the License for the specific language governing permissions and
     150             : limitations under the License.
     151             : */

Generated by: LCOV version 1.16