当前位置: 首页>>代码示例>>C++>>正文


C++ Widget::LinkDown方法代码示例

本文整理汇总了C++中Widget::LinkDown方法的典型用法代码示例。如果您正苦于以下问题:C++ Widget::LinkDown方法的具体用法?C++ Widget::LinkDown怎么用?C++ Widget::LinkDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Widget的用法示例。


在下文中一共展示了Widget::LinkDown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Widget

TEST_FIXTURE(SDL_fixture, FlatWidgets)
{
	UNITTEST_TIME_CONSTRAINT(50);

	CHECK(SDL_init_ok);
	if(SDL_init_ok)
	{
		Event e;
		e.event_type = EventType::KeyLeft;
		Widget* left = new Widget();
		Widget* right = new Widget();
		Widget* left_bottom = new Widget();
		Widget* right_bottom = new Widget();
		left->LinkRight(right);
		left->LinkDown(left_bottom);
		right->LinkLeft(left);
		right->LinkDown(right_bottom);
		left_bottom->LinkUp(left);
		left_bottom->LinkRight(right_bottom);
		right_bottom->LinkUp(right);
		right_bottom->LinkLeft(left_bottom);


		boost::signals::scoped_connection c = left->OnGainFocus.connect(widgetevent_callback);
		left->SetFocus();
		CHECK_EQUAL(1, widgetevent_callback_count);

		Widget::GetWidgetWithFocus()->HandleEvent(e);
		CHECK_EQUAL(true, left->HasFocus());
		CHECK_EQUAL(false, right->HasFocus());

		e.event_type = EventType::KeyRight;
		Widget::GetWidgetWithFocus()->HandleEvent(e);
		CHECK_EQUAL(false, left->HasFocus());
		CHECK_EQUAL(true, right->HasFocus());

		Widget::GetWidgetWithFocus()->HandleEvent(e);
		CHECK_EQUAL(false, left->HasFocus());
		CHECK_EQUAL(true, right->HasFocus());
		
		e.event_type = EventType::KeyDown;
		Widget::GetWidgetWithFocus()->HandleEvent(e);
		CHECK_EQUAL(true, right_bottom->HasFocus());

		e.event_type = EventType::KeyLeft;
		Widget::GetWidgetWithFocus()->HandleEvent(e);
		CHECK_EQUAL(true, left_bottom->HasFocus());

		e.event_type = EventType::KeyUp;
		Widget::GetWidgetWithFocus()->HandleEvent(e);
		CHECK_EQUAL(true, left->HasFocus());
		Widget::ClearRoot();
	}
}
开发者ID:danishcake,项目名称:ShokoTD,代码行数:54,代码来源:WidgetsKeyboardNavigation.cpp

示例2: Setup

void ModeMenu::Setup()
{
	const int btn_width = 160;
	const int btn_height = 40;
	const int btn_border = 10;

	Widget* newGame = new Widget(NinePatch("NavyButton.png", 16, 16, 16, 16), btn_width, btn_height);
	newGame->SetPosition(Vector2i(Widget::GetScreenCentre().x - newGame->GetSize().x / 2, btn_border));
	newGame->SetText("New game", TextAlignment::Centre);

	Widget* scrollRight = new Widget(NinePatch("NavyButton.png", 16, 16, 16, 16), btn_height, btn_height);
	scrollRight->SetPosition(newGame->GetPosition() + Vector2i(newGame->GetSize().x + btn_border, 0));
	scrollRight->SetText(">", TextAlignment::Centre);

	Widget* scrollLeft = new Widget(NinePatch("NavyButton.png", 16, 16, 16, 16), btn_height, btn_height);
	scrollLeft->SetPosition(newGame->GetPosition() - Vector2i(scrollLeft->GetSize().x + btn_border, 0));
	scrollLeft->SetText("<", TextAlignment::Centre);

	Widget* explainGame = new Widget(NinePatch("NavyButton.png", 16, 16, 16, 16), btn_width * 2 + btn_border, btn_height * 2);
	explainGame->SetPosition(Vector2i(btn_border, Widget::GetScreenSize().y - btn_height * 2 - btn_border));
	explainGame->SetTextSize(TextSize::Small);
	explainGame->SetTextWrap(true);
	explainGame->SetText("You cannot move the paddle, but you can move the wall. Keep the bricks alive by dodging the balls. You score 10 points for each brick left on every bounce", TextAlignment::Centre);
	explainGame->SetRejectsFocus(true);
	explainGame->SetHidesHighlight(true);

	Widget* exitGame = new Widget(NinePatch("NavyButton.png", 16, 16, 16, 16), btn_width, btn_height);
	exitGame->SetPosition(Vector2i(btn_border * 3 + btn_width * 2, Widget::GetScreenSize().y +  - btn_height - btn_border));
	exitGame->SetText("Exit", TextAlignment::Centre);

	Widget* betaTag = new Widget("Beta.png");
	betaTag->SetPosition(Widget::GetScreenSize() - betaTag->GetSize());

	mFeedbackWidget = new FeedbackWidget();

	
	scrollLeft->LinkDown(exitGame);
	scrollLeft->LinkRight(newGame);
	newGame->LinkLeft(scrollLeft);
	newGame->LinkDown(exitGame);
	newGame->LinkRight(scrollRight);
	scrollRight->LinkLeft(newGame);
	scrollRight->LinkDown(exitGame);
	exitGame->LinkUp(newGame);

	//Attach callback
	exitGame->OnClick.connect(boost::bind(&ModeMenu::clickExit, this, _1));
	newGame->OnClick.connect(boost::bind(&ModeMenu::clickNewGame, this, _1));
	betaTag->OnClick.connect(boost::bind(&ModeMenu::clickBetaTag, this, _1));
	scrollRight->OnClick.connect(boost::bind(&ModeMenu::clickNextLevel, this, _1));
	scrollLeft->OnClick.connect(boost::bind(&ModeMenu::clickPrevLevel, this, _1));

}
开发者ID:RahulSDeshpande,项目名称:ReverseArkanoid,代码行数:53,代码来源:ModeMenu.cpp

示例3: AddMenuItem

Widget*  MenuWidget::AddMenuItem(std::string _item)
{
	Widget* pMenuItem = new Widget();
	pMenuItem->SetSize(Vector2i(128, 48));
	pMenuItem->SetPosition(Vector2i(static_cast<int>(children_.size()) * 8, static_cast<int>(children_.size()) * 40));
	pMenuItem->SetText(_item, TextAlignment::Centre);
	SetSize(Vector2i(128 + static_cast<int>(children_.size()) * 8, 48 + static_cast<int>(children_.size()) * 40));
	//Link up
	if(children_.size() == 1)
	{
		children_.at(0)->LinkUp(pMenuItem);
		children_.at(0)->LinkDown(pMenuItem);
	}
	if(children_.size() > 0)
	{
		pMenuItem->LinkUp(children_.at(children_.size() - 1));
		pMenuItem->LinkDown(children_.at(0));
	}
	//Remove old link
	if(children_.size() > 1)
	{
		children_.at(children_.size() - 1)->LinkDown(pMenuItem);
		children_.at(0)->LinkUp(pMenuItem);
	}

	AddChild(pMenuItem);

	return pMenuItem;
}
开发者ID:danishcake,项目名称:Shoko-Rocket,代码行数:29,代码来源:MenuWidget.cpp


注:本文中的Widget::LinkDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。