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

          Line data    Source code
       1             : /* File: gui_sketch_drag_state.inl; Copyright and License: see below */
       2             : 
       3           0 : static inline void gui_sketch_drag_state_init ( gui_sketch_drag_state_t *this_ )
       4             : {
       5           0 :     (*this_).dragging = false;
       6           0 :     (*this_).from_x = 0;
       7           0 :     (*this_).from_y = 0;
       8           0 :     (*this_).to_x = 0;
       9           0 :     (*this_).to_y = 0;
      10           0 :     (*this_).start_dragging_when_move = false;
      11           0 :     data_full_id_init_void ( &((*this_).dragged_object) );
      12           0 : }
      13             : 
      14           0 : static inline void gui_sketch_drag_state_reinit ( gui_sketch_drag_state_t *this_ )
      15             : {
      16           0 :     gui_sketch_drag_state_init( this_ );
      17           0 : }
      18             : 
      19           0 : static inline void gui_sketch_drag_state_destroy ( gui_sketch_drag_state_t *this_ )
      20             : {
      21           0 :     data_full_id_destroy ( &((*this_).dragged_object) );
      22           0 : }
      23             : 
      24           0 : static inline bool gui_sketch_drag_state_is_dragging ( const gui_sketch_drag_state_t *this_ )
      25             : {
      26           0 :     return ( (*this_).dragging );
      27             : }
      28             : 
      29           0 : static inline void gui_sketch_drag_state_stop_dragging ( gui_sketch_drag_state_t *this_ )
      30             : {
      31           0 :     (*this_).dragging = false;
      32           0 :     (*this_).start_dragging_when_move = false;
      33           0 : }
      34             : 
      35           0 : static inline bool gui_sketch_drag_state_is_waiting_for_move ( const gui_sketch_drag_state_t *this_ )
      36             : {
      37           0 :     return ( (*this_).start_dragging_when_move );
      38             : }
      39             : 
      40           0 : static inline void gui_sketch_drag_state_start_dragging_when_move ( gui_sketch_drag_state_t *this_,
      41             :                                                                     data_full_id_t dragged_object )
      42             : {
      43           0 :     (*this_).dragged_object = dragged_object;
      44           0 :     (*this_).start_dragging_when_move = true;
      45           0 : }
      46             : 
      47           0 : static inline int32_t gui_sketch_drag_state_get_from_x ( const gui_sketch_drag_state_t *this_ )
      48             : {
      49           0 :     return ( (*this_).from_x );
      50             : }
      51             : 
      52           0 : static inline int32_t gui_sketch_drag_state_get_from_y ( const gui_sketch_drag_state_t *this_ )
      53             : {
      54           0 :     return ( (*this_).from_y );
      55             : }
      56             : 
      57           0 : static inline void gui_sketch_drag_state_set_from ( gui_sketch_drag_state_t *this_, int32_t from_x, int32_t from_y )
      58             : {
      59           0 :     (*this_).from_x = from_x;
      60           0 :     (*this_).from_y = from_y;
      61           0 : }
      62             : 
      63           0 : static inline int32_t gui_sketch_drag_state_get_to_x ( const gui_sketch_drag_state_t *this_ )
      64             : {
      65           0 :     return ( (*this_).to_x );
      66             : }
      67             : 
      68           0 : static inline int32_t gui_sketch_drag_state_get_to_y ( const gui_sketch_drag_state_t *this_ )
      69             : {
      70           0 :     return ( (*this_).to_y );
      71             : }
      72             : 
      73           0 : static inline void gui_sketch_drag_state_set_to ( gui_sketch_drag_state_t *this_, int32_t to_x, int32_t to_y )
      74             : {
      75           0 :     (*this_).to_x = to_x;
      76           0 :     (*this_).to_y = to_y;
      77           0 :     if ( (*this_).start_dragging_when_move )
      78             :     {
      79             :         static const uint32_t ACTIVATION_BORDER = 2;
      80           0 :         int32_t activation_border_left = (*this_).from_x - ACTIVATION_BORDER;
      81           0 :         int32_t activation_border_right = (*this_).from_x + ACTIVATION_BORDER;
      82           0 :         int32_t activation_border_top = (*this_).from_y - ACTIVATION_BORDER;
      83           0 :         int32_t activation_border_bottom = (*this_).from_y + ACTIVATION_BORDER;
      84           0 :         if ( ( to_x > activation_border_right ) || ( to_x < activation_border_left )
      85           0 :             || ( to_y > activation_border_bottom ) || ( to_y < activation_border_top ) )
      86             :         {
      87           0 :             (*this_).dragging = true;
      88           0 :             (*this_).start_dragging_when_move = false;
      89             :         }
      90             :     }
      91           0 : }
      92             : 
      93           0 : static inline data_full_id_t *gui_sketch_drag_state_get_dragged_object_ptr ( gui_sketch_drag_state_t *this_ )
      94             : {
      95           0 :     return ( &((*this_).dragged_object) );
      96             : }
      97             : 
      98             : 
      99             : /*
     100             : Copyright 2016-2024 Andreas Warnke
     101             : 
     102             : Licensed under the Apache License, Version 2.0 (the "License");
     103             : you may not use this file except in compliance with the License.
     104             : You may obtain a copy of the License at
     105             : 
     106             :     http://www.apache.org/licenses/LICENSE-2.0
     107             : 
     108             : Unless required by applicable law or agreed to in writing, software
     109             : distributed under the License is distributed on an "AS IS" BASIS,
     110             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     111             : See the License for the specific language governing permissions and
     112             : limitations under the License.
     113             : */

Generated by: LCOV version 1.16