Add Delete button alongside Selection editing handles - handy for keyboardless users.

presentation
JJones780 7 years ago
parent 84a028452b
commit 63e601ee51
  1. 1
      src/control/tools/CursorSelectionType.h
  2. 53
      src/control/tools/EditSelection.cpp
  3. 9
      src/control/tools/EditSelection.h
  4. 3
      src/gui/Cursor.cpp

@ -29,4 +29,5 @@ enum CursorSelectionType
CURSOR_SELECTION_TOP,
CURSOR_SELECTION_BOTTOM,
CURSOR_SELECTION_ROTATE,
CURSOR_SELECTION_DELETE
};

@ -389,14 +389,22 @@ void EditSelection::mouseUp()
{
XOJ_CHECK_TYPE(EditSelection);
PageRef page = this->view->getPage();
Layer* layer = page->getSelectedLayer();
snapRotation();
if (this->mouseDownType == CURSOR_SELECTION_DELETE )
{
this->view->getXournal()->deleteSelection();
}
else
{
PageRef page = this->view->getPage();
Layer* layer = page->getSelectedLayer();
this->contents->updateContent(this->x, this->y, this->rotation, this->width, this->height, this->aspectRatio,
layer, page, this->view, this->undo, this->mouseDownType);
snapRotation();
this->contents->updateContent(this->x, this->y, this->rotation, this->width, this->height, this->aspectRatio,
layer, page, this->view, this->undo, this->mouseDownType);
}
this->mouseDownType = CURSOR_SELECTION_NONE;
}
@ -690,6 +698,12 @@ CursorSelectionType EditSelection::getSelectionTypeForPos(double x, double y, do
return CURSOR_SELECTION_BOTTOM_RIGHT;
}
if ( (((x2-x1)*3.0)/4.0) + x1 - 4*zoom <=x && (((x2-x1)*3.0)/4.0) + x1 + 4*zoom >=x && (y1-10*zoom) - 4*zoom <= y && (y1-10*zoom) + 4*zoom >= y)
{
return CURSOR_SELECTION_DELETE;
}
if (supportRotation && x2 + BORDER_PADDING + 4 <= x && x <= x2 + BORDER_PADDING + 16 && (y2 + y1) / 2 - 4 <= y && (y2 + y1) / 2 + 4 >= y)
{
return CURSOR_SELECTION_ROTATE;
@ -758,7 +772,7 @@ void EditSelection::snapRotation()
/**
* Paints the selection to cr, with the given zoom factor. The coordinates of cr
* should be relative to the provideded view by getView() (use translateEvent())
* should be relative to the provided view by getView() (use translateEvent())
*/
void EditSelection::paint(cairo_t* cr, double zoom)
{
@ -832,6 +846,9 @@ void EditSelection::paint(cairo_t* cr, double zoom)
drawAnchorRect(cr, x, y + height, zoom);
// bottom right
drawAnchorRect(cr, x + width, y + height, zoom);
drawDeleteRect(cr, x + (3 * width)/4, y - 10 , zoom);
}
void EditSelection::drawAnchorRotation(cairo_t* cr, double x, double y, double zoom)
@ -861,6 +878,28 @@ void EditSelection::drawAnchorRect(cairo_t* cr, double x, double y, double zoom)
cairo_fill(cr);
}
/**
* draws an idicator where you can delete the selection
*/
void EditSelection::drawDeleteRect(cairo_t* cr, double x, double y, double zoom)
{
XOJ_CHECK_TYPE(EditSelection);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_rectangle(cr, x * zoom - 4, y * zoom - 4, 8, 8);
cairo_stroke(cr);
cairo_set_source_rgb(cr, 1, 0, 0);
cairo_move_to(cr, x * zoom - 4, y * zoom - 4);
cairo_rel_move_to(cr, 8,0);
cairo_rel_line_to(cr, -8,8);
cairo_rel_move_to(cr, 8,0);
cairo_rel_line_to(cr, -8,-8);
cairo_stroke(cr);
}
XojPageView* EditSelection::getView()
{
XOJ_CHECK_TYPE(EditSelection);

@ -212,6 +212,15 @@ private:
*/
void drawAnchorRotation(cairo_t* cr, double x, double y, double zoom);
/**
* Draws an indicator where you can delete the selection
*/
void drawDeleteRect(cairo_t* cr, double x, double y, double zoom);
/**
* Finishes all pending changes, move the elements, scale the elements and add
* them to new layer if any or to the old if no new layer

@ -183,6 +183,9 @@ void Cursor::updateCursor()
case CURSOR_SELECTION_ROTATE:
cursor = gdk_cursor_new_for_display(gdk_window_get_display(window), GDK_EXCHANGE);
break;
case CURSOR_SELECTION_DELETE:
cursor = gdk_cursor_new_for_display(gdk_window_get_display(window), GDK_PIRATE);
break;
case CURSOR_SELECTION_TOP:
case CURSOR_SELECTION_BOTTOM:
cursor = gdk_cursor_new_for_display(gdk_window_get_display(window), GDK_SB_V_DOUBLE_ARROW);

Loading…
Cancel
Save