本文整理汇总了C++中UISlider类的典型用法代码示例。如果您正苦于以下问题:C++ UISlider类的具体用法?C++ UISlider怎么用?C++ UISlider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UISlider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UISlider
UISlider * LandscapeToolsPanel::CreateSlider(const Rect & rect)
{
//Temporary fix for loading of UI Interface to avoid reloading of texrures to different formates.
// 1. Reset default format before loading of UI
// 2. Restore default format after loading of UI from stored settings.
Texture::SetDefaultGPU(GPU_UNKNOWN);
UISlider *slider = new UISlider(rect);
slider->SetMinMaxValue(0.f, 1.0f);
slider->SetValue(0.5f);
slider->SetMinSprite("~res:/Gfx/LandscapeEditor/Tools/polzunok", 1);
slider->SetMinDrawType(UIControlBackground::DRAW_STRETCH_HORIZONTAL);
slider->SetMinLeftRightStretchCap(5);
slider->SetMaxSprite("~res:/Gfx/LandscapeEditor/Tools/polzunok", 0);
slider->SetMaxDrawType(UIControlBackground::DRAW_STRETCH_HORIZONTAL);
slider->SetMaxLeftRightStretchCap(5);
slider->SetThumbSprite("~res:/Gfx/LandscapeEditor/Tools/polzunokCenter", 0);
Texture::SetDefaultGPU(EditorSettings::Instance()->GetTextureViewGPU());
return slider;
}
示例2: lua_cocos2dx_UISlider_addEventListenerSlider
static int lua_cocos2dx_UISlider_addEventListenerSlider(lua_State* L)
{
if (nullptr == L)
return 0;
int argc = 0;
UISlider* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(L,1,"UISlider",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<UISlider*>(tolua_tousertype(L,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UISlider_addEventListenerSlider'\n", NULL);
return 0;
}
#endif
argc = lua_gettop(L) - 1;
if (1 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) )
{
goto tolua_lerror;
}
#endif
LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create();
if (nullptr == listener)
{
tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
return 0;
}
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
self->setUserObject(listener);
self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc));
return 0;
}
CCLOG("'addEventListenerSlider' function of UISlider has wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'addEventListenerSlider'.",&tolua_err);
return 0;
#endif
}
示例3: UISlider
UISlider* UISlider::create()
{
UISlider* widget = new UISlider();
if (widget && widget->init())
{
return widget;
}
CC_SAFE_DELETE(widget);
return NULL;
}
示例4: buildBorderVB
void UIDisplay::buildWindowVB( UIWindow& window, float aspectRatio )
{
//Build window border
buildBorderVB( &window, aspectRatio );
if( window.getTabCount() > 1 ) {
//Buil Tabs after subtracting the title bar and border
buildTabVB( window, aspectRatio );
} else {
//Calculate the inside of a window
UIWindow w;
float borderWidth = mBorderDimension;
float borderHeight = borderWidth * aspectRatio;
w.setPosition( XMFLOAT2(window.getPosition().x + borderWidth, (window.getPosition().y + UIWINDOW_TITLE_BAR_HEIGHT) ) );
w.setDimension( XMFLOAT2(window.getDimension().x - ( borderWidth * 2.0f ), (window.getDimension().y - UIWINDOW_TITLE_BAR_HEIGHT ) - borderHeight ) );
buildBorderVB( &w, aspectRatio );
}
//Build BG
buildBGVB( &window, mBGColor );
UIWindow::Tab& t = window.getTab( window.getCurrentTab() );
mBuildingElements = true;
//Loop through and build elements in the current tab
for(int i = 0; i < t.elementCount; i++) {
buildBorderVB( t.elements[i], aspectRatio, window.getPosition() );
if( t.elements[i]->getElemType() == UIElement::ElemType::Slider ) {
UISlider* slider = *(UISlider**)(t.elements + i);
UIWindow w;
w.setPosition( XMFLOAT2( slider->getPosition().x + window.getPosition().x, slider->getPosition().y + window.getPosition().y ) );
w.setDimension( XMFLOAT2( slider->getDimension().x * slider->getPercent(), slider->getDimension().y ) );
XMFLOAT4 pctColor = XMFLOAT4( 1.0f, 0.0f, 0.0f, 0.3f );
buildBGVB( &w, pctColor );
} else if( t.elements[i]->getElemType() == UIElement::ElemType::CheckBox ) {
UICheckbox* cb = *(UICheckbox**)(t.elements + i);
if( cb->isChecked() ) {
UICheckbox b;
b.setPosition( XMFLOAT2( cb->getPosition().x + window.getPosition().x, cb->getPosition().y + window.getPosition().y ) );
b.setDimension( XMFLOAT2( cb->getDimension().x, cb->getDimension().y ) );
buildCheckboxVB( &b );
}
}
}
mBuildingElements = false;
}
示例5: UISlider
UISlider* UISlider::create()
{
UISlider* widget = new UISlider();
if (widget && widget->init())
{
widget->autorelease();
return widget;
}
CC_SAFE_DELETE(widget);
return nullptr;
}
示例6: copySpecialProperties
void UISlider::copySpecialProperties(UIWidget *widget)
{
UISlider* slider = dynamic_cast<UISlider*>(widget);
if (slider)
{
_prevIgnoreSize = slider->_prevIgnoreSize;
setScale9Enabled(slider->_scale9Enabled);
loadBarTexture(slider->_textureFile.c_str(), slider->_barTexType);
loadProgressBarTexture(slider->_progressBarTextureFile.c_str(), slider->_progressBarTexType);
loadSlidBallTextureNormal(slider->_slidBallNormalTextureFile.c_str(), slider->_ballNTexType);
loadSlidBallTexturePressed(slider->_slidBallPressedTextureFile.c_str(), slider->_ballPTexType);
loadSlidBallTextureDisabled(slider->_slidBallDisabledTextureFile.c_str(), slider->_ballDTexType);
setPercent(slider->getPercent());
}
}
示例7: switch
void UISliderTest::sliderEvent(CCObject *pSender, SliderEventType type)
{
switch (type)
{
case SLIDER_PERCENTCHANGED:
{
UISlider* slider = dynamic_cast<UISlider*>(pSender);
int percent = slider->getPercent();
m_pDisplayValueLabel->setText(CCString::createWithFormat("Percent %d", percent)->getCString());
}
break;
default:
break;
}
}
示例8: switch
void HelloWorld::sliderEvent( CCObject *pSender, SliderEventType type )
{
switch (type)
{
case SLIDER_PERCENTCHANGED:
{
UISlider* slider = dynamic_cast<UISlider*>(pSender);
int percent = slider->getPercent();
CCLOG("%d", percent);
}
break;
default:
break;
}
}
示例9: PSSMFactorChangedHandler
void CascadedShadowMapApp::PSSMFactorChangedHandler(UISlider const & sender)
{
pssm_factor_ = sender.GetValue() * 0.01f;
std::wostringstream stream;
stream << L"PSSM Factor: " << pssm_factor_;
dialog_->Control<UIStatic>(id_pssm_factor_static_)->SetText(stream.str());
deferred_rendering_->SetViewportCascades(0, num_cascades_, pssm_factor_);
}
示例10: LengthChangedHandler
void AreaLightingApp::LengthChangedHandler(UISlider const & sender)
{
float length = sender.GetValue() / 100.0f;
checked_pointer_cast<TubeAreaLightSource>(tube_area_light_)->Extend(float3(0.1f, 0.1f, length));
checked_pointer_cast<SceneObjectLightSourceProxy>(tube_area_light_src_)->Scaling(0.1f, 0.1f, length);
std::wostringstream stream;
stream << L"Length: " << length;
dialog_->Control<UIStatic>(id_length_static_)->SetText(stream.str());
}
示例11: RadiusChangedHandler
void AreaLightingApp::RadiusChangedHandler(UISlider const & sender)
{
float radius = sender.GetValue() / 100.0f;
checked_pointer_cast<SphereAreaLightSource>(sphere_area_light_)->Radius(radius);
checked_pointer_cast<SceneObjectLightSourceProxy>(sphere_area_light_src_)->Scaling(radius, radius, radius);
std::wostringstream stream;
stream << L"Radius: " << radius;
dialog_->Control<UIStatic>(id_radius_static_)->SetText(stream.str());
}
示例12: sliderpercentchangedselector
/*===*/
bool UISliderTest::init()
{
if (UIScene::init())
{
CCSize widgetSize = m_pWidget->getSize();
// Add a label in which the slider alert will be displayed
m_pDisplayValueLabel = UILabel::create();
m_pDisplayValueLabel->setText("Move the slider thumb");
m_pDisplayValueLabel->setFontName("Marker Felt");
m_pDisplayValueLabel->setFontSize(32);
m_pDisplayValueLabel->setAnchorPoint(ccp(0.5f, -1));
m_pDisplayValueLabel->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
m_pUiLayer->addWidget(m_pDisplayValueLabel);
// Add the alert
UILabel *alert = UILabel::create();
alert->setText("Slider");
alert->setFontName("Marker Felt");
alert->setFontSize(30);
alert->setColor(ccc3(159, 168, 176));
alert->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75));
m_pUiLayer->addWidget(alert);
// Create the slider
UISlider* slider = UISlider::create();
slider->setTouchEnabled(true);
slider->loadBarTexture("cocosgui/sliderTrack.png");
slider->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", "");
slider->loadProgressBarTexture("cocosgui/sliderProgress.png");
slider->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
// slider->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f + slider->getSize().height * 2));
slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest::sliderEvent));
m_pUiLayer->addWidget(slider);
/*
// Create the slider that set allow min progress and allow max progress
UISlider* sliderAllow = UISlider::create();
//===//
// sliderAllow->setMinAllowPercent(20);
// sliderAllow->setMaxAllowPercent(80);
//
sliderAllow->setTouchEnabled(true);
sliderAllow->loadBarTexture("cocosgui/sliderTrack.png");
sliderAllow->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", "");
sliderAllow->loadProgressBarTexture("cocosgui/sliderProgress.png");
sliderAllow->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f - sliderAllow->getSize().height * 2));
sliderAllow->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest::sliderEvent));
m_pUiLayer->addWidget(sliderAllow);
*/
return true;
}
return false;
}
示例13: VolumeChangedHandler
void SoundApp::VolumeChangedHandler(UISlider const & sender)
{
volume_ = sender.GetValue() * 0.01f;
AudioFactory& af = Context::Instance().AudioFactoryInstance();
AudioEngine& ae = af.AudioEngineInstance();
ae.SoundVolume(volume_);
ae.MusicVolume(volume_);
std::wostringstream stream;
stream << L"Volume: " << volume_;
dialog_->Control<UIStatic>(id_volume_static_)->SetText(stream.str());
}
示例14: percentChangedEvent
void UISliderTest::percentChangedEvent(CCObject *pSender)
{
UISlider* slider = dynamic_cast<UISlider*>(pSender);
int percent = slider->getPercent();
m_pDisplayValueLabel->setText(CCString::createWithFormat("Percent %d", percent)->getCString());
}
示例15: UIPopupWindow
UIWidget* UI::WrapWidget(tb::TBWidget* widget)
{
if (!widget)
return NULL;
if (widgetWrap_.Contains(widget))
return widgetWrap_[widget];
// switch this to use a factory?
// this is order dependent as we're using IsOfType which also works if a base class
if (widget->IsOfType<TBPopupWindow>())
{
UIPopupWindow* popupWindow = new UIPopupWindow(context_, false);
popupWindow->SetWidget(widget);
WrapWidget(popupWindow, widget);
return popupWindow;
}
if (widget->IsOfType<TBDimmer>())
{
UIDimmer* dimmer = new UIDimmer(context_, false);
dimmer->SetWidget(widget);
WrapWidget(dimmer, widget);
return dimmer;
}
if (widget->IsOfType<TBScrollContainer>())
{
UIScrollContainer* container = new UIScrollContainer(context_, false);
container->SetWidget(widget);
WrapWidget(container, widget);
return container;
}
if (widget->IsOfType<TBInlineSelect>())
{
UIInlineSelect* select = new UIInlineSelect(context_, false);
select->SetWidget(widget);
WrapWidget(select, widget);
return select;
}
if (widget->IsOfType<TBSlider>())
{
UISlider* slider = new UISlider(context_, false);
slider->SetWidget(widget);
WrapWidget(slider, widget);
return slider;
}
if (widget->IsOfType<TBScrollBar>())
{
UIScrollBar* slider = new UIScrollBar(context_, false);
slider->SetWidget(widget);
WrapWidget(slider, widget);
return slider;
}
if (widget->IsOfType<TBColorWidget>())
{
UIColorWidget* colorWidget = new UIColorWidget(context_, false);
colorWidget->SetWidget(widget);
WrapWidget(colorWidget, widget);
return colorWidget;
}
if (widget->IsOfType<TBColorWheel>())
{
UIColorWheel* colorWheel = new UIColorWheel(context_, false);
colorWheel->SetWidget(widget);
WrapWidget(colorWheel, widget);
return colorWheel;
}
if (widget->IsOfType<TBSection>())
{
UISection* section = new UISection(context_, false);
section->SetWidget(widget);
WrapWidget(section, widget);
return section;
}
if (widget->IsOfType<TBSeparator>())
{
UISeparator* sep = new UISeparator(context_, false);
sep->SetWidget(widget);
WrapWidget(sep, widget);
return sep;
}
if (widget->IsOfType<TBContainer>())
{
UIContainer* container = new UIContainer(context_, false);
container->SetWidget(widget);
WrapWidget(container, widget);
return container;
}
//.........这里部分代码省略.........