예제 #1
0
void
Relation::updateFlexibility()
{
  if (_scene->getBox(_abstract->secondBox()) != NULL) {
      if (_abstract->secondExtremity() == BOX_START && _scene->getBox(_abstract->secondBox())->hasTriggerPoint(BOX_START)) {
          _flexibleRelation = true;
        }

      else if (_abstract->secondExtremity() == BOX_END && _scene->getBox(_abstract->secondBox())->hasTriggerPoint(BOX_END)) {
          _flexibleRelation = true;
        }
      else {
          _flexibleRelation = false;
        }
    }
  else {
      _flexibleRelation = false;
    }


  double startX = mapFromScene(_start).x();
  double endX = mapFromScene(_end).x();

  if (_elasticMode) {
      _scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, NO_BOUND, NO_BOUND);
    }
  else if (!_flexibleRelation) {
      _scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, (endX - startX) / _scene->zoom(), (endX - startX) / _scene->zoom() + RIGID_TOLERANCE);
    }
  else {
      changeBounds(0, NO_BOUND);
      _scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, _abstract->minBound(), _abstract->maxBound());
    }
}
예제 #2
0
void
Relation::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
{
  QGraphicsItem::mouseMoveEvent(event);
  double eventPosX = mapFromScene(event->scenePos()).x();
  double startX = mapFromScene(_start).x();

  if (_leftHandleSelected) {
      changeBounds(_abstract->maxBound() == NO_BOUND ? std::max(eventPosX - startX, 0.) : std::min((float)std::max(eventPosX - startX, 0.), _abstract->maxBound()), _abstract->maxBound());
      _scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, _abstract->minBound(), _abstract->maxBound());
      update();
    }
  else if (_rightHandleSelected) {
      _scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, _abstract->minBound(), std::max((float)std::max(eventPosX - startX, 0.), _abstract->minBound()));
      update();
    }
  else if (_middleHandleSelected) {
      BasicBox *rightBox = _scene->getBox(_abstract->secondBox());
      _scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, NO_BOUND, NO_BOUND);
      qreal factorX = 2 * (eventPosX - _mouseClickPosSave.x());
      rightBox->moveBy(factorX, 0.);
      rightBox->setTopLeft(rightBox->getTopLeft() + QPointF(factorX, 0.));
      rightBox->updateStuff();
      _scene->boxMoved(rightBox->ID());
    }
}
예제 #3
0
void
Relation::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
{
  QGraphicsItem::mouseDoubleClickEvent(event);
  float maxBound;
  if (!_scene->playing()) {
      if (!_flexibleRelation) {
          _middleHandleSelected = false;
          _elasticMode = !_elasticMode;
          updateFlexibility();
        }
      else if (_abstract->maxBound() == NO_BOUND || _lastMaxBound != -1) {
          if (_lastMaxBound != -1) {
              maxBound = std::max(_lastMaxBound * _scene->zoom(), (float)(mapFromScene(_end).x() - mapFromScene(_start).x() + LINE_WIDTH));
            }
          else {
              maxBound = (mapFromScene(_end).x() - mapFromScene(_start).x() + LINE_WIDTH);
            }

          changeBounds(_abstract->minBound(), maxBound);
          _scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, _abstract->minBound(), maxBound / _scene->zoom());
          _lastMaxBound = -1;
        }
      else {
          _lastMaxBound = _abstract->maxBound();
          changeBounds(_abstract->minBound(), NO_BOUND);
          _scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, _abstract->minBound(), NO_BOUND);
        }

//        else{
//          RelationEdit * relEdit = new RelationEdit(_scene,_abstract->ID(),_scene->views().first());
//          relEdit->move(mapToScene(boundingRect().topLeft()).x(),mapToScene(boundingRect().topLeft()).y());
//          relEdit->exec();
//          delete relEdit;
//        }
    }
}
예제 #4
0
파일: TPROGRAM.cpp 프로젝트: gdobra/tvision
void TProgram::setScreenMode( ushort mode )
{
    TRect  r;

    TEventQueue::mouse.hide(); //HideMouse();
    TScreen::setVideoMode( mode );
    initScreen();
    buffer = TScreen::screenBuffer;
    r = TRect( 0, 0, TScreen::screenWidth, TScreen::screenHeight );
    changeBounds( r );
    setState(sfExposed, False);
    setState(sfExposed, True);
    redraw();
    TEventQueue::mouse.show(); //ShowMouse();
}
예제 #5
0
void TProgram::setScreenMode( ushort mode )
{
    TRect  r;

#ifndef __NT__
    TEventQueue::mouse.hide(); //HideMouse();
#endif
    TScreen::setVideoMode( mode );
    initScreen();
    buffer = (ushort far *)TScreen::screenBuffer;
    r = TRect( 0, 0, TScreen::screenWidth, TScreen::screenHeight );
    changeBounds( r );
    setState(sfExposed, False);
//    redraw(); useless, exposure is disabled
    setState(sfExposed, True);
#ifndef __NT__
    TEventQueue::mouse.show(); //ShowMouse();
#endif
}
예제 #6
0
LH_CursorController::LH_CursorController()
{
    updating_link_data_ = false;
    setup_link_json_data_ = new LH_Qt_QString(this, "Cursor Data", "", LH_FLAG_NOSAVE_DATA | LH_FLAG_NOSINK | LH_FLAG_READONLY | LH_FLAG_HIDEVALUE /*| LH_FLAG_HIDDEN*/);
    setup_link_json_data_->setHelp("<p>This field holds the data for this cursor; all cursor objects by default link themselves to \"Primary Cursor\".</p>"
                                   "<p>You only need change the name of this link if your layout needs more than one cursor.");

    setup_link_postback_ = new LH_Qt_QString(this, "Cursor Postback", "", LH_FLAG_NOSAVE_DATA | LH_FLAG_NOSOURCE | LH_FLAG_READONLY | LH_FLAG_HIDDEN);

    setup_link_current_pos = new LH_Qt_QString(this, "Cursor Position", "", LH_FLAG_NOSAVE_DATA | LH_FLAG_NOSINK | LH_FLAG_READONLY  /* | LH_FLAG_HIDDEN*/);
    setup_link_current_pos->setHelp("<p>Displays the coordinates of the cursor at present, as well as whether the controller is currently active:</p>"
                                    "<p>(x,y) [active]</p>"
                                    "<p>This is mainly provided for advanced layout designers if they want to link something to the current cursor position.</p>");

    setup_link_selected_pos = new LH_Qt_QString(this, "Selected Position", "", LH_FLAG_NOSAVE_DATA | LH_FLAG_NOSINK | LH_FLAG_READONLY  /* | LH_FLAG_HIDDEN*/);
    setup_link_selected_pos->setHelp("<p>Displays the coordinates of the selected point at present, as well as whether the controller is currently active:</p>"
                                     "<p>(x,y) [active]</p>"
                                     "<p>This is mainly provided for advanced layout designers if they want to link something to the current selection position.</p>");

    //setup_link_postback_->setLinkFilter("CursorPostback");
    //setup_link_json_data_->setLinkFilter("Cursors");

    setup_cursor_active_ = new LH_Qt_bool(this, "Active", cursor_data_.active, LH_FLAG_NOSAVE_DATA | LH_FLAG_NOSINK | LH_FLAG_READONLY | LH_FLAG_HIDDEN);
    setup_cursor_sel_x_ = new LH_Qt_int(this, "X (Selected)", cursor_data_.x, LH_FLAG_NOSAVE_DATA | LH_FLAG_NOSINK | LH_FLAG_READONLY | LH_FLAG_HIDDEN);
    setup_cursor_sel_y_ = new LH_Qt_int(this, "Y (Selected)", cursor_data_.y, LH_FLAG_NOSAVE_DATA | LH_FLAG_NOSINK | LH_FLAG_READONLY | LH_FLAG_HIDDEN);
    setup_cursor_x_ = new LH_Qt_int(this, "X (Current)", cursor_data_.x, LH_FLAG_NOSAVE_DATA | LH_FLAG_NOSINK | LH_FLAG_READONLY | LH_FLAG_HIDDEN);
    setup_cursor_y_ = new LH_Qt_int(this, "Y (Current)", cursor_data_.y, LH_FLAG_NOSAVE_DATA | LH_FLAG_NOSINK | LH_FLAG_READONLY | LH_FLAG_HIDDEN);

    new LH_Qt_QString(this, "hr1", "<hr>", LH_FLAG_NOSOURCE | LH_FLAG_NOSINK | LH_FLAG_HIDETITLE, lh_type_string_html );

    setup_coordinate_ = new LH_Qt_QString(this, "Coordinate", "1,1", LH_FLAG_NOSAVE_DATA | LH_FLAG_READONLY | LH_FLAG_FIRST | LH_FLAG_HIDDEN);
    setup_coordinate_->setHelp("The current cursor location.");

    cursorModes.append((cursorMode){smSelectDeselect, true , "Activate, Move & Select / Deselect"});
    cursorModes.append((cursorMode){smSelect        , true , "Activate, Move & Select Only (one is always selected)"});
    cursorModes.append((cursorMode){smNone          , true , "Activate & Move Only (Highlighted option is selected)"});
    cursorModes.append((cursorMode){smNone          , false, "Move Only (Highlighted option is selected, always activated)"});
    cursorModes.append((cursorMode){smSelectDeselect, false, "Move & Select / Deselect Only (Always activated)"});
    cursorModes.append((cursorMode){smSelect        , false, "Move & Select Only (Always activated)"});

    //cursor_data_ = (cursorData){1,1,false,0,0,false,0,0,false,false,0,0,(bounds){(minmax){0,0},(minmax){0,0}}};

    QStringList modeNames = QStringList();
    foreach(cursorMode cm, cursorModes) modeNames.append(cm.description);
    setup_mode_ = new LH_Qt_QStringList(this,"Cursor Mode",modeNames,LH_FLAG_AUTORENDER);
    setup_mode_->setHelp("This allows the user to select how the cursor should behave. Each cursor mode is a combination of several options:<br/>"
                         "<br/>"
                         "<ul>"
                         "<li><b>Activate</b></br>"
                         "If a mode includes \"activation\" then in it's default state the cursor is hidden and nothing happens when using the movement or selection keys. Insetad the user must first press the activation key to display the cursor. Whilst active the cursor is visible, can be moved and, if appropriate, items can be selected and deselected. If activation is not included in the mode, then the cursor is assumed to always be active.</li>"
                         "<li><b>Select</b></br>"
                         "For modes that include selecting, the user must first move the cursor over the desired option and then press the select key before anything happens. If a mode does not include selection, then simply moving the cursor changes the selection immediately.</li>"
                         "</li>"
                         "<li><b>Deselect</b></br>"
                         "Some modes have select/deselect behaviour, specified by this option. With this ability the user can \"turn off\" everything; without it there will always be one item selected.</li>"
                         "</li>"
                         "</ul>");
    connect( setup_mode_, SIGNAL(changed()), this, SLOT(changeMode()) );

    setup_boundry_ = new LH_Qt_QString(this,"Boundries","1,1,3,3",0);
    setup_boundry_->setHelp("This box should contain the borders of the \"box\" the cusror can move in.</br></br>The format is [left],[top],[right],[bottom] <br/><br/>e.g.:<br/>\"1,1,1,4\" would denote a box one column wide and four rows high<br/>\"1,1,3,3\" would be a square of three columns and three rows.");
    connect( setup_boundry_, SIGNAL(changed()), this, SLOT(changeBounds()) );
    setup_boundry_loop_ = new LH_Qt_bool(this, "Loop at edges", false);
    setup_boundry_loop_->setHelp("By default when at the furthest edge of the box the cursor stops. Ticking this however will change that so that moving off one edge will bring the cursor back in on the opposite side.");

    setup_invalid_coordinates_ = new LH_Qt_QString(this,"Invalid Points\n(x,y;x,y;x,y)","",0);
    setup_invalid_coordinates_->setHelp("If you wish to create a \"void\" in the cusrsor space, this allows you to do so. List all the points here that the cursor is not allowed to land on and it will be prevented from doing so either by jumping over the invlid points to the next valid one or simply by blocking its movement.<br/><br/>The format is [x1],[y1];[x2],[y2];[x3][y3]; etc...<br/>e.g.: for the boundry \"1,1,2,5\" the invalid points \"1,2;1,3;1,4\" would prevent the cursor landing on any of the top three middle cells, creating a \"U\"-like shape.");
    setup_jump_invalid_ = new LH_Qt_bool(this, "Jump over invalid points", true);
    setup_jump_invalid_->setHelp("By default when the cursor tries to move onto an invlid point it \"jumps\" the cell in question, and keeps moving in the same direction until reaching one where it is allowed to be. Alternatively, checking this box will prevent this, turning invalid points into \"walls\" that have to be moved around manually.");

    setup_move_up_ = new LH_Qt_InputState(this,"Up","",0);
    setup_move_up_->setHelp("The key used to move the cursor up, usually the up key from the LCD control");
    connect( setup_move_up_, SIGNAL(input(QString,int,int)), this, SLOT(doMoveUp(QString,int,int)) );

    setup_move_down_ = new LH_Qt_InputState(this,"Down","",0);
    setup_move_down_->setHelp("The key used to move the cursor down, usually the down key from the LCD control");
    connect( setup_move_down_, SIGNAL(input(QString,int,int)), this, SLOT(doMoveDown(QString,int,int)) );

    setup_move_left_ = new LH_Qt_InputState(this,"Left","",0);
    setup_move_left_->setHelp("The key used to move the cursor left, usually the left key from the LCD control");
    connect( setup_move_left_, SIGNAL(input(QString,int,int)), this, SLOT(doMoveLeft(QString,int,int)) );

    setup_move_right_ = new LH_Qt_InputState(this,"Right","",0);
    setup_move_right_->setHelp("The key used to move the cursor right, usually the right key from the LCD control");
    connect( setup_move_right_, SIGNAL(input(QString,int,int)), this, SLOT(doMoveRight(QString,int,int)) );

    setup_select_ = new LH_Qt_InputState(this,"Select","",0);
    setup_select_->setHelp("The key used to select the currently highlighted option, usually the Ok key from the LCD control");
    connect( setup_select_, SIGNAL(input(QString,int,int)), this, SLOT(doSelect(QString,int,int)) );

    setup_reselect_ = new LH_Qt_InputState(this,"Reselect","",0);
    setup_reselect_->setHelp("The key used to reselect the previously selected highlighted option. Usually this is unused, but is very useful for menu layouts where it acts as a \"return to last layout\" (or cancel) command");
    connect( setup_reselect_, SIGNAL(input(QString,int,int)), this, SLOT(doReselect(QString,int,int)) );

    setup_activate_ = new LH_Qt_InputState(this,"Enable","",0);
    setup_activate_->setHelp("The key used to activate the cursor control");
    connect( setup_activate_, SIGNAL(input(QString,int,int)), this, SLOT(doActivate(QString,int,int)) );

    setup_persistent_ = new LH_Qt_bool(this,"Persistent Selection",false);
    setup_persistent_->setHelp("Ticking this box will cause the system to automatically recall the cursor's last position whether you save the layout or not.<br/><br/>This is mainly of use within menu layouts and allows the menu to open with the last selected option still highlighted.");
    setup_persistent_autoselect_ = new LH_Qt_bool(this,"Auto-reselect",false, LH_FLAG_HIDDEN);
    setup_persistent_autoselect_->setHelp("When recovering a persited selection, this option determins if the option is merely highlighed (i.e. the cursor is positioned on it) or if the option is actually selected.");
    setup_persistent_file_ = new LH_Qt_QFileInfo(this, "Persistence File", QFileInfo(), LH_FLAG_HIDDEN);
    setup_persistent_file_->setHelp("The file in which to save the persisted location.<br/><br/>Note that you can use this to make serveral layouts work together as though they were all parts of the same layout by pointing them all to this file, thus causing the cursor position to persist accross them.");

#ifdef ENABLE_VIRTUAL_CURSOR_KEYS
    setup_virtual_keys_ = new LH_Qt_html(this, 0, LH_FLAG_NOSOURCE | LH_FLAG_NOSINK | LH_FLAG_LAST );
    setup_virtual_keys_->setTitle("<hr><center><table>"
                                 "<tr><td>  </td><td style='background-color:silver;'><center><a href='up'>[  Up  ]</a></center></td><td>  </td><td>         </td><td style='background-color:silver;'><center><a href='act'>[ Act ]</a></center></td></tr>"
                                 "<tr><td style='background-color:silver;'><center><a href='left'>[Left]</a></center></td><td style='background-color:silver;'><center><a href='sel'>[  OK  ]</a></center></td><td style='background-color:silver;'><center><a href='right'>[Right]</a></center></td><td>  </td></tr>"
                                 "<tr><td>  </td><td style='background-color:silver;'><center><a href='down'>[Down]</a></center></td><td>  </td><td>  </td><td style='background-color:silver;'><center><a href='resel'>[  Re  ]</a></center></td></tr>"
                                 "</table></center>");
    connect(setup_virtual_keys_, SIGNAL(change(QString)), this, SLOT(virtualKeyPress(QString)) );
#endif

    connect(setup_link_postback_,SIGNAL(set()),this,SLOT(processPostback()));
    connect(setup_link_postback_,SIGNAL(changed()),this,SLOT(processPostback()));
    connect(setup_persistent_, SIGNAL(changed()), this, SLOT(changePersistent()));
    connect(setup_persistent_file_, SIGNAL(changed()), this, SLOT(loadPersistedSelection()));

    connect(setup_cursor_active_, SIGNAL(changed()), this, SLOT(changeCursorData()));
    connect(setup_cursor_sel_x_, SIGNAL(changed()), this, SLOT(changeCursorData()));
    connect(setup_cursor_sel_y_, SIGNAL(changed()), this, SLOT(changeCursorData()));
    connect(setup_cursor_x_, SIGNAL(changed()), this, SLOT(changeCursorData()));
    connect(setup_cursor_y_, SIGNAL(changed()), this, SLOT(changeCursorData()));

    connect(setup_cursor_active_, SIGNAL(set()), this, SLOT(changeCursorData()));
    connect(setup_cursor_sel_x_, SIGNAL(set()), this, SLOT(changeCursorData()));
    connect(setup_cursor_sel_y_, SIGNAL(set()), this, SLOT(changeCursorData()));
    connect(setup_cursor_x_, SIGNAL(set()), this, SLOT(changeCursorData()));
    connect(setup_cursor_y_, SIGNAL(set()), this, SLOT(changeCursorData()));

    connect(this, SIGNAL(initialized()), this, SLOT(initialiseLinking()));

    updateLocation(0,0);

#ifdef LH_CF
    add_cf_target(setup_cursor_active_);
    add_cf_source(setup_cursor_active_);
    add_cf_target(setup_cursor_sel_x_);
    add_cf_source(setup_cursor_sel_x_);
    add_cf_target(setup_cursor_sel_y_);
    add_cf_source(setup_cursor_sel_y_);
    add_cf_target(setup_cursor_x_);
    add_cf_source(setup_cursor_x_);
    add_cf_target(setup_cursor_y_);
    add_cf_source(setup_cursor_y_);
#endif

}