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

          Line data    Source code
       1             : /* File: gui_sketch_area.inl; Copyright and License: see below */
       2             : 
       3             : #include "u8/u8_log.h"
       4             : #include <assert.h>
       5             : 
       6           0 : static inline data_diagram_t *gui_sketch_area_private_get_focused_diagram_ptr ( gui_sketch_area_t *this_ )
       7             : {
       8             :     gui_sketch_card_t *result_card;
       9           0 :     result_card = &((*this_).cards[GUI_SKETCH_AREA_CONST_FOCUSED_CARD]);
      10           0 :     return gui_sketch_card_get_diagram_ptr( result_card );
      11             : }
      12             : 
      13           0 : static inline data_row_id_t gui_sketch_area_private_get_focused_diagram_id ( gui_sketch_area_t *this_ )
      14             : {
      15           0 :     const data_diagram_t *focused_diag = gui_sketch_area_private_get_focused_diagram_ptr( this_ );
      16           0 :     const data_row_id_t focused_diagram_id = data_diagram_get_row_id( focused_diag );
      17           0 :     return focused_diagram_id;
      18             : }
      19             : 
      20           0 : static inline void gui_sketch_area_private_get_diagram_and_object_id_at_pos ( gui_sketch_area_t *this_,
      21             :                                                                               int32_t x,
      22             :                                                                               int32_t y,
      23             :                                                                               data_id_t* out_diagram_id,
      24             :                                                                               data_id_t* out_object_id )
      25             : {
      26           0 :     assert( NULL != out_diagram_id );
      27           0 :     assert( NULL != out_object_id );
      28           0 :     assert( (*this_).card_num <= GUI_SKETCH_AREA_CONST_MAX_CARDS );
      29           0 :     data_id_reinit_void( out_diagram_id );
      30           0 :     data_id_reinit_void( out_object_id );
      31             : 
      32           0 :     if ( gui_sketch_nav_tree_is_visible( &((*this_).nav_tree) ) )
      33             :     {
      34           0 :         gui_sketch_nav_tree_get_object_id_at_pos( &((*this_).nav_tree), x, y, out_diagram_id );
      35           0 :         data_id_replace( out_object_id, out_diagram_id );
      36             :     }
      37           0 :     else if ( gui_sketch_result_list_is_visible( &((*this_).result_list) ) )
      38             :     {
      39           0 :         gui_sketch_result_list_get_object_id_at_pos ( &((*this_).result_list),
      40             :                                                       x,
      41             :                                                       y,
      42             :                                                       out_object_id,  /* = out_selected_id */
      43             :                                                       out_diagram_id  /* = out_diagram_id */
      44             :                                                     );
      45             :     }
      46             : 
      47           0 :     for ( int idx = 0; idx < (*this_).card_num; idx ++ )
      48             :     {
      49           0 :         const gui_sketch_card_t *card = &((*this_).cards[idx]);
      50           0 :         const shape_int_rectangle_t card_bounds = gui_sketch_card_get_bounds( card );
      51           0 :         if ( shape_int_rectangle_contains( &card_bounds, x, y ) )
      52             :         {
      53             :             const data_diagram_t *selected_diag
      54           0 :                  = gui_sketch_card_get_diagram_const( card );
      55           0 :             data_id_reinit( out_diagram_id, DATA_TABLE_DIAGRAM, data_diagram_get_row_id( selected_diag ) );
      56           0 :             data_id_replace( out_object_id, out_diagram_id );
      57           0 :             break;
      58             :         }
      59             :     }
      60           0 : }
      61             : 
      62           0 : static inline void gui_sketch_area_private_get_object_id_at_pos ( gui_sketch_area_t *this_,
      63             :                                                                   int32_t x,
      64             :                                                                   int32_t y,
      65             :                                                                   pencil_type_filter_t filter,
      66             :                                                                   data_full_id_t* out_object_id,
      67             :                                                                   data_id_t* out_diagram_id )
      68             : {
      69           0 :     assert( (*this_).card_num <= GUI_SKETCH_AREA_CONST_MAX_CARDS );
      70           0 :     assert( NULL != out_object_id );
      71           0 :     assert( NULL != out_diagram_id );
      72           0 :     data_full_id_reinit_void( out_object_id );
      73           0 :     data_id_reinit_void( out_diagram_id );
      74             : 
      75           0 :     for ( int idx = 0; idx < (*this_).card_num; idx ++ )
      76             :     {
      77           0 :         const gui_sketch_card_t *card = &((*this_).cards[idx]);
      78           0 :         const shape_int_rectangle_t card_bounds = gui_sketch_card_get_bounds( card );
      79           0 :         if ( shape_int_rectangle_contains( &card_bounds, x, y ) )
      80             :         {
      81           0 :             *out_diagram_id = gui_sketch_card_get_diagram_id( card );
      82             :             data_full_id_t surrounding_id;  /* dummy */
      83           0 :             gui_sketch_card_get_object_id_at_pos ( card, x, y, filter, out_object_id, &surrounding_id );
      84           0 :             break;
      85             :         }
      86             :     }
      87           0 : }
      88             : 
      89           0 : static inline void gui_sketch_area_private_get_object_ids_at_pos ( gui_sketch_area_t *this_,
      90             :                                                                    int32_t x,
      91             :                                                                    int32_t y,
      92             :                                                                    pencil_type_filter_t filter,
      93             :                                                                    data_full_id_t* out_object_id,
      94             :                                                                    data_full_id_t* out_surrounding_id,
      95             :                                                                    data_id_t* out_diagram_id )
      96             : {
      97           0 :     assert( (*this_).card_num <= GUI_SKETCH_AREA_CONST_MAX_CARDS );
      98           0 :     assert( NULL != out_object_id );
      99           0 :     assert( NULL != out_surrounding_id );
     100           0 :     assert( NULL != out_diagram_id );
     101           0 :     data_full_id_init_void( out_object_id );
     102           0 :     data_full_id_init_void( out_surrounding_id );
     103           0 :     data_id_reinit_void( out_diagram_id );
     104             : 
     105           0 :     for ( int idx = 0; idx < (*this_).card_num; idx ++ )
     106             :     {
     107           0 :         const gui_sketch_card_t *card = &((*this_).cards[idx]);
     108           0 :         const shape_int_rectangle_t card_bounds = gui_sketch_card_get_bounds( card );
     109           0 :         if ( shape_int_rectangle_contains( &card_bounds, x, y ) )
     110             :         {
     111           0 :             *out_diagram_id = gui_sketch_card_get_diagram_id( card );
     112           0 :             gui_sketch_card_get_object_id_at_pos ( card, x, y, filter, out_object_id, out_surrounding_id );
     113           0 :             break;
     114             :         }
     115             :     }
     116           0 : }
     117             : 
     118           0 : static inline gui_sketch_card_t *gui_sketch_area_private_get_card_at_pos ( gui_sketch_area_t *this_, int32_t x, int32_t y )
     119             : {
     120           0 :     assert( (*this_).card_num <= GUI_SKETCH_AREA_CONST_MAX_CARDS );
     121           0 :     gui_sketch_card_t *result = NULL;
     122             : 
     123           0 :     for ( int idx = 0; idx < (*this_).card_num; idx ++ )
     124             :     {
     125           0 :         gui_sketch_card_t *card = &((*this_).cards[idx]);
     126           0 :         const shape_int_rectangle_t card_bounds = gui_sketch_card_get_bounds( card );
     127           0 :         if ( shape_int_rectangle_contains( &card_bounds, x, y ) )
     128             :         {
     129           0 :             result = card;
     130           0 :             break;
     131             :         }
     132             :     }
     133           0 :     return result;
     134             : }
     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