ScrollList::ScrollList(ds::ui::SpriteEngine& engine, const bool vertical) : ds::ui::Sprite(engine) , mScrollArea(nullptr) , mStartPositionX(10.0f) , mIncrementAmount(50.0f) , mAnimateOnDeltaDelay(0.0f) , mAnimateOnStartDelay(0.0f) , mVerticalScrolling(vertical) , mFillFromTop(true) { mScrollArea = new ds::ui::ScrollArea(mEngine, getWidth(), getHeight(), mVerticalScrolling); if(mScrollArea){ mScrollArea->setScrollUpdatedCallback([this](ds::ui::Sprite*){ assignItems(); }); mScrollArea->setFadeColors(ci::ColorA(0.0f, 0.0f, 0.0f, 1.0f), ci::ColorA(0.0f, 0.0f, 0.0f, 0.0f)); mScrollArea->setFadeHeight(50.0f); mScrollArea->setUseFades(true); addChildPtr(mScrollArea); } mScrollableHolder = new ds::ui::Sprite(mEngine); if(mScrollableHolder){ mScrollArea->addSpriteToScroll(mScrollableHolder); mScrollableHolder->enable(false); } enable(false); }
void TreeInspector::highlightSprite( const ds::ui::Sprite* sprite ) { auto showHighlight = [&]( const ds::ui::Sprite* s ) { if (!mHighlighter) { mHighlighter = new ds::ui::Sprite( mEngine ); mHighlighter->setTransparent( false ); mHighlighter->setColorA( ci::ColorA::hexA( 0xAA6fa8dc ) ); addChildPtr( mHighlighter ); auto crosshairColor = ci::Color::hex( (0xf6b26b) ); auto hCrosshair = new ds::ui::Sprite( mEngine, 40.0f, 3.0f ); hCrosshair->setTransparent( false ); hCrosshair->setColor( crosshairColor ); mHighlighter->addChildPtr( hCrosshair ); auto vCrosshair = new ds::ui::Sprite( mEngine, 3.0f, 40.0f ); vCrosshair->setTransparent( false ); vCrosshair->setColor( crosshairColor ); mHighlighter->addChildPtr( vCrosshair ); } mHighlighter->show(); mHighlighter->setSize( s->getWidth(), s->getHeight() ); auto pos = s->getGlobalPosition(); mHighlighter->setPosition( globalToLocal( pos ) ); }; if (sprite) { showHighlight(sprite); } else if (mHighlighter) { mHighlighter->hide(); } }
ScrollBar::ScrollBar(ds::ui::SpriteEngine& engine, const bool vertical, const float uiWidth, const float touchPadding, const bool autoHide) : Sprite(engine) , mVertical(vertical) , mNub(nullptr) , mBackground(nullptr) , mScrollPercent(0.0f) , mPercentVisible(1.0f) , mMinNubSize(uiWidth) , mTouchPadding(touchPadding) , mAutoHide(autoHide) , mAutoHidden(false) { // Set some defaults // You can change these by getting the nub and background sprites and changing them mBackground = new ds::ui::Sprite(mEngine); mBackground->mExportWithXml = false; mBackground->setTransparent(false); mBackground->setColor(ci::Color(0.1f, 0.1f, 0.1f)); mBackground->setCornerRadius(uiWidth/2.0f); mBackground->setOpacity(0.7f); addChildPtr(mBackground); mNub = new ds::ui::Sprite(mEngine); mNub->mExportWithXml = false; mNub->setTransparent(false); mNub->setColor(ci::Color(0.9f, 0.9f, 0.9f)); mNub->setOpacity(0.3f); mNub->setSize(uiWidth, uiWidth); mNub->setCornerRadius(uiWidth/2.0f); addChildPtr(mNub); enable(true); enableMultiTouch(ds::ui::MULTITOUCH_INFO_ONLY); setProcessTouchCallback([this](ds::ui::Sprite* bs, const ds::ui::TouchInfo& ti){ handleScrollTouch(bs, ti); }); setSize(mTouchPadding * 2.0f + uiWidth, mTouchPadding * 2.0f + uiWidth); if(mAutoHide){ doAutoHide(true); hide(); // immediately hide, but also call the function to track the state correctly setOpacity(0.0f); animOpacityStop(); } }
void ViewerController::addViewer(ds::model::MediaRef newMedia, const ci::Vec3f location, const float startWidth) { TitledMediaViewer* tmv = new TitledMediaViewer(mGlobals); addChildPtr(tmv); mViewers.push_back(tmv); tmv->setMedia(newMedia); tmv->setPosition(location); tmv->setViewerWidth(startWidth); tmv->animateOn(); }
TextTest::TextTest(Globals& g) : inherited(g.mEngine) , mGlobals(g) , mEventClient(g.mEngine.getNotifier(), [this](const ds::Event *m){ if(m) this->onAppEvent(*m); }) , mMessage(nullptr) { mMessage = mGlobals.getText("sample:config").createMultiline(mEngine, this); if(mMessage){ std::wstring theText = ds::wstr_from_utf8(mGlobals.getSettingsLayout().getText("text:test:text", 0, "")); mMessage->setText(theText); Poco::Timestamp::TimeVal before = Poco::Timestamp().epochMicroseconds(); ci::vec2 resizeSize = mGlobals.getSettingsLayout().getSize("text:test:resize", 0, ci::vec2(0.0f, 0.0f)); mMessage->setResizeLimit(resizeSize.x, resizeSize.y); std::cout << mMessage->getWidth() << " " << mMessage->getPositionForCharacterIndex(0) << std::endl; Poco::Timestamp::TimeVal after = Poco::Timestamp().epochMicroseconds(); float delty = (float)(after - before) / 1000000.0f; std::cout << "Layout time: " << delty << std::endl; std::vector<ci::Rectf> characterPositions; for(int i = 0; i < theText.size() + 1; i++){ ci::Rectf possy = mMessage->getRectForCharacterIndex(i); characterPositions.push_back(possy); } for(int i = 0; i < theText.size(); i++){ ci::Rectf possy = characterPositions[i]; //ci::vec2 possyTwo = ci::vec2(0.0f, 0.0f); //if(i + 1 < theText.size()){ // possyTwo = characterPositions[i + 1]; //} ds::ui::Sprite* overlay = new ds::ui::Sprite(mEngine); addChildPtr(overlay); overlay->setTransparent(false); overlay->setColor(ci::Color(ci::randFloat(), ci::randFloat(), ci::randFloat())); overlay->setPosition(possy.x1, possy.y1); overlay->setSize(possy.getWidth(), possy.getHeight()); overlay->setOpacity(0.5f); mCharacterOverlays.push_back(overlay); } } layout(); setPosition(mGlobals.getSettingsLayout().getSize("text:test:offset", 0, ci::vec2())); }
MediaSlideshow::MediaSlideshow(ds::ui::SpriteEngine& eng) : ds::ui::Sprite(eng) , mHolder(nullptr) , mCurItemIndex(0) , mAnimateDuration(0.35f) , mCurrentInterface(nullptr) , mItemChangedCallback(nullptr) , mAllowLoadAhead(true) { mHolder = new ds::ui::Sprite(mEngine); addChildPtr(mHolder); }
TreeItem::TreeItem(Globals& g, ds::ui::Sprite* linkedItem) : ds::ui::Sprite(g.mEngine) , mGlobals(g) , mLinkedSprite(linkedItem) , mNameText(nullptr) , mLabelTextTwo(nullptr) { ds::ui::ImageButton* deleteButton = new ds::ui::ImageButton(mEngine, "%APP%/data/images/ui/close_button.png", "%APP%/data/images/ui/close_button.png", 10.0f); deleteButton->setScale(0.25f, 0.25f); deleteButton->getHighImage().setColor(ci::Color(0.7f, 0.2f, 0.2f)); addChildPtr(deleteButton); deleteButton->setClickFn([this]{ callAfterDelay([this]{ mEngine.getNotifier().notify(DeleteSpriteRequest(mLinkedSprite)); }, 0.01f); }); float paddin = 10.0f; mLayoutLPad = paddin / 2.0f; mLayoutRPad = paddin/2.0f; float theWiddy = 0.0f; float theHiddy = 0.0f; mNameText = mGlobals.getText("tree:item").create(mEngine, this); mNameText->setText(mLinkedSprite->getSpriteName()); mNameText->setPosition(deleteButton->getScaleWidth(), paddin / 2.0f); theWiddy += mNameText->getWidth() + paddin / 2.0f + deleteButton->getScaleWidth(); theHiddy = mNameText->getFontSize() + paddin; mLabelTextTwo = mGlobals.getText("tree:item_two").create(mEngine, this); mLabelTextTwo->setText(ds::ui::XmlImporter::getSpriteTypeForSprite(mLinkedSprite)); mLabelTextTwo->setPosition(theWiddy, paddin / 2.0f); theWiddy += mLabelTextTwo->getWidth() + paddin / 2.0f; if(mLabelTextTwo->getFontSize() + paddin > theHiddy){ theHiddy = mLabelTextTwo->getFontSize() + paddin; } setTransparent(false); setColor(ci::Color(0.1f, 0.1f, 0.1f)); setSize(theWiddy, theHiddy); enable(true); enableMultiTouch(ds::ui::MULTITOUCH_CAN_POSITION); setTapCallback([this](ds::ui::Sprite* bs, const ci::Vec3f& pos){ if(mLinkedSprite){ mEngine.getNotifier().notify(InspectSpriteRequest(mLinkedSprite)); } }); }
ScrollList::ScrollList(ds::ui::SpriteEngine& engine, const bool vertical) : ds::ui::Sprite(engine) , mScrollArea(nullptr) , mStartPositionX(10.0f) , mStartPositionY(0.0f) , mIncrementAmount(50.0f) , mAnimateOnDeltaDelay(0.0f) , mAnimateOnStartDelay(0.0f) , mVerticalScrolling(vertical) , mFillFromTop(true) , mGridLayout(false) , mSpecialLayout(false) , mTargetRow(0) , mTargetColumn(0) , mGapping(0) { mScrollArea = new ds::ui::ScrollArea(mEngine, getWidth(), getHeight(), mVerticalScrolling); if(mScrollArea){ mScrollArea->setScrollUpdatedCallback([this](ds::ui::Sprite*){ assignItems(); if(mScrollUpdatedCallback){ mScrollUpdatedCallback(); } }); mScrollArea->setScrollerTouchedCallback([this]{ mLastUpdateTime = Poco::Timestamp().epochMicroseconds(); }); mScrollArea->setFadeColors(ci::ColorA(0.0f, 0.0f, 0.0f, 1.0f), ci::ColorA(0.0f, 0.0f, 0.0f, 0.0f)); mScrollArea->setFadeHeight(50.0f); mScrollArea->setUseFades(true); addChildPtr(mScrollArea); } mScrollableHolder = new ds::ui::Sprite(mEngine); if(mScrollableHolder){ mScrollArea->addSpriteToScroll(mScrollableHolder); mScrollableHolder->enable(false); } mLastUpdateTime = Poco::Timestamp().epochMicroseconds(); enable(false); }
void DrawTouchView::touchBegin(const ds::ui::TouchInfo &ti){ if(mTouchTrailsUse) { mTouchPointHistory[ti.mFingerId] = std::vector<ci::Vec3f>(); mTouchPointHistory[ti.mFingerId].push_back(ti.mCurrentGlobalPoint); } else { if(mCircles[ti.mFingerId]){ mCircles[ti.mFingerId]->show(); } else { Circle* circley = new Circle(mEngine, false, 20.0f); circley->setColor(getColor()); circley->setDrawDebug(true); circley->setCenter(0.5f, 0.5f); addChildPtr(circley); mCircles[ti.mFingerId] = circley; } if(mCircles[ti.mFingerId]) mCircles[ti.mFingerId]->setPosition(ti.mCurrentGlobalPoint); } }
MediaInterface::MediaInterface(ds::ui::SpriteEngine& eng, const ci::Vec2f& sizey, const ci::Color backgroudnColor) : ds::ui::Sprite(eng, sizey.x, sizey.y) , mBackground(nullptr) , mIdling(nullptr) , mAnimateDuration(0.35f) { // TODO: settings? const float backOpacccy = 0.95f; const float idleSeconds = 5.0f; mBackground = new ds::ui::Sprite(mEngine); mBackground->setTransparent(false); mBackground->setColor(backgroudnColor); mBackground->setOpacity(backOpacccy); addChildPtr(mBackground); setSecondBeforeIdle(idleSeconds); resetIdleTimer(); layout(); }
void TreeInspector::inspectTree(ds::ui::Sprite* sp) { clearTree(); mTreeRoot = sp; // todo: make this an xml mLayout = new ds::ui::LayoutSprite(mEngine); mLayout->setSpriteName(L"This layout"); mLayout->setLayoutType(ds::ui::LayoutSprite::kLayoutVFlow); mLayout->setSpacing(5.0f); mLayout->setShrinkToChildren(ds::ui::LayoutSprite::kShrinkBoth); mLayout->setTransparent(false); mLayout->setColor(ci::Color(0.2f, 0.2f, 0.2f)); addChildPtr(mLayout); treeParseRecursive(sp, 0); layout(); animateOn(); }
void PanoramicVideo::loadVideo(const std::string& path){ if(mVideoSprite){ mVideoSprite->release(); mVideoSprite = nullptr; } // this does some dumb shit // any added children are listened to and linked to the video sprite // this is for the net sync stuff // there should be a better way to do this auto video_sprite = addChildPtr(new ds::ui::Video(mEngine)); //Need to enable this to enable panning video_sprite->generateAudioBuffer(true); video_sprite->setPan(mPanning); video_sprite->setPlayableInstances(mPlayableInstances); video_sprite->setAutoStart(true); video_sprite->setLooping(true); video_sprite->setAutoSynchronize(mAutoSync); video_sprite->loadVideo(path); video_sprite->setFinalRenderToTexture(true); resetCamera(); }
void MediaPlayer::initialize(){ if(mInitialized) return; const int mediaType = mResource.getType(); if(mediaType == ds::Resource::ERROR_TYPE || mediaType == ds::Resource::FONT_TYPE){ // this is not a useful warning message in the very common case of setting the size of a MediaPlayer before loading the media // GN: This is a VERY useful message if your media isn't showing up, so we'll just check for emptiness instead of no warning if(!mResource.empty()){ DS_LOG_WARNING("Whoopsies - tried to open a media player on an invalid file type. " << mResource.getAbsoluteFilePath()); } return; } // do this first to avoid recursion problems mInitialized = true; float contentWidth = 1.0f; float contentHeight = 1.0f; mContentAspectRatio = 1.0f; bool showThumbnail = true; if(mediaType == ds::Resource::IMAGE_TYPE){ int flags = 0; if(mMediaViewerSettings.mCacheImages){ flags |= Image::IMG_CACHE_F; } mPrimaryImage = new ds::ui::Image(mEngine, mResource, flags); addChildPtr(mPrimaryImage); mPrimaryImage->checkStatus(); if(mPrimaryImage->isLoaded()){ showThumbnail = false; } else { mPrimaryImage->setOpacity(0.0f); mPrimaryImage->setStatusCallback([this](ds::ui::Image::Status status){ if(status.mCode == status.STATUS_LOADED && mPrimaryImage){ mPrimaryImage->tweenOpacity(1.0f, mAnimDuration); if(mStatusCallback){ mStatusCallback(true); } } }); } mContentAspectRatio = mPrimaryImage->getWidth() / mPrimaryImage->getHeight(); contentWidth = mPrimaryImage->getWidth(); contentHeight = mPrimaryImage->getHeight(); } else if(mediaType == ds::Resource::VIDEO_TYPE){ mVideoPlayer = new VideoPlayer(mEngine, mEmbedInterface); addChildPtr(mVideoPlayer); mVideoPlayer->setErrorCallback([this](const std::string& msg){ if(mErrorCallback) mErrorCallback(msg); }); mVideoPlayer->setGoodStatusCallback([this]{ if(mStatusCallback) mStatusCallback(true); }); mVideoPlayer->setPan(mMediaViewerSettings.mVideoPanning); mVideoPlayer->setAutoSynchronize(mMediaViewerSettings.mVideoAutoSync); mVideoPlayer->setPlayableInstances(mMediaViewerSettings.mVideoPlayableInstances); mVideoPlayer->setAutoPlayFirstFrame(mMediaViewerSettings.mVideoAutoPlayFirstFrame); mVideoPlayer->setVideoLoop(mMediaViewerSettings.mVideoLoop); mVideoPlayer->setMedia(mResource.getAbsoluteFilePath()); mContentAspectRatio = mVideoPlayer->getWidth() / mVideoPlayer->getHeight(); contentWidth = mVideoPlayer->getWidth(); contentHeight = mVideoPlayer->getHeight(); } else if(mediaType == ds::Resource::VIDEO_STREAM_TYPE){ mStreamPlayer = new StreamPlayer(mEngine, mEmbedInterface); addChildPtr(mStreamPlayer); mStreamPlayer->setErrorCallback([this](const std::string& msg){ if(mErrorCallback) mErrorCallback(msg); }); mStreamPlayer->setGoodStatusCallback([this]{ if(mStatusCallback) mStatusCallback(true); }); mStreamPlayer->setResource(mResource); mContentAspectRatio = mStreamPlayer->getWidth() / mStreamPlayer->getHeight(); contentWidth = mStreamPlayer->getWidth(); contentHeight = mStreamPlayer->getHeight(); } else if(mediaType == ds::Resource::PDF_TYPE){ mPDFPlayer = new PDFPlayer(mEngine, mEmbedInterface); addChildPtr(mPDFPlayer); mPDFPlayer->setMedia(mResource.getAbsoluteFilePath()); mPDFPlayer->setErrorCallback([this](const std::string& msg){ if(mErrorCallback) mErrorCallback(msg); }); mPDFPlayer->setGoodStatusCallback([this]{ if(mStatusCallback){ mStatusCallback(true); } }); mContentAspectRatio = mPDFPlayer->getWidth() / mPDFPlayer->getHeight(); contentWidth = mPDFPlayer->getWidth(); contentHeight = mPDFPlayer->getHeight(); } else if(mediaType == ds::Resource::WEB_TYPE){ mWebPlayer = new WebPlayer(mEngine, mEmbedInterface); addChildPtr(mWebPlayer); mWebPlayer->setWebViewSize(mMediaViewerSettings.mWebDefaultSize); mWebPlayer->setKeyboardParams(mMediaViewerSettings.mWebKeyboardPanelSize, mMediaViewerSettings.mWebKeyboardKeyScale, mMediaViewerSettings.mWebAllowKeyboard); mWebPlayer->setAllowTouchToggle(mMediaViewerSettings.mWebAllowTouchToggle); mWebPlayer->setMedia(mResource.getAbsoluteFilePath()); if(mWebPlayer->getWeb()){ mWebPlayer->getWeb()->setDocumentReadyFn([this]{ if(mStatusCallback) mStatusCallback(true); }); mWebPlayer->getWeb()->setErrorCallback([this](const std::string& errorMsg){ if(mErrorCallback) mErrorCallback(errorMsg); }); } mContentAspectRatio = mWebPlayer->getWidth() / mWebPlayer->getHeight(); contentWidth = mWebPlayer->getWidth(); contentHeight = mWebPlayer->getHeight(); } else { DS_LOG_WARNING("Whoopsies - tried to open a media player on an invalid file type. " << mResource.getAbsoluteFilePath() << " " << ds::utf8_from_wstr(mResource.getTypeName())); } if(showThumbnail && (mResource.getThumbnailId() > 0 || !mResource.getThumbnailFilePath().empty())){ int flags = 0; if(mMediaViewerSettings.mCacheImages){ flags |= Image::IMG_CACHE_F; } mThumbnailImage = new ds::ui::Image(mEngine); addChildPtr(mThumbnailImage); mThumbnailImage->sendToBack(); if(mResource.getThumbnailId() > 0){ mThumbnailImage->setImageResource(mResource.getThumbnailId(), flags); } else { mThumbnailImage->setImageFile(mResource.getThumbnailFilePath(), flags); } mThumbnailImage->setOpacity(0.0f); mThumbnailImage->setStatusCallback([this](ds::ui::Image::Status status){ if(status.mCode == status.STATUS_LOADED && mThumbnailImage){ mThumbnailImage->tweenOpacity(1.0f, mAnimDuration); } }); } setSize(contentWidth, contentHeight); if(mInitializedCallback){ mInitializedCallback(); } }
PDFInterface::PDFInterface(ds::ui::SpriteEngine& eng, const ci::Vec2f& sizey, const float buttonHeight, const ci::Color buttonColor, const ci::Color backgroundColor) : MediaInterface(eng, sizey, backgroundColor) , mLinkedPDF(nullptr) , mUpButton(nullptr) , mDownButton(nullptr) , mPageCounter(nullptr) , mTouchToggle(nullptr) { mUpButton = new ds::ui::ImageButton(mEngine, "%APP%/data/images/media_interface/prev.png", "%APP%/data/images/media_interface/prev.png", (sizey.y - buttonHeight) / 2.0f); addChildPtr(mUpButton); mUpButton->setClickFn([this](){ if(mLinkedPDF){ if(mLinkedPDF->getPageCount() > 1){ mLinkedPDF->goToPreviousPage(); updateWidgets(); } } }); mUpButton->getNormalImage().setColor(buttonColor); mUpButton->getHighImage().setColor(buttonColor / 2.0f); mUpButton->setScale(sizey.y / mUpButton->getHeight()); mDownButton = new ds::ui::ImageButton(mEngine, "%APP%/data/images/media_interface/next.png", "%APP%/data/images/media_interface/next.png", (sizey.y - buttonHeight) / 2.0f); addChildPtr(mDownButton); mDownButton->setClickFn([this](){ if(mLinkedPDF){ if(mLinkedPDF->getPageCount() > 1){ mLinkedPDF->goToNextPage(); updateWidgets(); } } }); mDownButton->getNormalImage().setColor(buttonColor); mDownButton->getHighImage().setColor(buttonColor / 2.0f); mDownButton->setScale(sizey.y / mDownButton->getHeight()); mPageCounter = mEngine.getEngineCfg().getText("viewer:widget").create(mEngine, this); if(mPageCounter){ mPageCounter->setResizeToText(true); mPageCounter->enable(false); } mTouchToggle = new ds::ui::ImageButton(mEngine, "%APP%/data/images/media_interface/touch_unlocked.png", "%APP%/data/images/media_interface/touch_unlocked.png", (sizey.y - buttonHeight) / 2.0f); addChildPtr(mTouchToggle); mTouchToggle->setClickFn([this](){ if(mLinkedPDF){ if(mLinkedPDF->isEnabled()){ mLinkedPDF->enable(false); } else { mLinkedPDF->enable(true); } updateWidgets(); } }); mTouchToggle->getNormalImage().setColor(buttonColor); mTouchToggle->getHighImage().setColor(buttonColor / 2.0f); mTouchToggle->setScale(sizey.y / mTouchToggle->getHeight()); updateWidgets(); }
void SpriteInspector::inspectSprite(ds::ui::Sprite* sp) { clearProperties(); if(!sp) return; mLinkedSprite = sp; // todo: make this an xml mLayout = new ds::ui::LayoutSprite(mEngine); mLayout->setSpriteName(L"This layout"); mLayout->setLayoutType(ds::ui::LayoutSprite::kLayoutVFlow); //mLayout->setSpacing(5.0f); mLayout->setShrinkToChildren(ds::ui::LayoutSprite::kShrinkBoth); mLayout->setTransparent(false); mLayout->setColor(ci::Color(0.2f, 0.2f, 0.2f)); addChildPtr(mLayout); addSpriteProperty(L"name", sp->getSpriteName()); addSpriteProperty(L"type", ds::wstr_from_utf8(ds::ui::XmlImporter::getSpriteTypeForSprite(sp))); addSpriteProperty(L"size", sp->getSize()); addSpriteProperty(L"color", sp->getColor()); addSpriteProperty(L"opacity", sp->getOpacity()); addSpriteProperty(L"center", sp->getCenter()); addSpriteProperty(L"position", sp->getPosition()); addSpriteProperty(L"rotation", sp->getRotation()); addSpriteProperty(L"scale", sp->getScale()); addSpriteProperty(L"clipping", sp->getClipping()); addSpritePropertyBlend(L"blend_mode", sp->getBlendMode()); addSpriteProperty(L"enable", sp->isEnabled()); addSpriteProperty(L"multitouch", sp->getMultiTouchConstraints()); addSpriteProperty(L"transparent", sp->getTransparent()); addSpriteProperty(L"animate_on", ds::wstr_from_utf8(sp->getAnimateOnScript())); addSpriteProperty(L"t_pad", sp->mLayoutTPad); addSpriteProperty(L"l_pad", sp->mLayoutLPad); addSpriteProperty(L"b_pad", sp->mLayoutBPad); addSpriteProperty(L"r_pad", sp->mLayoutRPad); addSpriteProperty(L"layout_fudge", sp->mLayoutFudge); addSpriteProperty(L"layout_size", sp->mLayoutSize); addSpritePropertyLayoutSizeMode(L"layout_size_mode", sp->mLayoutUserType); addSpritePropertyLayoutVAlign(L"layout_v_align", sp->mLayoutVAlign); addSpritePropertyLayoutHAlign(L"layout_h_align", sp->mLayoutHAlign); ds::ui::LayoutSprite* ls = dynamic_cast<ds::ui::LayoutSprite*>(mLinkedSprite); if(ls){ addSpritePropertyLayoutType(L"layout_type", ls->getLayoutType()); addSpriteProperty(L"layout_spacing", ls->getSpacing()); addSpritePropertyLayoutShrink(L"shrink_to_children", ls->getShrinkToChildren()); addSpritePropertyLayoutVAlign(L"overall_alignment", ls->getOverallAlignment()); } ds::ui::Text* texty = dynamic_cast<ds::ui::Text*>(mLinkedSprite); if(texty){ addSpriteProperty(L"text", texty->getText()); addSpriteProperty(L"font", ds::wstr_from_utf8(texty->getConfigName())); // addSpriteProperty(L"font_size", texty->getFontSize()); } ds::ui::MultilineText* multitexty = dynamic_cast<ds::ui::MultilineText*>(mLinkedSprite); if(multitexty){ addSpriteProperty(L"resize_limit", ci::Vec2f(multitexty->getResizeLimitWidth(), multitexty->getResizeLimitHeight())); addSpritePropertyLayoutHAlign(L"text_align", multitexty->getAlignment()); } ds::ui::Gradient* grad = dynamic_cast<ds::ui::Gradient*>(mLinkedSprite); if(grad){ addSpriteProperty(L"gradientColors", ds::wstr_from_utf8(ds::ui::XmlImporter::getGradientColorsAsString(grad))); } ds::ui::Circle* circle = dynamic_cast<ds::ui::Circle*>(mLinkedSprite); if(circle){ addSpriteProperty(L"filled", circle->getFilled()); addSpriteProperty(L"radius", circle->getRadius()); } ds::ui::Border* border = dynamic_cast<ds::ui::Border*>(mLinkedSprite); if(border){ addSpriteProperty(L"border_width", border->getBorderWidth()); } ds::ui::Image* img = dynamic_cast<ds::ui::Image*>(mLinkedSprite); if(img){ addSpriteProperty(L"filename", ds::wstr_from_utf8(ds::Environment::contract(img->getImageFilename()))); addSpriteProperty(L"circle_crop", img->getCircleCrop()); } ds::ui::ImageButton* imgB = dynamic_cast<ds::ui::ImageButton*>(mLinkedSprite); if(imgB){ std::string normImgFile = ds::Environment::contract(imgB->getNormalImage().getImageFilename()); std::string highImgFile = ds::Environment::contract(imgB->getHighImage().getImageFilename()); if(normImgFile == highImgFile){ addSpriteProperty(L"filename", ds::wstr_from_utf8(normImgFile)); } else { addSpriteProperty(L"up_image", ds::wstr_from_utf8(normImgFile)); addSpriteProperty(L"down_image", ds::wstr_from_utf8(highImgFile)); } addSpriteProperty(L"btn_touch_padding", imgB->getPad()); addSpriteProperty(L"down_image_color", imgB->getHighImageColor()); } layout(); animateOn(); }