Esempio n. 1
0
void ShopBuyLayer::optionLabel( ButtonTag tag )
{
	auto SpritebutOption = (Sprite*)GameMainLayer::seekNodeByName(_widgetLayer, "SpritebutOption" );

	auto ButtonGold = (Button*)GameMainLayer::seekNodeByName(_widgetLayer, "ButtonGold" );
	auto ButtonGem = (Button*)GameMainLayer::seekNodeByName(_widgetLayer, "ButtonGem" );
	auto ButtonWing = (Button*)GameMainLayer::seekNodeByName(_widgetLayer, "ButtonWing" );

	auto PageViewBuy = (PageView*)GameMainLayer::seekNodeByName(_widgetLayer, "PageViewBuy" );

	SpritebutOption->setScale( 1.15f );
	auto action = ScaleTo::create(0.3f, 1.0f);
	SpritebutOption->runAction( action );
	switch ( tag )
	{
	case Tag_LabelGem:
		SpritebutOption->setPosition( ButtonGem->getPosition() );
		PageViewBuy->scrollToPage(1);
		break;

	case Tag_LabelGold:
		SpritebutOption->setPosition( ButtonGold->getPosition() );
		PageViewBuy->scrollToPage(0);
		break;

	case Tag_LabelWing:
		SpritebutOption->setPosition( ButtonWing->getPosition() );
		PageViewBuy->scrollToPage(2);
		break;
	default:
		break;
	}

}
Esempio n. 2
0
void ScrollHandler::goToNextPage()
{
	XOJ_CHECK_TYPE(ScrollHandler);

	if (this->control->getWindow())
	{
		if (this->control->getSettings()->isPresentationMode())
		{
			PageView* view = this->control->getWindow()->getXournal()->getViewFor(this->control->getWindow()->getXournal()->getCurrentPage() + 1);
			if (view)
			{
				double dHeight = view->getDisplayHeight();
				double disHeight = this->control->getWindow()->getLayout()->getDisplayHeight();
				//this gets reversed when we are going down if the page is smaller than the display height
				double top = (-dHeight + disHeight)/2.0 - 7.5;
				//the magic 7.5 is from XOURNAL_PADDING_BETWEEN/2
				scrollToPage(this->control->getWindow()->getXournal()->getCurrentPage() + 1, top);
			}
		}
		else
		{
			scrollToPage(this->control->getWindow()->getXournal()->getCurrentPage() + 1);
		}
	}
}
Esempio n. 3
0
void ScrollView::adjustScrollView(const Vec2& oBegin, const Vec2& oEnd)
{
    int nPage = abs(oBegin.x / (int)_cellSize.width);
    
    int nAdjustPage = 0;
    
    int nDis = oEnd.x-oBegin.x;
    
    if (nDis<-getViewSize().width/15)
    {
        nAdjustPage=nPage+1;
    }
    else if (nDis>getViewSize().width/15)
    {
        nAdjustPage=nPage-1;
    }
    else
    {
        nAdjustPage=nPage;
    }
    
    nAdjustPage=MIN(nAdjustPage, _pageCount-1);
    nAdjustPage=MAX(nAdjustPage, 0);
    
    scrollToPage(nAdjustPage);
}
void CCCGameScrollView::adjustScrollView( const cocos2d::CCPoint& oBegin,const cocos2d::CCPoint & oEnd)
{
    
	int nPage = abs(oBegin.x / (int)m_CellSize.width);
    
	int nAdjustPage = 0;
    
	int nDis = oEnd.x-oBegin.x;
    
	if (nDis<-getViewSize().width/5)
	{
		nAdjustPage=nPage+1;
	}
	else if (nDis>getViewSize().width/5)
	{
		nAdjustPage=nPage-1;
	}
	else
	{
		nAdjustPage=nPage;
	}
    
	nAdjustPage=MIN(nAdjustPage,m_nPageCount-1);
	nAdjustPage=MAX(nAdjustPage,0);
    
	scrollToPage(nAdjustPage);
}
Esempio n. 5
0
void ScrollHandler::scrollToAnnotatedPage(bool next)
{
	XOJ_CHECK_TYPE(ScrollHandler);

	if (!this->control->getWindow())
	{
		return;
	}

	int step;
	if (next)
	{
		step = 1;
	}
	else
	{
		step = -1;
	}

	Document* doc = this->control->getDocument();

	for (int i = this->control->getCurrentPageNo() + step; i >= 0 &&
	     i < doc->getPageCount(); i += step)
	{
		if (doc->getPage(i)->isAnnotated())
		{
			scrollToPage(i);
			break;
		}
	}
}
Esempio n. 6
0
void PageView::handleReleaseLogic(Touch *touch)
{
    if (this->getPageCount() <= 0)
    {
        return;
    }
    Widget* curPage = dynamic_cast<Widget*>(this->getPages().at(_curPageIdx));
    if (curPage)
    {
        Vec2 curPagePos = curPage->getPosition();
        ssize_t pageCount = this->getPageCount();
        float curPageLocation = curPagePos.x;
        float pageWidth = getContentSize().width;
        if (!_usingCustomScrollThreshold) {
            _customScrollThreshold = pageWidth / 2.0;
        }
        float boundary = _customScrollThreshold;
        if (curPageLocation <= -boundary)
        {
            if (_curPageIdx >= pageCount-1)
            {
                scrollPages(-curPageLocation);
            }
            else
            {
                scrollToPage(_curPageIdx+1);
            }
        }
        else if (curPageLocation >= boundary)
        {
            if (_curPageIdx <= 0)
            {
                scrollPages(-curPageLocation);
            }
            else
            {
                scrollToPage(_curPageIdx-1);
            }
        }
        else
        {
            scrollToPage(_curPageIdx);
        }
    }
}
Esempio n. 7
0
void ScrollView::scrollToNextPage()
{
    int nCurPage = getCurPage();
    if (nCurPage >= _pageCount-1)
    {
        return ;
    }
    scrollToPage(nCurPage+1);
}
Esempio n. 8
0
void CCCGameScrollView::scrollToPrePage()
{
	int nCurPage = getCurPage();
	if (nCurPage <= 0)
	{
		return ;
	}
	scrollToPage(nCurPage - 1);
}
Esempio n. 9
0
void ScrollHandler::goToLastPage()
{
	XOJ_CHECK_TYPE(ScrollHandler);

	if (this->control->getWindow())
	{
		scrollToPage(this->control->getDocument()->getPageCount() - 1);
	}
}
Esempio n. 10
0
void ScrollHandler::goToFirstPage()
{
	XOJ_CHECK_TYPE(ScrollHandler);

	if (this->control->getWindow())
	{
		scrollToPage(0);
	}
}
Esempio n. 11
0
void CCCGameScrollView::scrollToNextPage()
{
	int nCurPage = getCurPage();
	if (nCurPage >= m_nPageCount - 1)
	{
		return ;
	}
	scrollToPage(nCurPage + 1);
}
Esempio n. 12
0
void ScrollHandler::goToNextPage()
{
	XOJ_CHECK_TYPE(ScrollHandler);

	if (this->control->getWindow())
	{
		scrollToPage(this->control->getWindow()->getXournal()->getCurrentPage() + 1);
	}
}
Esempio n. 13
0
void NewPageView::handleReleaseLogic(Touch *touch)
{
    if (_pages.size() <= 0)
    {
        return;
    }
    Widget* curPage = _pages.at(_curPageIdx);
    if (curPage)
    {
        Vec2 curPagePos = curPage->getPosition();
        ssize_t pageCount = _pages.size();
        float curPageLocation = curPagePos.x;
        float boundary = 10;
        if (curPageLocation <= -boundary)
        {
            if (_curPageIdx >= pageCount-1)
            {
                _curPageIdx=0;
                scrollToPage(_curPageIdx);
            }
            else
            {
                scrollToPage(_curPageIdx+1);
            }
        }
        else if (curPageLocation >= boundary)
        {
            if (_curPageIdx <= 0)
            {
                 _curPageIdx=pageCount-1;
                scrollToPage(_curPageIdx);
            }
            else
            {
                scrollToPage(_curPageIdx-1);
            }
        }
        else
        {
            scrollToPage(_curPageIdx);
        }
    }
}
Esempio n. 14
0
void PageView::handleReleaseLogic(const Vec2 &touchPoint)
{
    if (this->getPageCount() <= 0)
    {
        return;
    }
    Widget* curPage = dynamic_cast<Widget*>(this->getPages().at(_curPageIdx));
    if (curPage)
    {
        Vec2 curPagePos = curPage->getPosition();
        ssize_t pageCount = this->getPageCount();
        float curPageLocation = curPagePos.x;
        float pageWidth = getSize().width;
        float boundary = pageWidth/2.0f;
        if (curPageLocation <= -boundary)
        {
            if (_curPageIdx >= pageCount-1)
            {
                scrollPages(-curPageLocation);
            }
            else
            {
                scrollToPage(_curPageIdx+1);
            }
        }
        else if (curPageLocation >= boundary)
        {
            if (_curPageIdx <= 0)
            {
                scrollPages(-curPageLocation);
            }
            else
            {
                scrollToPage(_curPageIdx-1);
            }
        }
        else
        {
            scrollToPage(_curPageIdx);
        }
    }
}
Esempio n. 15
0
void UIPageView::handleReleaseLogic(const CCPoint &touchPoint)
{
    UIWidget* curPage = dynamic_cast<UIWidget*>(m_pages->objectAtIndex(m_nCurPageIdx));
    if (curPage)
    {
        CCPoint curPagePos = curPage->getPosition();
        int pageCount = m_pages->count();
        float curPageLocation = curPagePos.x;
        float pageWidth = getSize().width;
        float boundary = pageWidth/2.0f;
        if (curPageLocation <= -boundary)
        {
            if (m_nCurPageIdx >= pageCount-1)
            {
                scrollPages(-curPageLocation);
            }
            else
            {
                scrollToPage(m_nCurPageIdx+1);
            }
        }
        else if (curPageLocation >= boundary)
        {
            if (m_nCurPageIdx <= 0)
            {
                scrollPages(-curPageLocation);
            }
            else
            {
                scrollToPage(m_nCurPageIdx-1);
            }
        }
        else
        {
            scrollToPage(m_nCurPageIdx);
        }
    }
}
Esempio n. 16
0
void ScrollHandler::scrollToPage(PageRef page, double top)
{
	XOJ_CHECK_TYPE(ScrollHandler);

	Document* doc = this->control->getDocument();

	doc->lock();
	int p = doc->indexOf(page);
	doc->unlock();

	if (p != -1)
	{
		scrollToPage(p, top);
	}
}
Esempio n. 17
0
void ScrollHandler::goToPreviousPage()
{
	XOJ_CHECK_TYPE(ScrollHandler);

	if (this->control->getWindow())
	{
		if (this->control->getSettings()->isPresentationMode())
		{
			PageView* view = this->control->getWindow()->getXournal()->getViewFor(this->control->getWindow()->getXournal()->getCurrentPage() - 1);
			if (view)
			{
				double dHeight = view->getDisplayHeight();
				double disHeight = this->control->getWindow()->getLayout()->getDisplayHeight();
				double top = (dHeight - disHeight)/2.0 + 7.5;
					//the magic 7.5 is from XOURNAL_PADDING_BETWEEN/2
				scrollToPage(this->control->getWindow()->getXournal()->getCurrentPage() - 1, top);
			}
		}
		else
		{
			scrollToPage(this->control->getWindow()->getXournal()->getCurrentPage() - 1);
		}
	}
}
Esempio n. 18
0
void ScrollHandler::scrollToSpinPange()
{
	XOJ_CHECK_TYPE(ScrollHandler);

	if (!this->control->getWindow())
	{
		return;
	}
	SpinPageAdapter* spinPageNo = this->control->getWindow()->getSpinPageNo();
	int page = spinPageNo->getPage();
	if (page == 0)
	{
		return;
	}
	scrollToPage(page - 1);
}
Esempio n. 19
0
void CCCGameScrollView::adjustScrollView( const cocos2d::CCPoint &oBegin, const cocos2d::CCPoint &oEnd)
{
	int nPage = 0;
	int nAdjustPage = 0;

	if (m_eDirection == kCCScrollViewDirectionHorizontal)
	{
		nPage = abs(oBegin.x / (int)m_CellSize.width);
		int nDis = oEnd.x - oBegin.x;

		if (nDis < -getViewSize().width / 5)
		{
			nAdjustPage = nPage + 1;
		}
		else if (nDis > getViewSize().width / 5)
		{
			nAdjustPage = nPage - 1;
		}
		else
		{
			nAdjustPage = nPage;
		}
	}
	else
	{
		nPage = abs(oBegin.y / (int)m_CellSize.height);
		int nDis = oEnd.y - oBegin.y;

		if (nDis < -getViewSize().height / 5)
		{
			nAdjustPage = nPage - 1;
		}
		else if (nDis > getViewSize().height / 5)
		{
			nAdjustPage = nPage + 1;
		}
		else
		{
			nAdjustPage = nPage;
		}
	}

	nAdjustPage = MIN(nAdjustPage, m_nPageCount - 1);
	nAdjustPage = MAX(nAdjustPage, 0);

	scrollToPage(nAdjustPage);
}
Esempio n. 20
0
void ScrollHandler::scrollToAnnotatedPage(bool next)
{
	XOJ_CHECK_TYPE(ScrollHandler);

	if (!this->control->getWindow())
	{
		return;
	}

	int step = next ? 1 : -1;

	Document* doc = this->control->getDocument();

	for (size_t i = this->control->getCurrentPageNo() + step; i != size_t_npos && i < doc->getPageCount();
		 i = ((i == 0 && step == -1) ? size_t_npos : i + step))
	{
		if (doc->getPage(i)->isAnnotated())
		{
			scrollToPage(i);
			break;
		}
	}
}