当前位置:编程学习 > 网站相关 >>

tool bar支持按end键后弹出,再按end键后缩回

1. 在Vfx_page.cpp文件中定义全局变量
//mtk added
VfxBool g_isHiddenToolbar = true;
 
2, 修改adjustClient函数,用#if 1标注
void VfxPage::adjustClient()
{
 VfxFrame *f = getParentFrame();
 if(m_pageFlags & FLAGS_IS_TRANSLUCENT)
 {
 if(m_pageFlags & FLAGS_IN_IME_LAYOUT)
 return;
 
 VFX_MC_TRACE5(VFX_FUNC, TRC_VFX_F5FD630A0FA44B6990DD4AC43AE75B29, 
"[VfxPage](%x) adjustClient(%d,%d,%dx%d)", this, 0, 0, f->getSize().width, f->getSize().height);
 setPos(0, 0);
 setSize(f->getSize());
 }
 else
 {
 VfxS32 barH;
 VfxRect client;
 VfxSize s;
 VfxPoint t;
 if(f->isKindOf(VFX_OBJ_CLASS_INFO(VfxMainScr)))
 {
 client = ((VfxMainScr*)f)->getClient(this);
 }
 else if(f->isKindOf(VFX_OBJ_CLASS_INFO(VfxPage)))
 {
 client = ((VfxPage*)f)->getPageRect();
 }
 else
 {
 client.size = f->getSize();
 client.origin.x = 0;
 client.origin.y = 0;
 }
 
 s = client.size;
 t = client.origin;
 barH = m_topBar->getSize().height;
 t.y += barH;
 s.height -= barH;
 barH = m_bottomBar->getSize().height;
 if(m_pageFlags & FLAGS_IN_IME_LAYOUT)
 {
 VfxS32 *imeOffset = (VfxS32*)getAttachProperty(VFX_PAGE_PROP_ID_IMEOFFSET, sizeof(VfxS32));
 VfxS32 imeH = client.size.height - (*imeOffset);
 if(barH < imeH)
 barH = imeH;
 }
 //mtk added
 #if 1
 if(!g_isHiddenToolbar) 
 s.height -= barH;
 #else
 s.height -= barH;
 #endif
 VFX_MC_TRACE5(VFX_FUNC, TRC_VFX_F5FD630A0FA44B6990DD4AC43AE75B29, 
"[VfxPage](%x) adjustClient(%d,%d,%dx%d)", this, t.x, t.y, s.width, s.height);
 
 setRect(VfxRect(t, s));
 }
}
3. VfxPage::Bar::reposistionBar方法,用#if 1标注
void reposistionBar(VfxPageBar *bar, VfxPageBarLocationEnum loc, VfxBool noAnimation = VFX_FALSE)
 {
 VfxPage *page = VFX_OBJ_DYNAMIC_CAST(bar->getParent(), VfxPage);
 VFX_ASSERT(page);
 
 VfxFrame *f = page->getParentFrame();
 VfxMainScr *scr = page->getMainScr();
 if(bar->getParentFrame() != f)
 f->addChildFrame(bar);
 VfxRect client;
 if(f == scr)
 {
 client = scr->getClient(page);
 }
 else
 {
 client.size = f->getSize();
 client.origin = VfxPoint(0, 0);
 }
 VfxSize barSize = bar->getSize();
 if(noAnimation)
 {
 VfxAutoAnimate::begin();
 VfxAutoAnimate::setDisable(VFX_TRUE);
 }
 // adjust size
 barSize.width = client.size.width;
 bar->setSize(barSize);
 // adjust position 
 if(loc == VFX_PAGE_BAR_LOCATION_TOP)
 bar->setPos(client.origin.x, client.origin.y);
 else if(loc == VFX_PAGE_BAR_LOCATION_BOTTOM)
 {
 #if 1
 if(g_isHiddenToolbar)
 bar->setPos(client.origin.x, client.origin.y + client.size.height);
 else
 bar->setPos(client.origin.x, client.origin.y + client.size.height - barSize.height);
 #else
 bar->setPos(client.origin.x, client.origin.y + client.size.height - barSize.height);
 #endif
 }
 if(noAnimation)
 {
 VfxAutoAnimate::commit();
 }
 bar->setLoc(loc);
 bar->setRotate(page->getRotate());
 }
 
4. 修改VfxPage::onKeyInput的默认实现,用#if 1标注
VfxBool VfxPage::onKeyInput(VfxKeyEvent &event)
{
 if (event.keyCode == VFX_PAGE_KEY_BACK &&
 event.type == VFX_KEY_EVENT_TYPE_DOWN)
 {
 back();
 return VFX_TRUE;
 }
#if 1
 if (event.keyCode == VFX_KEY_CODE_END && event.type == VFX_KEY_EVENT_TYPE_DOWN)
 {
 g_isHiddenToolbar = !g_isHiddenToolbar;
 //toggleBar(VFX_PAGE_BAR_LOCATION_BOTTOM, g_isHiddenToolbar);
 reposistionBars(VFX_FALSE);
 return VFX_TRUE;
 }
#endif
 
 return VfxControl::onKeyInput(event);
}
 
 
另外,如果不用做弹上弹下的动画,那么前面的2,3步均可不做修改。可以在onKeyInput里面,把call reposistionBars换成call toggleBar。
补充:综合编程 , 其他综合 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,