Added sketch for rectangular draw.

presentation
Wilson Brenna 12 years ago
parent cb6711b7a1
commit 28b6263328
  1. 78
      src/control/ToolHandler.cpp
  2. 9
      src/control/ToolHandler.h
  3. 33
      src/control/tools/InputHandler.cpp
  4. 6
      src/gui/toolbarMenubar/ToolMenuHandler.cpp

@ -219,6 +219,24 @@ bool ToolHandler::isEnableRuler()
return current->enableRuler;
}
bool ToolHandler::isEnableRectangle()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableRectangle;
}
bool ToolHandler::isEnableCircle()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableCircle;
}
bool ToolHandler::isEnableArrow()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableArrow;
}
bool ToolHandler::isEnableShapreRecognizer()
{
@ -233,6 +251,24 @@ void ToolHandler::setRuler(bool ruler)
this->current->ruler = ruler;
}
void ToolHandler::setRectangle(bool rectangle)
{
XOJ_CHECK_TYPE(ToolHandler);
this->current->rectangle = rectangle;
}
void ToolHandler::setCircle(bool circle)
{
XOJ_CHECK_TYPE(ToolHandler);
this->current->circle = circle;
}
void ToolHandler::setArrow(bool arrow)
{
XOJ_CHECK_TYPE(ToolHandler);
this->current->arrow = arrow;
}
bool ToolHandler::isRuler()
{
@ -240,6 +276,24 @@ bool ToolHandler::isRuler()
return this->current->ruler;
}
bool ToolHandler::isRectangle()
{
XOJ_CHECK_TYPE(ToolHandler);
return this->current->rectangle;
}
bool ToolHandler::isCircle()
{
XOJ_CHECK_TYPE(ToolHandler);
return this->current->circle;
}
bool ToolHandler::isArrow()
{
XOJ_CHECK_TYPE(ToolHandler);
return this->current->arrow;
}
void ToolHandler::setShapeRecognizer(bool reco)
{
@ -414,6 +468,18 @@ void ToolHandler::saveSettings()
{
st.setBool("ruler", t->isRuler());
}
else if (t->isEnableRectangle())
{
st.setBool("rectangle", t->isRectangle());
}
else if (t->isEnableCircle())
{
st.setBool("circle", t->isCircle());
}
else if (t->isEnableArrow())
{
st.setBool("arrow", t->isArrow());
}
if (t->isEnableShapeRecognizer())
{
st.setBool("shapeRecognizer", t->isShapeRecognizer());
@ -498,6 +564,18 @@ void ToolHandler::loadSettings()
{
t->setRuler(enabled);
}
else if (t->isEnableRectangle() && st.getBool("rectangle", enabled))
{
t->setRectangle(enabled);
}
else if (t->isEnableCircle() && st.getBool("circle", enabled))
{
t->setCircle(enabled);
}
else if (t->isEnableArrow() && st.getBool("arrow", enabled))
{
t->setArrow(enabled);
}
if (t->isEnableShapeRecognizer() && st.getBool("shapeRecognizer", enabled))
{
t->setShapeRecognizer(enabled);

@ -40,7 +40,13 @@ public:
GdkColor getGdkColor();
void setRuler(bool ruler);
void setRectangle(bool rectangle);
void setCircle(bool circle);
void setArrow(bool arrow);
bool isRuler();
bool isRectangle();
bool isCircle();
bool isArrow();
void setShapeRecognizer(bool reco);
bool isShapeRecognizer();
@ -70,6 +76,9 @@ public:
bool isEnableColor();
bool isEnableSize();
bool isEnableRuler();
bool isEnableRectangle();
bool isEnableCircle();
bool isEnableArrow();
bool isEnableShapreRecognizer();
void saveSettings();

@ -92,15 +92,44 @@ void InputHandler::addPointToTmpStroke(GdkEventMotion* event)
}
else if (h->isRectangle())
{
printf("Drawing rectangle\n");
int count = tmpStroke->getPointCount();
this->redrawable->repaintRect(tmpStroke->getX(), tmpStroke->getY(),
tmpStroke->getElementWidth(),
tmpStroke->getElementHeight());
if (count < 2)
{
tmpStroke->addPoint(Point(x,y));
}
else
{
//Point p = tmpStroke->getPoint(0);
if (count > 3)
{
tmpStroke->deletePoint(4);
tmpStroke->deletePoint(3);
tmpStroke->deletePoint(2);
tmpStroke->deletePoint(1);
}
tmpStroke->addPoint(Point(x,tmpStroke->getY()));
tmpStroke->addPoint(Point(x,y));
tmpStroke->addPoint(tmpStroke->getX(),y);
tmpStroke->setLastPoint(tmpStroke->getX(),tmpStroke->getY());
}
drawTmpStroke(true);
return;
}
else if (h->isCircle())
{
printf("Drawing circle\n");
return;
}
else if (h->isArrow())
{
printf("Drawing arrow\n");
return;
}
if (presureSensitivity)

@ -537,15 +537,15 @@ void ToolMenuHandler::initToolItems()
"object-select.png", _("Select Object"), gui->get("menuToolsSelectObject")));
addToolItem(new ToolButton(listener, gui, "DRAW_CIRCLE",
ACTION_TOOL_DRAW_CIRCLE, GROUP_RULER, true, "lasso.png",
ACTION_TOOL_DRAW_CIRCLE, GROUP_RULER, true, "circle-draw.png",
_("Draw Circle"), gui->get("menuToolsDrawCircle")));
addToolItem(new ToolButton(listener, gui, "DRAW_RECTANGLE",
ACTION_TOOL_DRAW_RECT, GROUP_RULER, true,
"rect-select.png", _("Draw Rectangle"),
"rect-draw.png", _("Draw Rectangle"),
gui->get("menuToolsDrawRect")));
addToolItem(new ToolButton(listener, gui, "DRAW_ARROW",
ACTION_TOOL_DRAW_ARROW, GROUP_RULER, true,
"object-select.png", _("Draw Arrow"), gui->get("menuToolsDrawArrow")));
"arrow-draw.png", _("Draw Arrow"), gui->get("menuToolsDrawArrow")));
addToolItem(new ToolButton(listener, gui, "VERTICAL_SPACE",
ACTION_TOOL_VERTICAL_SPACE, GROUP_TOOL, true,

Loading…
Cancel
Save