HistoryView::TextState HistoryGroupedMedia::textState(
		QPoint point,
		StateRequest request) const {
	auto result = getPartState(point, request);
	if (!result.link && !_caption.isEmpty()) {
		const auto captionw = width() - st::msgPadding.left() - st::msgPadding.right();
		const auto captiony = height()
			- (isBubbleBottom() ? st::msgPadding.bottom() : 0)
			- _caption.countHeight(captionw);
		if (QRect(st::msgPadding.left(), captiony, captionw, height() - captiony).contains(point)) {
			return TextState(_parent->data(), _caption.getState(
				point - QPoint(st::msgPadding.left(), captiony),
				captionw,
				request.forText()));
		}
	} else if (_parent->media() == this) {
		auto fullRight = width();
		auto fullBottom = height();
		if (_parent->pointInTime(fullRight, fullBottom, point, InfoDisplayType::Image)) {
			result.cursor = CursorState::Date;
		}
		if (!_parent->hasBubble() && _parent->displayRightAction()) {
			auto fastShareLeft = (fullRight + st::historyFastShareLeft);
			auto fastShareTop = (fullBottom - st::historyFastShareBottom - st::historyFastShareSize);
			if (QRect(fastShareLeft, fastShareTop, st::historyFastShareSize, st::historyFastShareSize).contains(point)) {
				result.link = _parent->rightActionLink();
			}
		}
	}
	return result;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
    
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    label = Label::create("Hello World", "Arial", 24);
    
    // position the label on the center of the screen
    label->setPosition(Vec2(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - label->getContentSize().height));

    // add the label as a child to this layer
    this->addChild(label, 1);

    // add "HelloWorld" splash screen"
    auto sprite = Sprite::create("HelloWorld.png");

    // position the sprite on the center of the screen
    sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    this->addChild(sprite, 0);

	/**********************************************************************************

	SSアニメ表示のサンプルコード
	Visual Studio Express 2013 for Windows Desktop、cocos2d-x Ver3.2で動作を確認しています。
	ssbpとpngがあれば再生する事ができますが、Resourcesフォルダにsspjも含まれています。

	**********************************************************************************/
		
	//リソースマネージャの作成
	auto resman = ss::ResourceManager::getInstance();
	//プレイヤーの作成
	ssplayer = ss::Player::create();

	//アニメデータをリソースに追加
	//それぞれのプラットフォームに合わせたパスへ変更してください。
	resman->addData("character_template_comipo\\character_template1.ssbp");
	//プレイヤーにリソースを割り当て
	ssplayer->setData("character_template1");        // ssbpファイル名(拡張子不要)
	//再生するモーションを設定
	ssplayer->play("character_template_3head/stance");				 // アニメーション名を指定(ssae名/アニメーション名も可能、詳しくは後述)

	//アニメの位置を設定
	ssplayer->setPosition(visibleSize.width / 2, visibleSize.height / 2);
	//スケールの変更
	ssplayer->setScale(0.5f, 0.5f);

	//ユーザーデータコールバックを設定
	ssplayer->setUserDataCallback(CC_CALLBACK_2(HelloWorld::userDataCallback, this));

	//アニメーション終了コールバックを設定
	ssplayer->setPlayEndCallback(CC_CALLBACK_1(HelloWorld::playEndCallback, this));

	//プレイヤーをゲームシーンに追加
	this->addChild(ssplayer, 10);


	//updeteの作成
	this->scheduleUpdate();


	/**********************************************************************************

	アニメーションに含まるパーツがタッチされたかを取得するサンプルコードです。
	サンプルでは、パーツ名"collision"の範囲をタッチ判定します。

	**********************************************************************************/

	//イベントリスナーを作成
	auto listener = EventListenerTouchOneByOne::create();

	//タッチ開始
	listener->onTouchBegan = [](Touch* touch, Event* event)
	{
		//イベントを発生させたSSPlayerを取得します。
		auto target = (ss::Player*)event->getCurrentTarget();

		//パーツ名を検索してタッチ判定用の矩形を取得
		ss::ResluteState result;
		if ( true == target->getPartState(result, "collision") )
		{
			//Nodeの配置座標とタッチで取得される座標のY方向が逆の様なので上下を反転します。
			Size visibleSize = Director::getInstance()->getVisibleSize();
			Rect targetBox(result.x, visibleSize.height - result.y, result.scaledsize_X, result.scaledsize_Y);

			//タッチされた座標の取得
			Point touchPoint = Vec2(touch->getLocationInView().x, touch->getLocationInView().y);

			//touchPointがtargetBoxの中に含まれているか判定
			if (targetBox.containsPoint(touchPoint))
			{
				//パーツがタッチされました。
				CCLOG("touch parts");
				return true;
			}
		}


		return false;
	};

	//イベントリスナーを登録
	this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, ssplayer);


    return true;
}
Пример #3
0
bool SS5Player::getPartState(PartState& result, const char* name) const
{
	int partIndex = indexOfPart(name);		//indexに変換
	return getPartState(result, partIndex);
}