void NDUIButton::drawLongTouch() { NDPicture *pic = NULL; if (m_touchDownImage != NULL) { pic = m_touchDownImage; } else { pic = m_image ? m_image : m_picBG; } if (pic) { pic->SetColor(ccc4(255, 255, 255, 255)); //** chh 2012-07-31 修改button放大效果 **// /* CCRect rect = CCRectMake(scrRect.origin.x - 5 * fScale, scrRect.origin.y - 5 * fScale, scrRect.size.width + 10 * fScale, scrRect.size.height + 10 * fScale); */ CCRect scrRect = this->GetScreenRect(); pic->DrawInRect(scrRect); pic->SetColor(m_normalImageColor); } }
void NDUIEdit::draw_ios_ime() //for ios { CCRect scrRect; if (m_pPlatformInput) { //** chh 2012-06-19 **// scrRect = m_pkTextLabel->GetFrameRect(); CCSize textSize = getStringSize(TEST_TEXT,m_pkTextLabel->GetFontSize()); int HBorder = (this->GetScreenRect().size.height-textSize.height)/2; m_pPlatformInput->SetFrame(scrRect.origin.x, scrRect.origin.y+HBorder, scrRect.size.width, scrRect.size.height); } if (m_bRecacl && m_pPlatformInput) { m_pPlatformInput->SetText(m_strText.c_str()); m_pPlatformInput->EnableSafe(m_bPassword); // m_pPlatformInput->SetStyleNone(); m_bRecacl = false; } NDPicture* pic = m_picImage; if (m_pPlatformInput && m_pPlatformInput->IsInputState() && m_picFocusImage) { pic = m_picFocusImage; } if (pic) { pic->DrawInRect(scrRect); } }
bool DrawAni::doDraw(const int frameIndex, const AniModify* mod_lev2, const AniModify* mod_lev3) { if (!m_pkAni || !m_pkInstance || !m_pkInstance->getOwnerNode()) return false; // get picture to draw NDPicture* pkPicture = getPicture(m_pkAni, frameIndex); if (!pkPicture) return false; // get node screen rect CCRect kNodeRect; NDNode* pkOwnerNode = m_pkInstance->getOwnerNode(); if (pkOwnerNode->IsA(RTCLS(NDTileObj))) { NDTileObj* pkTileObj = (NDTileObj*) pkOwnerNode; if (pkTileObj->isPlayer() || pkTileObj->isPath()) kNodeRect = pkOwnerNode->GetScreenRect(); else kNodeRect = pkOwnerNode->GetPushScreenRect(); } else { kNodeRect = pkOwnerNode->GetScreenRect(); } // node center pos (caution: world map tile obj!) CCPoint centerPos = CCPointMake( kNodeRect.origin.x + kNodeRect.size.width * 0.5f, kNodeRect.origin.y + kNodeRect.size.height * 0.5f); // get node scale (recursive) float nodeScaleX = pkOwnerNode->GetScaleX_R(); float nodeScaleY = pkOwnerNode->GetScaleY_R(); // add offset int sign = pkOwnerNode->isReverse() ? -1 : 1; centerPos.x += m_pkAni->m_kAniModifyEx.getOffsetX() * COORD_SCALE_X_960 * nodeScaleX * sign; centerPos.y += m_pkAni->m_kAniModifyEx.getOffsetY() * COORD_SCALE_Y_960 * nodeScaleY; // apply mod: offset if (mod_lev2) { centerPos.x += mod_lev2->getOffsetX() * COORD_SCALE_X_960 * nodeScaleX * sign; centerPos.y += mod_lev2->getOffsetY() * COORD_SCALE_Y_960 * nodeScaleY; } if (mod_lev3) { centerPos.x += mod_lev3->getOffsetX() * COORD_SCALE_X_960 * nodeScaleX * sign; centerPos.y += mod_lev3->getOffsetY() * COORD_SCALE_Y_960 * nodeScaleY; } // calculate pic size CCSize picSize = pkPicture->GetSize(); if (m_pkAni->m_kAniModifyEx.getStretch()) { picSize.width *= COORD_SCALE_X_960; picSize.height *= COORD_SCALE_Y_960; } else { picSize.width *= RESOURCE_SCALE_960; picSize.height *= RESOURCE_SCALE_960; } if (m_pkAni->m_kAniModifyEx.getFullScreen()) { // apply fullscreen picSize = CCDirector::sharedDirector()->getWinSizeInPixels(); } else { // size override if (m_pkAni->m_kAniModifyEx.sizeOverride()) { picSize = CCSizeMake(m_pkAni->m_kAniModifyEx.getWidth(), m_pkAni->m_kAniModifyEx.getHeight()); } // apply node scale picSize.width *= nodeScaleX; picSize.height *= nodeScaleY; // apply scale picSize.width *= m_pkAni->m_kAniModifyEx.getScale(); picSize.height *= m_pkAni->m_kAniModifyEx.getScale(); // apply mod: scale if (mod_lev2) { picSize.width *= mod_lev2->getScale(); picSize.height *= mod_lev2->getScale(); } if (mod_lev3) { picSize.width *= mod_lev3->getScale(); picSize.height *= mod_lev3->getScale(); } } // apply alpha applyAlpha(pkPicture, mod_lev2); // apply HSL applyHSL(pkPicture, mod_lev2); // target rect to draw in CCRect picRect = CCRectMake(centerPos.x - picSize.width * 0.5f, centerPos.y - picSize.height * 0.5f, picSize.width, picSize.height); // check to disable scissor if (!isAllowScissor()) { NDDirector::DefaultDirector()->DisableScissor(); } // draw if (m_pkInstance && m_pkInstance->getOwnerNode()) { // apply from action: opacity/rotation/gaussianBlur NDNode* pkOwnerNode = m_pkInstance->getOwnerNode(); pkPicture->SetOpacity(pkOwnerNode->getRGBA()->getOpacity()); pkPicture->SetRotation(pkOwnerNode->getCCNode()->getRotation()); pkPicture->SetRotationX(pkOwnerNode->getCCNode()->getRotationX()); pkPicture->SetRotationY(pkOwnerNode->getCCNode()->getRotationY()); pkPicture->setGaussianBlur(pkOwnerNode->getCCNode()->getGaussianBlur()); // toggle reverse bool bReverse = m_pkAni->m_kAniModifyEx.getReverse(); if (pkOwnerNode->isReverse()) bReverse = !bReverse; pkPicture->SetReverse(bReverse); } pkPicture->DrawInRect(picRect); }