* ./hurricane/src/hviewer :

- Change: In RulerCommand, key & mouse now mimic Cadence behavior.
This commit is contained in:
Jean-Paul Chaput 2009-12-03 11:19:54 +00:00
parent e208fbeb2f
commit dcf39378c5
3 changed files with 31 additions and 21 deletions

View File

@ -185,7 +185,7 @@ namespace Hurricane {
_clearRulersAction = new QAction ( tr("Clear Rulers"), this );
_clearRulersAction->setObjectName ( "viewer.menuBar.view.clearRulers" );
_clearRulersAction->setStatusTip ( tr("Remove all rulers") );
_clearRulersAction->setShortcut ( QKeySequence(tr("CTRL+R")) );
//_clearRulersAction->setShortcut ( QKeySequence(tr("K")) );
_controllerAction = new QAction ( tr("Controller"), this );
_controllerAction->setObjectName ( "viewer.menuBar.tools.controller" );

View File

@ -43,6 +43,7 @@ namespace Hurricane {
RulerCommand::RulerCommand ()
: Command ()
, _ruler ()
, _drawing(false)
{ }
@ -56,7 +57,7 @@ namespace Hurricane {
void RulerCommand::mouseMoveEvent ( QMouseEvent* event )
{
if ( !isActive() ) return;
if ( not isActive() or not _drawing ) return;
_ruler->setExtremity ( _cellWidget->_onCursorGrid(_cellWidget->screenToDbuPoint(event->pos())) );
_cellWidget->update ();
@ -65,38 +66,46 @@ namespace Hurricane {
void RulerCommand::mousePressEvent ( QMouseEvent* event )
{
if ( (event->modifiers() & Qt::ShiftModifier )
and (event->button() == Qt::LeftButton ) ) {
setActive ( true );
if ( not isActive() ) return;
if ( event->button() == Qt::LeftButton ) {
if ( not _drawing ) {
_drawing = true;
_ruler.reset ( new Ruler
(_cellWidget->_onCursorGrid(_cellWidget->screenToDbuPoint(_cellWidget->getMousePosition())) ) );
return;
}
if ( isActive() ) {
if ( event->button() != Qt::RightButton )
_cellWidget->addRuler ( _ruler );
} else {
setActive ( false );
_drawing = false;
_cellWidget->addRuler ( _ruler );
_ruler.reset ();
}
}
}
void RulerCommand::keyPressEvent ( QKeyEvent* event )
{
if ( !isActive() ) return;
if ( event->key() == Qt::Key_Escape ) {
if ( isActive() and (event->key() == Qt::Key_Escape) ) {
setActive ( false );
_drawing = false;
_ruler.reset ();
return;
}
if ( event->key() != Qt::Key_K ) return;
if ( event->modifiers() & Qt::ShiftModifier ) {
_cellWidget->clearRulers ();
return;
}
setActive ( true );
}
void RulerCommand::draw ()
{
if ( !isActive() ) return;
if ( not _drawing ) return;
_cellWidget->drawRuler ( _ruler );
}

View File

@ -47,9 +47,10 @@ namespace Hurricane {
private:
RulerCommand ( const RulerCommand& );
RulerCommand& operator= ( const RulerCommand& );
protected:
private:
static string _name;
std::tr1::shared_ptr<Ruler> _ruler;
bool _drawing;
};