コード例 #1
0
ファイル: WidgetContainer.cpp プロジェクト: doorxp/seed
void WidgetContainer::OnInputPointerMove(const EventInputPointer *ev)
{
	ASSERT_NULL(ev);

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();

	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		bEventConsumed = FALSE;

		if (w->IsDisabled())
			continue;

		if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
		{
			WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
			wc->OnInputPointerMove(ev);

			bEventConsumed = wc->IsEventConsumed();
			if (bEventConsumed)
				break;
		}

		bEventConsumed = this->UpdateStates(ev, w);
		//if (UpdateStates(ev, w))
		if (bEventConsumed)
			break;
	}
}
コード例 #2
0
ファイル: YWidget.cpp プロジェクト: jwk000/YSLib
void
SetSizeOf(IWidget& wgt, const Size& s)
{
	wgt.GetRenderer().SetSize(s);
	wgt.GetView().SetSize(s);
	CallEvent<Resize>(wgt, UIEventArgs(wgt));
}
コード例 #3
0
ファイル: main.c プロジェクト: AAAJet/OOC-Design-Pattern
int main()
{
	LinuxFactory* linuxFactory = new (LinuxFactory);
	IFactory* ifactory = &linuxFactory->ifactory;
	IWidget* iwidget = ifactory->createWidget(ifactory);
	iwidget->show(iwidget);
	IButton* ibutton = ifactory->createButton(ifactory);
	ibutton->click(ibutton);
	delete (LinuxWidget, container_of(iwidget, LinuxWidget, iwidget));
	delete (LinuxButton, container_of(ibutton, LinuxButton, ibutton));

	MacFactory* macFactory = new (MacFactory);
	ifactory = &macFactory->ifactory;
	iwidget = ifactory->createWidget(ifactory);
	iwidget->show(iwidget);
	ibutton = ifactory->createButton(ifactory);
	ibutton->click(ibutton);
	delete (MacWidget, container_of(iwidget, MacWidget, iwidget));
	delete (MacButton, container_of(ibutton, MacButton, ibutton));

	WindowsFactory* windowsFactory = new (WindowsFactory);
	ifactory = &windowsFactory->ifactory;
	iwidget = ifactory->createWidget(ifactory);
	iwidget->show(iwidget);
	ibutton = ifactory->createButton(ifactory);
	ibutton->click(ibutton);
	delete (WindowsWidget, container_of(iwidget, WindowsWidget, iwidget));
	delete (WindowsButton, container_of(ibutton, WindowsButton, ibutton));

	delete (LinuxFactory, linuxFactory);
	delete (MacFactory, macFactory);
	delete (WindowsFactory, windowsFactory);

	return 0;
}
コード例 #4
0
//-----------------------------------------------------------------
void
MenuOptions::prepareMenu()
{
    if (m_container) {
        deregisterDrawable(m_container);
        delete m_container;
        m_container = NULL;
    }

    Labels labels(Path::dataReadPath("script/labels.lua"));
    IWidget *soundBox = createSoundPanel(labels);
    IWidget *musicBox = createMusicPanel(labels);

    VBox *vbox = new VBox();
    vbox->addWidget(soundBox);
    vbox->addWidget(new WiSpace(0, 10));
    vbox->addWidget(musicBox);
    vbox->addWidget(new WiSpace(0, 10));
    vbox->addWidget(createLangPanel(labels));
    vbox->addWidget(new WiSpace(0, 5));
    vbox->addWidget(createSpeechPanel(labels));
    vbox->addWidget(new WiSpace(0, 5));
    vbox->addWidget(createSubtitlesPanel(labels));

    IWidget *backButton = createBackButton(labels);
    m_statusBar = createStatusBar(musicBox->getW() - backButton->getW());
    HBox *backBox = new HBox();
    backBox->addWidget(m_statusBar);
    backBox->addWidget(backButton);

    vbox->addWidget(backBox);
    m_container = vbox;
    registerDrawable(m_container);
}
コード例 #5
0
ファイル: main.cpp プロジェクト: canercandan/design-pattern
int	main(void)
{
  IWidget*	aWidget;

  aWidget = new ILoveGeraldine(new BorderDecorator(new ScrollDecorator(new BorderDecorator(new TextField(80, 24)))));
  aWidget->draw();
  delete aWidget;
}
コード例 #6
0
//-----------------------------------------------------------------
IWidget *
MenuOptions::createBackButton(const Labels &labels)
{
    IWidget *button = new WiButton(
            new WiPicture(Path::dataReadPath("images/menu/back.png")),
            new SimpleMsg(this, "quit"));
    button->setTip(labels.getLabel("menu_back"));
    return button;
}
コード例 #7
0
ファイル: YWidget.cpp プロジェクト: jwk000/YSLib
void
InvalidateChildren(IWidget& wgt, const Rect& bounds)
{
	Rect r(wgt.GetRenderer().CommitInvalidation(bounds));

	for(auto pr(wgt.GetChildren()); pr.first != pr.second; ++pr.first)
	{
		auto& child(*pr.first);

		InvalidateChildren(child, Rect(r - GetLocationOf(child)));
	}
}
コード例 #8
0
ファイル: WidgetContainer.cpp プロジェクト: Patuti/seed
void WidgetContainer::Update(f32 dt)
{
	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();
	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		w->Update(dt);
	}

	std::sort(vWidget.begin(), vWidget.end(), ITransformable2DDescendingPrioritySort());
}
コード例 #9
0
ファイル: WidgetContainer.cpp プロジェクト: doorxp/seed
INLINE void WidgetContainer::SetDisabled(BOOL b)
{
	IWidget::SetDisabled(b);

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();
	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		w->SetDisabled(b);
	}
}
コード例 #10
0
ファイル: WidgetContainer.cpp プロジェクト: doorxp/seed
INLINE void WidgetContainer::Render()
{
	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();
	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		w->Render();
	}

	if (pConfiguration->bDebugContainer)
		pRendererDevice->DrawRect(this->GetX(), this->GetY(), this->GetWidth(), this->GetHeight(), PIXEL_COLOR(255, 0, 255, 255));
}
コード例 #11
0
ファイル: UIManager.hpp プロジェクト: quarck/csetup
	void onTouchUpdate(int x, int y)
	{
		Point pt(x,y);
	
		if ( m_activeButton )
		{
			m_activeButton->onTouchUpdate(pt);
		}
	}
コード例 #12
0
ファイル: YWidget.cpp プロジェクト: jwk000/YSLib
void
PaintChild(IWidget& wgt, PaintEventArgs&& e)
{
	auto& sender(e.GetSender());

	if(Clip(e.ClipArea, Rect(e.Location += GetLocationOf(sender),
		GetSizeOf(sender))))
		wgt.GetRenderer().Paint(sender, std::move(e));
}
コード例 #13
0
ファイル: UIManager.hpp プロジェクト: quarck/csetup
	void onTouchDown(int x, int y)
	{
		Point pt(x,y);

		if ( m_activeButton ) 
		{
			m_activeButton->onTouchUp( Point(-1,-1) );
			m_activeButton = NULL;
		}

		IWidget* wdgt = m_activePane ? m_activePane->hitTest(pt) : NULL;

		if ( wdgt != NULL ) 
		{
			m_activeButton = wdgt;
			m_activeButton->onTouchDown(pt);
		}
	}
コード例 #14
0
ファイル: UIManager.hpp プロジェクト: quarck/csetup
	void onTouchUp(int x, int y)
	{
		Point pt(x,y);
		
		if ( m_activeButton )
		{
			m_activeButton->onTouchUp(pt);
			m_activeButton = NULL;
		}
	}
コード例 #15
0
ファイル: LayoutBox.cpp プロジェクト: Noxalus/YAPOG
  void LayoutBox::AddChild (IWidget& child, Align align)
  {
    BaseWidget::AddChild (child);
    items_.Add (&child, align);

    if (child.IsFocusable ())    
      focusables_.Add (&child);
	  
    GeneratePosition ();
  }
コード例 #16
0
ファイル: LayoutBox.cpp プロジェクト: Noxalus/YAPOG
  void LayoutBox::RemoveChild (IWidget& child)
  {
    BaseWidget::RemoveChild (child);
    items_.Remove (&child);

    if (child.IsFocusable ())
      focusables_.Remove (&child);

    GeneratePosition ();
  }
コード例 #17
0
ファイル: LayoutBox.cpp プロジェクト: Noxalus/YAPOG
  bool LayoutBox::HandleOnPriorityEvent (const GuiEvent& guiEvent)
  {
    if (guiEvent.type == sf::Event::KeyPressed)
    {
      if (guiEvent.key.code == sf::Keyboard::Tab)
      {
        if (focusables_.Count () == 0 || !isFocused_)
          return false;

        IWidget* child;
        uint cycle = focusedChild_;

        // if current focussable is a layout, give it control for tab
        if (focusables_[cycle]->OnPriorityEvent (guiEvent))
          return true;
        focusedChild_ = (focusedChild_ + 1) % focusables_.Count ();

        //Performed a cycle, give control to the parent
        if (focusedChild_ == 0)
        {
          child = focusables_[focusedChild_];          
          child->SetFocused (true);
          eventHandlers_.Remove (child);
          eventHandlers_.AddFront (child);
          isFocused_ = true; //to make cycle
          return false;
        }

        child = focusables_[focusedChild_];
        child->SetFocused (true);
        eventHandlers_.Remove (child);
        eventHandlers_.AddFront (child);

        return true;
      }
      return false;
    }
    return false;
  }
コード例 #18
0
ファイル: WidgetContainer.cpp プロジェクト: doorxp/seed
BOOL WidgetContainer::DoDrag(const EventInputPointer *ev, IWidget *widget)
{
	f32 cX = ev->GetX();
	f32 cY = ev->GetY();
	u32 j = ev->GetJoystick();

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();

	IWidget *receiver = NULL;
	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		/* FIX ME */
		w->SetPlayerState(Seed::WidgetStateDrag, j);
		/* FIX ME */
		if (w != widget && w->ContainsPoint(pInput->GetX(), pInput->GetY()) && !w->IsDisabled())
		{
			receiver = w;
			//break;

			const EventWidget newEvent(widget, receiver, WidgetEventDrag, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());

			LOG(">DRAG OVER [id: %d]", receiver->GetId());
			LOG("\tEstado WIDGET");
			widget->SetState(Seed::WidgetStateDrag);
			widget->OnWidgetDrag(&newEvent);

			widget->SendOnDrag(&newEvent);
			LOG("\tEvento");
			if (newEvent.IsConsumed())
				return TRUE;
		}
	}

	if (!receiver)
	{
		const EventWidget newEvent(widget, NULL, WidgetEventDrag, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());

		LOG(">DRAG [id: %d]", widget->GetId());
		LOG("\tEstado WIDGET");
		widget->SetState(Seed::WidgetStateDrag);
		widget->OnWidgetDrag(&newEvent);

		widget->SendOnDrag(&newEvent);
		LOG("\tEvento");
		if (newEvent.IsConsumed())
			return TRUE;
	}

	return FALSE;
}
コード例 #19
0
ファイル: WidgetContainer.cpp プロジェクト: doorxp/seed
IWidget *WidgetContainer::FindNearestByRadius(f32 radius, const EventInputPointer *ev) const
{
	WidgetIteratorConst it = vWidget.begin();
	WidgetIteratorConst end = vWidget.end();
	
	IWidget *nearest = NULL;
	f32 distance = radius;
	
	f32 x = ev->GetX();
	f32 y = ev->GetY();
	
	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		if (w->IsDisabled())
			continue;

		if (!(w->GetTrigger() & ev->GetPressed()))
			continue;

		if (w->GetState() == Seed::WidgetStateDrag)
			continue;

		f32 wX = w->GetX() + (w->GetWidth() / 2.0f);
		f32 wY = w->GetY() + (w->GetHeight() / 2.0f);
		Point2f wp((x * x) - (wX * wX), (y * y)-(wY * wY));

		f32 dX = wp.SquareLength();
		
		if (dX < distance)
		{
			distance = dX;
			nearest = w;
		}
	}
	
	return nearest;
}
コード例 #20
0
ファイル: YWidget.cpp プロジェクト: jwk000/YSLib
void
SetLocationOf(IWidget& wgt, const Point& pt)
{
	wgt.GetView().SetLocation(pt);
	CallEvent<Move>(wgt, UIEventArgs(wgt));
}
コード例 #21
0
ファイル: WidgetContainer.cpp プロジェクト: doorxp/seed
void WidgetContainer::OnInputPointerRelease(const EventInputPointer *ev)
{
	ASSERT_NULL(ev);

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();

	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		//BOOL consumed = FALSE;

		bEventConsumed = FALSE;

		ASSERT_NULL(w);

		if (w->IsDisabled())
			continue;

		if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
		{
			WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
			wc->OnInputPointerRelease(ev);

			bEventConsumed = wc->IsEventConsumed();
			if (bEventConsumed)
				break;
		}

		//f32 cX = ev->GetX();
		//f32 cY = ev->GetY();
		u32 j = ev->GetJoystick();

		if (!(w->GetTrigger() & ev->GetReleased()))
			continue;

		if (w->GetState() == Seed::WidgetStateDrag)
		{
			//LOG("> STOP DRAG [%d, %f, %f]", j, cX, cY);
			bEventConsumed = this->DoDrop(ev, w);
		}
		else
		{
			if (w->GetPlayerState(j) == Seed::WidgetStatePressedOver)
			{
				//LOG("> RELEASE [%d, %f, %f]", j, cX, cY);
				//consumed = this->DoRelease(ev, w);
				bEventConsumed = this->DoRelease(ev, w);
			}
			else if (w->GetPlayerState(j) == Seed::WidgetStatePressedOut)
			{
				//LOG("> RELEASE OUT [%d, %f, %f]", j, cX, cY);
				//consumed = this->DoReleaseOut(ev, w);
				bEventConsumed = this->DoReleaseOut(ev, w);
			}
		}

		//if (consumed)
		if (bEventConsumed)
			break;
	}
}
コード例 #22
0
ファイル: WidgetContainer.cpp プロジェクト: doorxp/seed
void WidgetContainer::OnInputPointerPress(const EventInputPointer *ev)
{
	ASSERT_NULL(ev);

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();

	f32 cX = ev->GetX();
	f32 cY = ev->GetY();
	BOOL found = FALSE;
	
	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		bEventConsumed = FALSE;

		if (w->IsDisabled())
			continue;

		if (!w->ContainsPoint(cX, cY))
			continue;

		if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
		{
			WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
			wc->OnInputPointerPress(ev);

			bEventConsumed = wc->IsEventConsumed();
			if (bEventConsumed)
				break;
		}

		if (!(w->GetTrigger() & ev->GetPressed()))
			continue;

		u32 j = ev->GetJoystick();

		//LOG("> PRESS [%d, %f, %f]", j, cX, cY);

		if (w->GetState() == Seed::WidgetStateDrag)
		{
			continue;
		}
		
		found = TRUE;

		const EventWidget newEvent(w, NULL, WidgetEventPressed, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());

		LOG(">PRESSED_OVER [id: %d]", w->GetId());
		// GetState eh o baseado em prioridade a partir de todos os inputs.
		if (w->GetState() != Seed::WidgetStatePressedOver && w->GetPlayerState(j) != Seed::WidgetStatePressedOver)
		{
			// muda apenas o estado interno do widget
			LOG("\tEstado WIDGET");
			w->OnWidgetPress(&newEvent);
		}

		w->SetState(Seed::WidgetStatePressed);
		w->SetPlayerState(Seed::WidgetStatePressedOver, j);
		LOG("\tEstado PLAYER");

		w->SendOnPress(&newEvent);
		LOG("\tEvento");
		//if (newEvent.IsConsumed())
		bEventConsumed = newEvent.IsConsumed();
		if (bEventConsumed)
			break;
	}

	if (!found) // avoid call
	{
		// If no widget have collision, then we try distance based input;
		f32 maxDist = pConfiguration->GetInputDistanceRadius();
		if (maxDist)
		{
			IWidget *nearest = this->FindNearestByRadius(maxDist, ev);
			if (nearest)
			{
				IWidget *w = nearest;
				if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
				{
					WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
					wc->OnInputPointerPress(ev);

					bEventConsumed = wc->IsEventConsumed();
					if (bEventConsumed)
						return;
				}

				u32 j = ev->GetJoystick();

				const EventWidget newEvent(w, NULL, WidgetEventPressed, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());

				LOG(">PRESSED_OVER [id: %d]", w->GetId());
				// GetState eh o baseado em prioridade a partir de todos os inputs.
				if (w->GetState() != Seed::WidgetStatePressedOver && w->GetPlayerState(j) != Seed::WidgetStatePressedOver)
				{
					// muda apenas o estado interno do widget
					LOG("\tEstado WIDGET");
					w->OnWidgetPress(&newEvent);
				}

				w->SetState(Seed::WidgetStatePressed);
				w->SetPlayerState(Seed::WidgetStatePressedOver, j);
				LOG("\tEstado PLAYER");

				w->SendOnPress(&newEvent);
				LOG("\tEvento");
				bEventConsumed = newEvent.IsConsumed();
				if (bEventConsumed)
					return;
			}
		}
	}
}
コード例 #23
0
ファイル: WidgetContainer.cpp プロジェクト: Patuti/seed
void WidgetContainer::OnInputPointerPress(const EventInputPointer *ev)
{
	ASSERT_NULL(ev);

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();

	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		bEventConsumed = FALSE;

		if (w->IsDisabled())
			continue;

		f32 cX = ev->GetX();
		f32 cY = ev->GetY();

		if (!w->ContainsPoint(cX, cY))
			continue;

		if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
		{
			WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
			wc->OnInputPointerPress(ev);

			bEventConsumed = wc->IsEventConsumed();
			if (bEventConsumed)
				break;
		}

		if (!(w->GetTrigger() & ev->GetPressed()))
			continue;

		u32 j = ev->GetJoystick();

		//LOG("> PRESS [%d, %f, %f]", j, cX, cY);

		if (w->GetState() == Seed::WidgetStateDrag)
		{
			continue;
		}

		const EventWidget newEvent(w, NULL, WidgetEventPressed, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());

		LOG(">PRESSED_OVER [id: %d]", w->GetId());
		// GetState eh o baseado em prioridade a partir de todos os inputs.
		if (w->GetState() != Seed::WidgetStatePressedOver && w->GetPlayerState(j) != Seed::WidgetStatePressedOver)
		{
			// muda apenas o estado interno do widget
			LOG("\tEstado WIDGET");
			w->OnWidgetPress(&newEvent);
		}

		w->SetState(Seed::WidgetStatePressed);
		w->SetPlayerState(Seed::WidgetStatePressedOver, j);
		LOG("\tEstado PLAYER");

		w->SendOnPress(&newEvent);
		LOG("\tEvento");
		//if (newEvent.IsConsumed())
		bEventConsumed = newEvent.IsConsumed();
		if (bEventConsumed)
			break;
	}
}