+ y->first = editor_y_to_summary (_editor->vertical_adjustment.get_value ());
+ y->second = editor_y_to_summary (_editor->vertical_adjustment.get_value () + _editor->canvas_height() - _editor->get_canvas_timebars_vsize());
+}
+
+/** Get an expression of the position of a point with respect to the view rectangle */
+EditorSummary::Position
+EditorSummary::get_position (double x, double y) const
+{
+ /* how close the mouse has to be to the edge of the view rectangle to be considered `on it',
+ in pixels */
+
+ int x_edge_size = (_view_rectangle_x.second - _view_rectangle_x.first) / 4;
+ x_edge_size = min (x_edge_size, 8);
+ x_edge_size = max (x_edge_size, 1);
+
+ int y_edge_size = (_view_rectangle_y.second - _view_rectangle_y.first) / 4;
+ y_edge_size = min (y_edge_size, 8);
+ y_edge_size = max (y_edge_size, 1);
+
+ bool const near_left = (std::abs (x - _view_rectangle_x.first) < x_edge_size);
+ bool const near_right = (std::abs (x - _view_rectangle_x.second) < x_edge_size);
+ bool const near_top = (std::abs (y - _view_rectangle_y.first) < y_edge_size);
+ bool const near_bottom = (std::abs (y - _view_rectangle_y.second) < y_edge_size);
+ bool const within_x = _view_rectangle_x.first < x && x < _view_rectangle_x.second;
+ bool const within_y = _view_rectangle_y.first < y && y < _view_rectangle_y.second;
+
+ if (near_left && near_top) {
+ return LEFT_TOP;
+ } else if (near_left && near_bottom) {
+ return LEFT_BOTTOM;
+ } else if (near_right && near_top) {
+ return RIGHT_TOP;
+ } else if (near_right && near_bottom) {
+ return RIGHT_BOTTOM;
+ } else if (near_left && within_y) {
+ return LEFT;
+ } else if (near_right && within_y) {
+ return RIGHT;
+ } else if (near_top && within_x) {
+ return TOP;
+ } else if (near_bottom && within_x) {
+ return BOTTOM;
+ } else if (within_x && within_y) {
+ return INSIDE;
+ } else if (within_x) {
+ return BELOW_OR_ABOVE;
+ } else if (within_y) {
+ return TO_LEFT_OR_RIGHT;
+ } else {
+ return OTHERWISE_OUTSIDE;
+ }
+}
+
+void
+EditorSummary::set_cursor (Position p)
+{
+ switch (p) {
+ case LEFT:
+ get_window()->set_cursor (*_editor->_cursors->resize_left);
+ break;
+ case LEFT_TOP:
+ get_window()->set_cursor (*_editor->_cursors->resize_top_left);
+ break;
+ case TOP:
+ get_window()->set_cursor (*_editor->_cursors->resize_top);
+ break;
+ case RIGHT_TOP:
+ get_window()->set_cursor (*_editor->_cursors->resize_top_right);
+ break;
+ case RIGHT:
+ get_window()->set_cursor (*_editor->_cursors->resize_right);
+ break;
+ case RIGHT_BOTTOM:
+ get_window()->set_cursor (*_editor->_cursors->resize_bottom_right);
+ break;
+ case BOTTOM:
+ get_window()->set_cursor (*_editor->_cursors->resize_bottom);
+ break;
+ case LEFT_BOTTOM:
+ get_window()->set_cursor (*_editor->_cursors->resize_bottom_left);
+ break;
+ case INSIDE:
+ get_window()->set_cursor (*_editor->_cursors->move);
+ break;
+ case TO_LEFT_OR_RIGHT:
+ get_window()->set_cursor (*_editor->_cursors->expand_left_right);
+ break;
+ case BELOW_OR_ABOVE:
+ get_window()->set_cursor (*_editor->_cursors->expand_up_down);
+ break;
+ default:
+ get_window()->set_cursor ();
+ break;
+ }