1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
/* File: gui_sketch_drag_state.h; Copyright and License: see below */
#ifndef GUI_SKETCH_DRAG_STATE_H
#define GUI_SKETCH_DRAG_STATE_H
/* public file for the doxygen documentation: */
/*! \file
* \brief keeps track of the dragging state: dragging is started by button-press and mouse-movement.
*/
#include "set/data_full_id.h"
#include <stdbool.h>
#include <stdint.h>
/*!
* \brief attributes of the drag state
*/
struct gui_sketch_drag_state_struct {
bool dragging; /*!< true if an object is currently being dragged */
int32_t from_x; /*!< x coordingate of the origin */
int32_t from_y; /*!< y coordingate of the origin */
int32_t to_x; /*!< x coordingate of the destination */
int32_t to_y; /*!< y coordingate of the destination */
bool start_dragging_when_move; /*!< true if dragging shall start when moving */
data_full_id_t dragged_object; /* primary_id is the dragged object or diagramelement, secondary_id is the classifier */
};
typedef struct gui_sketch_drag_state_struct gui_sketch_drag_state_t;
/*!
* \brief initializes the gui_sketch_drag_state_t struct
*
* \param this_ pointer to own object attributes
*/
static inline void gui_sketch_drag_state_init ( gui_sketch_drag_state_t *this_ );
/*!
* \brief re-initializes the gui_sketch_drag_state_t struct
*
* \param this_ pointer to own object attributes
*/
static inline void gui_sketch_drag_state_reinit ( gui_sketch_drag_state_t *this_ );
/*!
* \brief destroys the gui_sketch_drag_state_t struct
*
* \param this_ pointer to own object attributes
*/
static inline void gui_sketch_drag_state_destroy ( gui_sketch_drag_state_t *this_ );
/*!
* \brief gets the dragging attribute
*
* \param this_ pointer to own object attributes
* \return true if an object is currently being dragged
*/
static inline bool gui_sketch_drag_state_is_dragging ( const gui_sketch_drag_state_t *this_ );
/*!
* \brief sets the dragging attribute
*
* \param this_ pointer to own object attributes
*/
static inline void gui_sketch_drag_state_stop_dragging ( gui_sketch_drag_state_t *this_ );
/*!
* \brief checks if the start_dragging_when_move attribute is set.
*
* \param this_ pointer to own object attributes
* \return true the mouse button was pressed and the pending drag is not yet cancelled
*/
static inline bool gui_sketch_drag_state_is_waiting_for_move ( const gui_sketch_drag_state_t *this_ );
/*!
* \brief sets the dragging attribute to true as soon as the to position has moved a small distance
*
* \param this_ pointer to own object attributes
* \param dragged_object primary_id is the dragged object or diagramemelent, secondary_id is the classifier
*/
static inline void gui_sketch_drag_state_start_dragging_when_move ( gui_sketch_drag_state_t *this_,
data_full_id_t dragged_object
);
/*!
* \brief gets the from_x attribute
*
* \param this_ pointer to own object attributes
* \return x coordinate of the dragging origin
*/
static inline int32_t gui_sketch_drag_state_get_from_x ( const gui_sketch_drag_state_t *this_ );
/*!
* \brief gets the from_y attribute
*
* \param this_ pointer to own object attributes
* \return y coordinate of the dragging origin
*/
static inline int32_t gui_sketch_drag_state_get_from_y ( const gui_sketch_drag_state_t *this_ );
/*!
* \brief sets the from_x and from_y attributes
*
* \param this_ pointer to own object attributes
* \param from_x x coordinate of the dragging origin
* \param from_y y coordinate of the dragging origin
*/
static inline void gui_sketch_drag_state_set_from ( gui_sketch_drag_state_t *this_, int32_t from_x, int32_t from_y );
/*!
* \brief gets the to_x attribute
*
* \param this_ pointer to own object attributes
* \return x coordinate of the dragging destination
*/
static inline int32_t gui_sketch_drag_state_get_to_x ( const gui_sketch_drag_state_t *this_ );
/*!
* \brief gets the to_y attribute
*
* \param this_ pointer to own object attributes
* \return y coordinate of the dragging destination
*/
static inline int32_t gui_sketch_drag_state_get_to_y ( const gui_sketch_drag_state_t *this_ );
/*!
* \brief sets the to_x and to_y attributes
*
* \param this_ pointer to own object attributes
* \param to_x x coordinate of the dragging destination
* \param to_y y coordinate of the dragging destination
*/
static inline void gui_sketch_drag_state_set_to ( gui_sketch_drag_state_t *this_, int32_t to_x, int32_t to_y );
/*!
* \brief gets the dragged object
*
* \param this_ pointer to own object attributes
* \return primary_id is the dragged object or diagramemelent, secondary_id is the classifier
*/
static inline data_full_id_t *gui_sketch_drag_state_get_dragged_object_ptr ( gui_sketch_drag_state_t *this_ );
#include "gui_sketch_drag_state.inl"
#endif /* GUI_SKETCH_DRAG_STATE_H */
/*
Copyright 2016-2023 Andreas Warnke
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
|