753
s.get_height(), s_grip_size, s_grip_size ) );
757
( -s_grip_size, s.get_height(),
758
s_grip_size, s_grip_size ) );
762
( s.get_width(), -s_grip_size,
763
s_grip_size, s_grip_size ) );
782
s.get_height(), s_grip_size, s_grip_size ) );
786
( -s_grip_size, s.get_height(),
787
s_grip_size, s_grip_size ) );
791
( s.get_width(), -s_grip_size,
792
s_grip_size, s_grip_size ) );
767
796
( -s_grip_size, (s.get_height()-s_grip_size)/2,
768
s_grip_size, s_grip_size ));
772
( (s.get_width()-s_grip_size)/2,
773
s.get_height(), s_grip_size, s_grip_size ) );
777
( (s.get_width()-s_grip_size)/2, -s_grip_size,
778
s_grip_size, s_grip_size ) );
783
(s.get_height()-s_grip_size)/2,
784
s_grip_size, s_grip_size ) );
797
s_grip_size, s_grip_size ));
801
( (s.get_width()-s_grip_size)/2,
802
s.get_height(), s_grip_size, s_grip_size ) );
806
( (s.get_width()-s_grip_size)/2, -s_grip_size,
807
s_grip_size, s_grip_size ) );
812
(s.get_height()-s_grip_size)/2,
813
s_grip_size, s_grip_size ) );
785
814
} // model_view::draw_grip()
787
816
/*----------------------------------------------------------------------------*/
955
984
const snapshot* snap =
956
985
m_model.get_active_action().get_snapshot_before_or_at_date
957
986
(m_player.get_date());
962
( to_local_rect( 0, 0, snap->get_width(), snap->get_height() ) );
991
( to_local_rect( 0, 0, snap->get_width(), snap->get_height() ) );
963
992
const wxSize s( grip_size, grip_size );
964
993
wxPoint mouse_pos;
966
995
const wxRect top_left( box.GetTopLeft() - s, s );
967
996
const wxRect top_right( box.GetTopRight() - wxSize(0, grip_size), s );
968
997
const wxRect bottom_left
969
( box.GetBottomLeft() - wxSize(grip_size, 0), s );
998
( box.GetBottomLeft() - wxSize(grip_size, 0), s );
970
999
const wxRect bottom_right( box.GetBottomRight(), s );
972
1001
if ( top_left.Contains(point) )
974
m_drag_info.mouse_origin = box.GetBottomRight();
975
mouse_pos = box.GetTopLeft();
976
m_drag_info.mark_move_x = true;
1003
m_drag_info.mouse_origin = box.GetBottomRight();
1004
mouse_pos = box.GetTopLeft();
1005
m_drag_info.mark_move_x = true;
978
1007
else if ( top_right.Contains(point) )
980
m_drag_info.mouse_origin = box.GetBottomLeft();
981
mouse_pos = box.GetTopRight();
1009
m_drag_info.mouse_origin = box.GetBottomLeft();
1010
mouse_pos = box.GetTopRight();
983
1012
else if ( bottom_left.Contains(point) )
985
m_drag_info.mouse_origin = box.GetTopRight();
986
mouse_pos = box.GetBottomLeft();
987
m_drag_info.mark_move_x = true;
988
m_drag_info.mark_move_y = true;
1014
m_drag_info.mouse_origin = box.GetTopRight();
1015
mouse_pos = box.GetBottomLeft();
1016
m_drag_info.mark_move_x = true;
1017
m_drag_info.mark_move_y = true;
990
1019
else if ( bottom_right.Contains(point) )
992
m_drag_info.mouse_origin = box.GetTopLeft();
993
mouse_pos = box.GetBottomRight();
994
m_drag_info.mark_move_y = true;
1021
m_drag_info.mouse_origin = box.GetTopLeft();
1022
mouse_pos = box.GetBottomRight();
1023
m_drag_info.mark_move_y = true;
998
const wxCoord h((wxCoord)to_local_size(snap->get_height())/ 2);
999
const wxCoord w((wxCoord)to_local_size(snap->get_width())/ 2);
1000
const wxRect middle_left
1001
( box.GetLeft() - grip_size,
1002
box.GetTop() + h - grip_size / 2, grip_size, grip_size );
1003
const wxRect middle_right
1004
( box.GetRight(), box.GetTop() + h - grip_size / 2,
1005
grip_size, grip_size );
1006
const wxRect middle_bottom
1007
( box.GetLeft() + w - grip_size / 2,
1008
box.GetTop() - grip_size, grip_size, grip_size );
1009
const wxRect middle_top
1010
( box.GetLeft() + w - grip_size / 2,
1011
box.GetBottom(), grip_size, grip_size );
1013
if ( middle_left.Contains(point) )
1015
m_drag_info.mouse_origin = box.GetTopRight();
1016
mouse_pos = box.GetTopLeft();
1017
m_drag_info.y_active = false;
1018
m_drag_info.mark_move_x = true;
1020
else if ( middle_right.Contains(point) )
1022
m_drag_info.mouse_origin = box.GetTopLeft();
1023
mouse_pos = box.GetTopRight();
1024
m_drag_info.y_active = false;
1026
else if ( middle_bottom.Contains(point) )
1028
m_drag_info.mouse_origin = box.GetBottomLeft();
1029
mouse_pos = box.GetTopLeft();
1030
m_drag_info.x_active = false;
1032
else if ( middle_top.Contains(point) )
1034
m_drag_info.mouse_origin = box.GetTopLeft();
1035
mouse_pos = box.GetBottomRight();
1036
m_drag_info.x_active = false;
1037
m_drag_info.mark_move_y = true;
1027
const wxCoord h((wxCoord)to_local_size(snap->get_height())/ 2);
1028
const wxCoord w((wxCoord)to_local_size(snap->get_width())/ 2);
1029
const wxRect middle_left
1030
( box.GetLeft() - grip_size,
1031
box.GetTop() + h - grip_size / 2, grip_size, grip_size );
1032
const wxRect middle_right
1033
( box.GetRight(), box.GetTop() + h - grip_size / 2,
1034
grip_size, grip_size );
1035
const wxRect middle_bottom
1036
( box.GetLeft() + w - grip_size / 2,
1037
box.GetTop() - grip_size, grip_size, grip_size );
1038
const wxRect middle_top
1039
( box.GetLeft() + w - grip_size / 2,
1040
box.GetBottom(), grip_size, grip_size );
1042
if ( middle_left.Contains(point) )
1044
m_drag_info.mouse_origin = box.GetTopRight();
1045
mouse_pos = box.GetTopLeft();
1046
m_drag_info.y_active = false;
1047
m_drag_info.mark_move_x = true;
1049
else if ( middle_right.Contains(point) )
1051
m_drag_info.mouse_origin = box.GetTopLeft();
1052
mouse_pos = box.GetTopRight();
1053
m_drag_info.y_active = false;
1055
else if ( middle_bottom.Contains(point) )
1057
m_drag_info.mouse_origin = box.GetBottomLeft();
1058
mouse_pos = box.GetTopLeft();
1059
m_drag_info.x_active = false;
1061
else if ( middle_top.Contains(point) )
1063
m_drag_info.mouse_origin = box.GetTopLeft();
1064
mouse_pos = box.GetBottomRight();
1065
m_drag_info.x_active = false;
1066
m_drag_info.mark_move_y = true;
1045
m_drag_info.drag_mode = drag_info::drag_mode_size;
1046
m_drag_info.mouse_position = mouse_pos;
1074
m_drag_info.drag_mode = drag_info::drag_mode_size;
1075
m_drag_info.mouse_position = mouse_pos;
1051
1080
} // model_view::coordinate_in_anchors()
1053
1082
/*----------------------------------------------------------------------------*/
1055
1084
* \brief Update the position of the mouse according to the constraints.
1056
* \param mouse_position The position of the mouse in the level.
1085
* \param position The position of the mouse in the model.
1058
1087
void bf::model_view::update_mouse_position( const wxPoint& position )
1076
1105
if ( m_model.has_active_action() )
1078
1107
const snapshot* s =
1079
m_model.get_active_action().get_snapshot_before_or_at_date
1080
(m_player.get_date());
1108
m_model.get_active_action().get_snapshot_before_or_at_date
1109
(m_player.get_date());
1082
1111
snapshot::const_mark_placement_iterator it;
1084
for ( it = s->mark_placement_begin();
1085
( it!= s->mark_placement_end() ) && ( result == NULL ); ++it )
1086
if ( ( (double)point.x <= to_local_x_coordinate(it->get_position_x())
1087
+ (double)s_point_size ) &&
1088
( (double)point.x >= to_local_x_coordinate(it->get_position_x())
1089
- (double)s_point_size ) &&
1090
( (double)point.y <= to_local_y_coordinate(it->get_position_y())
1091
+ (double)s_point_size ) &&
1092
( (double)point.y >= to_local_y_coordinate(it->get_position_y())
1093
- (double)s_point_size ) )
1094
result = it->get_mark();
1113
for ( it = s->mark_placement_begin();
1114
( it!= s->mark_placement_end() ) && ( result == NULL ); ++it )
1115
if ( ( (double)point.x <= to_local_x_coordinate(it->get_position_x())
1116
+ (double)s_point_size ) &&
1117
( (double)point.x >= to_local_x_coordinate(it->get_position_x())
1118
- (double)s_point_size ) &&
1119
( (double)point.y <= to_local_y_coordinate(it->get_position_y())
1120
+ (double)s_point_size ) &&
1121
( (double)point.y >= to_local_y_coordinate(it->get_position_y())
1122
- (double)s_point_size ) )
1123
result = it->get_mark();
1123
1152
wxRect bf::model_view::get_drag_mode_size_box() const
1125
1154
CLAW_PRECOND( m_drag_info.drag_mode == drag_info::drag_mode_size );
1129
1158
const snapshot* snap =
1130
1159
m_model.get_active_action().get_snapshot_before_or_at_date
1131
1160
(m_player.get_date());
1135
1164
if ( m_drag_info.x_active )
1138
to_model_x_coordinate
1139
( std::min( m_drag_info.mouse_position.x,
1140
m_drag_info.mouse_origin.x ));
1143
( std::abs( m_drag_info.mouse_position.x -
1144
m_drag_info.mouse_origin.x ) + 1 );
1167
to_model_x_coordinate
1168
( std::min( m_drag_info.mouse_position.x,
1169
m_drag_info.mouse_origin.x ));
1172
( std::abs( m_drag_info.mouse_position.x -
1173
m_drag_info.mouse_origin.x ) + 1 );
1148
result.x = to_model_x_coordinate(m_drag_info.mouse_origin.x);
1149
result.width = (int)snap->get_width();
1177
result.x = to_model_x_coordinate(m_drag_info.mouse_origin.x);
1178
result.width = (int)snap->get_width();
1152
1181
if ( m_drag_info.y_active )
1155
to_model_y_coordinate
1156
( std::min( m_drag_info.mouse_position.y,
1157
m_drag_info.mouse_origin.y ) );
1160
( std::abs( m_drag_info.mouse_position.y -
1161
m_drag_info.mouse_origin.y ) + 1);
1184
to_model_y_coordinate
1185
( std::min( m_drag_info.mouse_position.y,
1186
m_drag_info.mouse_origin.y ) );
1189
( std::abs( m_drag_info.mouse_position.y -
1190
m_drag_info.mouse_origin.y ) + 1);
1165
result.y = to_model_y_coordinate(m_drag_info.mouse_origin.y);
1166
result.height = snap->get_height();
1194
result.y = to_model_y_coordinate(m_drag_info.mouse_origin.y);
1195
result.height = snap->get_height();
1177
1206
void bf::model_view::apply_drag_mode_size()
1179
1208
CLAW_PRECOND( m_drag_info.drag_mode == drag_info::drag_mode_size );
1181
1210
wxRect box = get_drag_mode_size_box();
1183
1212
const snapshot* snap =
1184
1213
m_model.get_active_action().get_snapshot_before_or_at_date
1185
1214
(m_player.get_date());
1189
1218
if ( (box.x != 0)
1191
|| (box.width != snap->get_width())
1192
|| (box.height != snap->get_height()) )
1194
bounding_box_event event
1195
( box.x, box.y, box.width, box.height,
1196
m_drag_info.mark_move_x, m_drag_info.mark_move_y,
1197
bounding_box_event::change_event_type, GetId() );
1198
event.SetEventObject(this);
1199
ProcessEvent(event);
1220
|| (box.width != snap->get_width())
1221
|| (box.height != snap->get_height()) )
1223
bounding_box_event event
1224
( box.x, box.y, box.width, box.height,
1225
m_drag_info.mark_move_x, m_drag_info.mark_move_y,
1226
bounding_box_event::change_event_type, GetId() );
1227
event.SetEventObject(this);
1228
ProcessEvent(event);
1202
1231
} // model_view::apply_drag_mode_size()
1204
1233
/*----------------------------------------------------------------------------*/
1206
1235
* \brief Send the event "selection_change".
1207
* \param value The name of the new selected mark.
1236
* \param label The name of the new selected mark.
1209
void bf::model_view::send_event_selection_change(const std::string& label)
1238
void bf::model_view::send_event_selection_change(const std::string& label)
1211
1240
mark_event event
1212
1241
( label, mark_event::selection_change_event_type, GetId() );