Rectf EditorInputCenter::tile_drag_rect() { Rectf result = drag_rect(); result.p1 = sp_to_tp(result.p1); result.p2 = sp_to_tp(result.p2); return result; }
void EditorInputCenter::rubber_rect() { delete_markers(); Rectf dr = drag_rect(); for (auto& moving_object : Editor::current()->currentsector->moving_objects) { Rectf bbox = moving_object->get_bbox(); if (bbox.p2.x >= dr.p1.x && bbox.p1.x <= dr.p2.x && bbox.p2.y >= dr.p1.y && bbox.p1.y <= dr.p2.y ) { moving_object->editor_delete(); } } last_node_marker = NULL; }
void DragonView::MouseMoved( BPoint where, uint32 code, const BMessage *msg ) { // If we're already dragging, we don't care. if( _am_dragging ) return; // If the primary mouse button isn't down, or the mouse is just entering // the view, we just return... no drag is starting. if( !_button_down || code == B_ENTERED_VIEW ) return; // If the mouse has travelled "far enough", we start a drag. In this // case, "far enough" is measured by the number of pixels the user's // chosen in the "Drag Threshold" submenu of the "File" menu. // // A real application would probably have a slider for picking the // threshold values. float dx = fabs( where.x - _button_click.x ); float dy = fabs( where.y - _button_click.y ); if( dx >= _drag_threshold || dy >= _drag_threshold ) { // Start a drag! _bits_mutex.Lock(); _am_dragging = true; // Create our drag message. BMessage *drag_message = _MakeDragMessage(); // Create a new bitmap or rectangle (if the bitmap would be too // large) to drag around. BRect drag_rect( _bits->Bounds() ); BBitmap *drag_bitmap = _MakeDragBitmap(); _bits_mutex.Unlock(); if( drag_bitmap ) { DragMessage( drag_message, drag_bitmap, B_OP_ALPHA, where, this ); } else { DragMessage( drag_message, drag_rect, this ); } delete drag_message; } }
void EditorInputCenter::draw_rectangle() { Rectf dr = drag_rect(); dr.p1 = sp_to_tp(dr.p1); dr.p2 = sp_to_tp(dr.p2); bool sgn_x = drag_start.x < sector_pos.x; bool sgn_y = drag_start.y < sector_pos.y; int x_, y_; x_ = sgn_x ? 0 : -dr.get_width(); for (int x = dr.p1.x; x <= dr.p2.x; x++, x_++) { y_ = sgn_y ? 0 : -dr.get_height(); for (int y = dr.p1.y; y <= dr.p2.y; y++, y_++) { input_tile( Vector(x, y), Editor::current()->tileselect.tiles->pos(x_, y_) ); } } }