Finished manually updating out-of-boundary selection.

presentation
Wilson Brenna 12 years ago
parent 8c0ea393cb
commit 82591806f4
  1. 6
      src/control/tools/Selection.cpp
  2. 27
      src/gui/PageView.cpp
  3. 45
      src/gui/PageView.h
  4. 6
      src/gui/pageposition/PagePosition.cpp
  5. 36
      src/gui/pageposition/PagePosition.h
  6. 9
      src/gui/pageposition/PagePositionHandler.h

@ -99,6 +99,9 @@ bool RectSelection::finalize(PageRef page)
}
}
view->repaintArea(this->x1 - 10, this->y1 - 10,
this->x2 + 10, this->y2 + 10);
return this->selectedElements != NULL;
}
@ -423,6 +426,9 @@ bool RegionSelect::finalize(PageRef page)
}
}
view->repaintArea(this->x1Box - 10, this->y1Box - 10,
this->x2Box + 10, this->y2Box + 10);
return this->selectedElements != NULL;
}

@ -148,17 +148,27 @@ void PageView::deleteViewBuffer()
g_mutex_unlock(&this->drawingMutex);
}
bool PageView::containsPoint(int x, int y)
bool PageView::containsPoint(int x, int y, bool local)
{
XOJ_CHECK_TYPE(PageView);
bool leftOk = this->layout.getLayoutAbsoluteX() <= x;
bool rightOk = x <= this->layout.getLayoutAbsoluteX() + this->getDisplayWidth();
bool topOk = this->layout.getLayoutAbsoluteY() <= y;
bool bottomOk = y <= this->layout.getLayoutAbsoluteY() +
this->getDisplayHeight();
if(!local)
{
bool leftOk = this->layout.getLayoutAbsoluteX() <= x;
bool rightOk = x <= this->layout.getLayoutAbsoluteX() + this->getDisplayWidth();
bool topOk = this->layout.getLayoutAbsoluteY() <= y;
bool bottomOk = y <= this->layout.getLayoutAbsoluteY() +
this->getDisplayHeight();
return leftOk && rightOk && topOk && bottomOk;
return leftOk && rightOk && topOk && bottomOk;
}
else
{
return x >= 0 &&
y >= 0 &&
x <= this->getWidth() &&
y <= this->getHeight();
}
}
bool PageView::searchTextOnPage(const char* text, int* occures, double* top)
@ -530,7 +540,8 @@ bool PageView::onMotionNotifyEvent(GtkWidget* widget, GdkEventMotion* event)
ToolHandler* h = xournal->getControl()->getToolHandler();
if (this->inputHandler->onMotionNotifyEvent(event))
if (containsPoint(x, y, true) &&
this->inputHandler->onMotionNotifyEvent(event))
{
//input handler used this event
}

@ -70,7 +70,11 @@ public:
void deleteViewBuffer();
bool containsPoint(int x, int y);
/**
* Returns whether this PageView contains the
* given point on the display
*/
bool containsPoint(int x, int y, bool local = false);
bool containsY(int y);
GdkColor getSelectionColor();
@ -83,15 +87,52 @@ public:
*/
int getLastVisibleTime();
TextEditor* getTextEditor();
/**
* Returns a reference to the XojPage belonging to
* this PageView
*/
PageRef getPage();
XournalView* getXournal();
double getHeight();
/**
* Returns the width of this PageView
*/
double getWidth();
/**
* Returns the height of this PageView
*/
double getHeight();
/**
* Returns the width of this PageView as displayed
* on the display taking into account the current zoom
*/
int getDisplayWidth();
/**
* Returns the height of this PageView as displayed
* on the display taking into account the current zoom
*/
int getDisplayHeight();
/**
* Returns the x coordinate of this PageView with
* respect to the display
*/
int getX();
/**
* Returns the y coordinate of this PageView with
* respect to the display
*/
int getY();
/**
* Maps a Rectangle from display coordinates to local
* coordinates
*/
virtual Rectangle* rectOnWidget(double x, double y, double width,
double height);

@ -68,21 +68,21 @@ PageView* PagePosition::getViewAt(int x, int y)
return NULL;
}
bool PagePosition::containsY(int y)
bool PagePosition::containsY(int y) const
{
XOJ_CHECK_TYPE(PagePosition);
return (y >= this->y1 && y <= this->y2);
}
bool PagePosition::isYSmallerThan(int y)
bool PagePosition::isYSmallerThan(int y) const
{
XOJ_CHECK_TYPE(PagePosition);
return y > this->y2;
}
bool PagePosition::isYGraterThan(int y)
bool PagePosition::isYGraterThan(int y) const
{
XOJ_CHECK_TYPE(PagePosition);

@ -17,6 +17,9 @@
class PageView;
/**
* @brief A set of PageView%s within an interval of y coordinates
*/
class PagePosition
{
public:
@ -25,19 +28,46 @@ public:
virtual ~PagePosition();
public:
/**
* Adds a PageView to this PagePosition provided that the
* y interval is not split up
*
* @return whether or not the PageView was added
*/
bool add(PageView* pv);
bool containsY(int y);
bool isYSmallerThan(int y);
bool isYGraterThan(int y);
/**
* Returns whether or not the given y value is in
* the current interval
*/
bool containsY(int y) const;
/**
* Returns whether the given y value is below the
* current interval
*/
bool isYSmallerThan(int y) const;
/**
* Returns whether the given y value is above the
* current interval
*/
bool isYGraterThan(int y) const;
/**
* Returns the PageView containing the given
* point display point
*/
PageView* getViewAt(int x, int y);
private:
XOJ_TYPE_ATTRIB;
// the minimal/maximal y coordinates
int y1;
int y2;
// a list of PageViews
GList* views;
friend class PagePositionHandler;

@ -19,6 +19,12 @@ class PageView;
class PagePosition;
class PagePositionCache;
/**
* @brief Look up PageView%s from display coordinates
*
* The PagePositionHandler maintains a set of PagePosition%s
* sorted according to their respective intervals
*/
class PagePositionHandler
{
public:
@ -28,6 +34,9 @@ public:
public:
void update(PageView** viewPages, int viewPagesLen, int maxY);
/**
* Returns the PageView with the given coordinates
*/
PageView* getViewAt(int x, int y, PagePositionCache* cache = NULL);
PageView* getBestMatchingView(int x, int y, int width, int heigth);

Loading…
Cancel
Save