void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    if (!Delegate() || !Delegate()->mouseMoveEvent(event))
    {
        QGraphicsTextItem::mouseMoveEvent(event);
    }
}
UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) :
    QGraphicsTextItem(parent)
    , UBGraphicsItem()
    , mMultiClickState(0)
    , mLastMousePressTime(QTime::currentTime())
{
    setDelegate(new UBGraphicsTextItemDelegate(this, 0));

    // TODO claudio remove this because in contrast with the fact the frame should be created on demand.
    Delegate()->createControls();
    Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
    Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, false);
    Delegate()->setUBFlag(GF_REVOLVABLE, true);

    mTypeTextHereLabel = tr("<Type Text Here>");

    setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
    setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly


    setFlag(QGraphicsItem::ItemIsSelectable, true);
    setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

    setTextInteractionFlags(Qt::TextEditorInteraction);

    setUuid(QUuid::createUuid());

    connect(document(), SIGNAL(contentsChanged()), Delegate(), SLOT(contentsChanged()));
    connect(document(), SIGNAL(undoCommandAdded()), this, SLOT(undoCommandAdded()));

    connect(document()->documentLayout(), SIGNAL(documentSizeChanged(const QSizeF &)),
            this, SLOT(documentSizeChanged(const QSizeF &)));

}
void UBGraphicsTextItem::setSelected(bool selected)
{
    if(selected){
        Delegate()->createControls();
        Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
    }
    QGraphicsTextItem::setSelected(selected);
}
void UBGraphicsTextItem::resize(qreal w, qreal h)
{
    setTextWidth(w);
    setTextHeight(h);

    if (Delegate())
        Delegate()->positionHandles();
}
QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
    QVariant newValue = value;

    if(Delegate())
        newValue = Delegate()->itemChange(change, value);

    return QGraphicsTextItem::itemChange(change, newValue);
}
void
IMenuListener::Events
::RemoveListener(IMenuListener::Pointer l)
{
  if (l.IsNull()) return;

  menuAboutToShow -= Delegate(l.GetPointer(), &IMenuListener::MenuAboutToShow);
  menuAboutToHide -= Delegate(l.GetPointer(), &IMenuListener::MenuAboutToHide);
}
InstructionsMenuPage::InstructionsMenuPage(Menu *menu, SaveGameManager *savedGames) : IMenuPage(menu)
{
	this->savedGames = savedGames;
	
	menuButton = new Input_Button();
	if(AppConfig::Instance().IsIpad())
	{
		menuButton->SetSpriteAndBounds(12, 15, CR::AssetList::menu_menu_buttons);
		menuButton->DesignSize(69,30);
	}
	else
		menuButton->SetSpriteAndBounds(12, 11, CR::AssetList::menu_menu_buttons);
	menuButton->SetSoundOn(true);
	menuButton->OnClicked += Delegate(this, &InstructionsMenuPage::OnMenuButtonClicked);
	input_objects.push_back(menuButton);
	
	nextButton = new Input_Button();
	if(AppConfig::Instance().IsIpad())
	{
		nextButton->SetSpriteAndBounds(394, 268, CR::AssetList::button_next);
		nextButton->DesignSize(78,47);
	}
	else
		nextButton->SetSpriteAndBounds(420, 277, CR::AssetList::button_next);
	nextButton->SetSoundOn(true);
	nextButton->OnClicked += Delegate(this, &InstructionsMenuPage::OnNextButtonClicked);
	input_objects.push_back(nextButton);
	
	prevButton = new Input_Button();
	if(AppConfig::Instance().IsIpad())
	{
		prevButton->SetSpriteAndBounds(394, 268, CR::AssetList::button_previous);
		prevButton->DesignSize(78,47);
	}
	else
		prevButton->SetSpriteAndBounds(420, 277, CR::AssetList::button_previous);
	prevButton->SetSoundOn(true);
	prevButton->OnClicked += Delegate(this, &InstructionsMenuPage::OnPrevButtonClicked);
	prevButton->Disabled(true);
	input_objects.push_back(prevButton);
	
	instructions01 = graphics_engine->CreateSprite1();
	instructions01->SetImage(CR::AssetList::menu_instructions_01);
	instructions01->SetPositionAbsalute(240, 160);
	if(AppConfig::Instance().IsIpad())
		instructions01->SetDesignSize(480,320);
	
	instructions02 = graphics_engine->CreateSprite1();
	instructions02->SetImage(CR::AssetList::menu_instructions_02);
	instructions02->SetPositionAbsalute(240, 160);
	if(AppConfig::Instance().IsIpad())
		instructions02->SetDesignSize(480,320);
	
	currPage = 1;
}
void
IControlListener::Events
::RemoveListener(IControlListener::Pointer l)
{
  if (l.IsNull()) return;

  movedEvent -= Delegate(l.GetPointer(), &IControlListener::ControlMoved);
  resizedEvent -= Delegate(l.GetPointer(), &IControlListener::ControlResized);
  activatedEvent -= Delegate(l.GetPointer(), &IControlListener::ControlActivated);
  destroyedEvent -= Delegate(l.GetPointer(), &IControlListener::ControlDestroyed);
}
void
IWindowListener::Events
::RemoveListener(IWindowListener::Pointer listener)
{
  if (listener.IsNull()) return;

  windowActivated -= Delegate(listener.GetPointer(), &IWindowListener::WindowActivated);
  windowDeactivated -= Delegate(listener.GetPointer(), &IWindowListener::WindowDeactivated);
  windowClosed -= Delegate(listener.GetPointer(), &IWindowListener::WindowClosed);
  windowOpened -= Delegate(listener.GetPointer(), &IWindowListener::WindowOpened);
}
void
IWindowListener::Events
::RemoveListener(IWindowListener* listener)
{
  if (listener == nullptr) return;

  windowActivated -= Delegate(listener, &IWindowListener::WindowActivated);
  windowDeactivated -= Delegate(listener, &IWindowListener::WindowDeactivated);
  windowClosed -= Delegate(listener, &IWindowListener::WindowClosed);
  windowOpened -= Delegate(listener, &IWindowListener::WindowOpened);
}
QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVariant &value)
{

    QVariant newValue = value;

    if (Delegate())
    {
        newValue = Delegate()->itemChange(change, value);
    }

    return QGraphicsRectItem::itemChange(change, newValue);
}
Exemple #12
0
void
IPartListener::Events
::AddListener(IPartListener::Pointer l)
{
  if (l.IsNull()) return;

  Types t = l->GetPartEventTypes();

  if (t & ACTIVATED)
    partActivated += Delegate(l.GetPointer(), &IPartListener::PartActivated);
  if (t & BROUGHT_TO_TOP)
    partBroughtToTop += Delegate(l.GetPointer(), &IPartListener::PartBroughtToTop);
  if (t & CLOSED)
    partClosed += Delegate(l.GetPointer(), &IPartListener::PartClosed);
  if (t & DEACTIVATED)
    partDeactivated += Delegate(l.GetPointer(), &IPartListener::PartDeactivated);
  if (t & OPENED)
    partOpened += Delegate(l.GetPointer(), &IPartListener::PartOpened);
  if (t & HIDDEN)
    partHidden += Delegate(l.GetPointer(), &IPartListener::PartHidden);
  if (t & VISIBLE)
    partVisible += Delegate(l.GetPointer(), &IPartListener::PartVisible);
  if (t & INPUT_CHANGED)
    partInputChanged += Delegate(l.GetPointer(), &IPartListener::PartInputChanged);
}
void UBGraphicsPathItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    if(mMultiClickState == 0){
        Delegate()->mouseMoveEvent(event);
        UBAbstractGraphicsPathItem::mouseMoveEvent(event);
    }
}
void UBEditableGraphicsRegularShapeItem::updateHandle(UBAbstractHandle *handle)
{
    prepareGeometryChange();

    Delegate()->showFrame(false);

    QPointF diff = handle->pos() - path().boundingRect().topLeft();

    qreal maxSize = handle->radius() * 4;

    if(diff.x() < maxSize) {
        handle->setX(handle->pos().x() + (maxSize - diff.x()));
    }

    if(diff.y() < maxSize) {
        handle->setY(handle->pos().y() + (maxSize - diff.y()));
    }

    updatePath(handle->pos());

    if(hasGradient()) {
        QLinearGradient g(path().boundingRect().topLeft(), path().boundingRect().topRight());

        g.setColorAt(0, brush().gradient()->stops().at(0).second);
        g.setColorAt(1, brush().gradient()->stops().at(1).second);

        setBrush(g);
    }

}
UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
    : QGraphicsPixmapItem(parent)
{
    setDelegate(new UBGraphicsItemDelegate(this, 0, true, false, true, true));
    Delegate()->init();
    Delegate()->setFlippable(true);
    Delegate()->setRotatable(true);

    setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
    setTransformationMode(Qt::SmoothTransformation);

    setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
    setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

    setUuid(QUuid::createUuid()); //more logical solution is in creating uuid for element in element's constructor
}
Exemple #16
0
void UBAbstractEditableGraphicsShapeItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    if(mMultiClickState == 0){
        Delegate()->mouseMoveEvent(event);
        UBAbstractGraphicsItem::mouseMoveEvent(event);
    }
}
Exemple #17
0
bool EffectChangePitch::Process()
{
#if USE_SBSMS
   if (mUseSBSMS)
   {
      double pitchRatio = 1.0 + m_dPercentChange / 100.0;
      EffectSBSMS proxy;
      proxy.mProxyEffectName = XO("High Quality Pitch Change");
      proxy.setParameters(1.0, pitchRatio);

      return Delegate(proxy, mUIParent, false);
   }
   else
#endif
   {
      mSoundTouch = std::make_unique<SoundTouch>();
      IdentityTimeWarper warper;
      mSoundTouch->setPitchSemiTones((float)(m_dSemitonesChange));
#ifdef USE_MIDI
      // Pitch shifting note tracks is currently only supported by SoundTouchEffect
      // and non-real-time-preview effects require an audio track selection.
      //
      // Note: m_dSemitonesChange is private to ChangePitch because it only
      // needs to pass it along to mSoundTouch (above). I added mSemitones
      // to SoundTouchEffect (the super class) to convey this value
      // to process Note tracks. This approach minimizes changes to existing
      // code, but it would be cleaner to change all m_dSemitonesChange to
      // mSemitones, make mSemitones exist with or without USE_MIDI, and
      // eliminate the next line:
      mSemitones = m_dSemitonesChange;
#endif
      return EffectSoundTouch::ProcessWithTimeWarper(warper);
   }
}
Exemple #18
0
void ClothDemo::InitializeDebugGui()
{
	stiffness = 1;
	restlength = 3;
	tearlength = 10;
	frameSolvesPerFrame = 1;

	this->gridDisplay->ClickAndDrag = true;

	VerticalDebugMenu::WatchFloatSlider("Rest Length", &restlength, 0.5f, 10.0f);
	VerticalDebugMenu::WatchFloatSlider("Stiffness", &stiffness, 0.0f, 1.25f);
	VerticalDebugMenu::WatchFloatSlider("Solves/Frame", &frameSolvesPerFrame, 1, 4);

	Delegate f = Delegate();
	f.bind(this, &ClothDemo::ResetParticles);
	VerticalDebugMenu::WatchButton("Reset", f);

	
	for(uint r = 0; r < DIMENSION; r++)
	{
		for(uint c = 0; c < DIMENSION; c++)
		{
			points[r][c] = ClothP();

			if(r > 0) links_up[r][c] = ClothLink(&points[r - 1][c], &points[r][c], &restlength, &tearlength, &stiffness);
			if(c > 0) links_left[r][c] = ClothLink(&points[r][c - 1], &points[r][c], &restlength, &tearlength, &stiffness);

			DemoWindow::WatchPoint(&points[r][c].position, &points[r][c].imass, Qt::red);
		}
	}

	ResetParticles();
}
Exemple #19
0
void UBGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QColor color = UBSettings::settings()->isDarkBackground() ? mColorOnDarkBackground : mColorOnLightBackground;
    setDefaultTextColor(color);

    // Never draw the rubber band, we draw our custom selection with the DelegateFrame
    QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option);
    styleOption.state &= ~QStyle::State_Selected;
    styleOption.state &= ~QStyle::State_HasFocus;

    QGraphicsTextItem::paint(painter, &styleOption, widget);

    if (widget == UBApplication::boardController->controlView()->viewport() &&
            !isSelected() && toPlainText().isEmpty())
    {
        QFontMetrics fm(font());
        setTextWidth(fm.width(mTypeTextHereLabel));
        painter->setFont(font());
        painter->setPen(UBSettings::paletteColor);
        painter->drawText(boundingRect(), Qt::AlignCenter, mTypeTextHereLabel);
        setTextInteractionFlags(Qt::NoTextInteraction);
    }

    Delegate()->postpaint(painter, option, widget);
}
UBEditableGraphicsLineItem::UBEditableGraphicsLineItem(QGraphicsItem* parent)
    : UBEditableGraphicsPolygonItem(parent)
{
    // Line has Stroke and Fill capabilities :
    Delegate()->setCanReturnInCreationMode(false);
    initializeStrokeProperty();
    initializeFillingProperty();

    UBFreeHandle *startHandle = new UBFreeHandle;
    UBFreeHandle *endHandle = new UBFreeHandle;

    endHandle->setId(1);

    startHandle->setParentItem(this);
    endHandle->setParentItem(this);

    startHandle->setEditableObject(this);
    endHandle->setEditableObject(this);

    startHandle->hide();
    endHandle->hide();

    mHandles.push_back(startHandle);
    mHandles.push_back(endHandle);

    mIsMagnetic = true;
}
void UBGraphicsPathItem::copyItemParameters(UBItem *copy) const
{
    UBGraphicsPathItem *cp = dynamic_cast<UBGraphicsPathItem*>(copy);
    if (cp)
    {
        cp->setPath(QPainterPath(this->path()));

        cp->setTransform(this->transform());
        cp->setTransformOriginPoint(this->transformOriginPoint());

        cp->setFlag(QGraphicsItem::ItemIsMovable, true);
        cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
        cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
        cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
        cp->setFlag(QGraphicsItem::ItemIsFocusable, true);

        if(Delegate()->action()){
            if(Delegate()->action()->linkType() == eLinkToAudio){
                UBGraphicsItemPlayAudioAction* audioAction = dynamic_cast<UBGraphicsItemPlayAudioAction*>(Delegate()->action());
                UBGraphicsItemPlayAudioAction* action = new UBGraphicsItemPlayAudioAction(audioAction->fullPath());
                cp->Delegate()->setAction(action);
            }
            else
                cp->Delegate()->setAction(Delegate()->action());
        }

        if (hasFillingProperty())
            cp->mFillingProperty = new UBFillProperty(*fillingProperty());

        if (hasStrokeProperty())
            cp->mStrokeProperty = new UBStrokeProperty(*strokeProperty());

        cp->mClosed = this->mClosed;

        for(int i = 0; i < mHandles.size(); i++){
            UBFreeHandle *handle = new UBFreeHandle();

            handle->setParentItem(cp);
            handle->setEditableObject(cp);
            handle->setPos(mHandles.at(i)->pos());
            handle->setId(mHandles.at(i)->getId());
            handle->hide();

            cp->mHandles.push_back(handle);
        }
    }
}
void
ICommandCategoryListener::Events
::RemoveListener(ICommandCategoryListener* l)
{
  if (l == nullptr) return;

  categoryChanged -= Delegate(l, &ICommandCategoryListener::CategoryChanged);
}
void
ISelectionListener::Events
::RemoveListener(ISelectionListener::Pointer listener)
{
  if (listener.IsNull()) return;

  this->selectionChanged -= Delegate(listener.GetPointer(), &ISelectionListener::SelectionChanged);
}
void
ISelectionChangedListener::Events
::AddListener(ISelectionChangedListener* listener)
{
  if (listener == nullptr) return;

  this->selectionChanged += Delegate(listener, &ISelectionChangedListener::SelectionChanged);
}
void
IControlListener::Events
::AddListener(IControlListener::Pointer l)
{
  if (l.IsNull()) return;

  Types types = l->GetEventTypes();

  if (types & MOVED)
    movedEvent += Delegate(l.GetPointer(), &IControlListener::ControlMoved);
  if (types & RESIZED)
    resizedEvent += Delegate(l.GetPointer(), &IControlListener::ControlResized);
  if (types & ACTIVATED)
    activatedEvent += Delegate(l.GetPointer(), &IControlListener::ControlActivated);
  if (types & DESTROYED)
    destroyedEvent += Delegate(l.GetPointer(), &IControlListener::ControlDestroyed);
}
void
ICommandListener::Events
::RemoveListener(ICommandListener::Pointer l)
{
  if (l.IsNull()) return;

  commandChanged -= Delegate(l.GetPointer(), &ICommandListener::CommandChanged);
}
void
IPropertyChangeListener::Events
::RemoveListener(IPropertyChangeListener::Pointer listener)
{
  if (listener.IsNull()) return;

  this->propertyChange -= Delegate(listener.GetPointer(), &IPropertyChangeListener::PropertyChange);
}
void
IHandlerListener::Events
::RemoveListener(IHandlerListener::Pointer l)
{
  if (l.IsNull()) return;

  handlerChanged -= Delegate(l.GetPointer(), &IHandlerListener::HandlerChanged);
}
void
ISelectionListener::Events
::RemoveListener(ISelectionListener* listener)
{
  if (listener == NULL) return;

  this->selectionChanged -= Delegate(listener, &ISelectionListener::SelectionChanged);
}
SpecialsMenuPage::SpecialsMenuPage(Menu *menu, SaveGameManager *savedGames) : IMenuPage(menu)
{
	this->menu = menu;
	this->savedGames = savedGames;

	this->backButton = new Input_Button();
	if(AppConfig::Instance().IsIpad())
		backButton->SetSpriteAndBounds(12, 15, CR::AssetList::specials_backButton);
	else
		backButton->SetSpriteAndBounds(12, 11, CR::AssetList::specials_backButton);
	if(AppConfig::Instance().IsIpad())
		backButton->DesignSize(69,30);
	backButton->SetSoundOn(true);
	input_objects.push_back(backButton);

	showSelectionSprite = false;
	selectionSprite = graphics_engine->CreateSprite1();
	selectionSprite->SetImage(CR::AssetList::specials_selector);
	if(AppConfig::Instance().IsIpad())
		selectionSprite->SetDesignSize(456,31);

	medalFontSprite = graphics_engine->CreateSprite1();
	medalFontSprite->SetImage(CR::AssetList::SpecialMedalFont);
	if(AppConfig::Instance().IsIpad())
		medalFontSprite->SetDesignSize(12,11);

	// Survival Run (Unlocked)
	survivalRunUnlockedSprite = graphics_engine->CreateSprite1();
	survivalRunUnlockedSprite->SetPositionAbsalute(10,10);
	survivalRunUnlockedSprite->SetImage(CR::AssetList::specials_lockedUnlockedTag);
	this->showSurvivalRunUnlockedSprite = savedGames->GetSaveGameInfo().bonusInfo.BonusLevel1;
	if(AppConfig::Instance().IsIpad())
		survivalRunUnlockedSprite->SetDesignSize(98,8);

	// Speed Boost (Toggle)
	speedBoostToggle = new Input_Toggle();
	speedBoostToggle->SetSprite(CR::AssetList::options_on_off);
	if(AppConfig::Instance().IsIpad())
		speedBoostToggle->SetPosition(417, 103);
	else
		speedBoostToggle->SetPosition(407, 105);
	speedBoostToggle->SetTouchBounds(0, 91, 480, 30);
	speedBoostToggle->OnToggled += Delegate(this, &SpecialsMenuPage::OnToggledSpeedBoost);
	speedBoostToggle->ToggleOn(savedGames->GetSaveGameInfo().bonusToggles[1]);
	speedBoostToggle->SetSoundOn(true);
	if(AppConfig::Instance().IsIpad())
		speedBoostToggle->DesignSize(65,10);
	input_objects.push_back(speedBoostToggle);

	//gamerGirlToggle = new Input_Toggle();
	//gamerGirlToggle->SetSprite(CR::AssetList::options_on_off);
	//gamerGirlToggle->SetPosition(405, 300);
	//gamerGirlToggle->SetTouchBounds(360, 115, 90, 58);
	//gamerGirlToggle->OnToggled += Delegate(this, &SpecialsMenuPage::OnToggledGamerGirl);
	//gamerGirlToggle->ToggleOn(settingsInfo.musicOn);
	//gamerGirlToggle->SetSoundOn(true);
	//input_objects.push_back(gamerGirlToggle);
}