MCPcopy Create free account
hub / github.com/9miao/CrossApp / updateCapInset

Method updateCapInset

CrossApp/view/CAScale9ImageView.cpp:292–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292void CAScale9ImageView::updateCapInset()
293{
294 float w = m_obOriginalSize.width;
295 float h = m_obOriginalSize.height;
296
297 if ( m_obCapInsets.equals(DRectZero) )
298 {
299 m_obCapInsets = DRect(w/3, h/3, w/3, h/3);
300 }
301
302 const float lenghtX1 = m_obCapInsets.origin.x;
303 const float lenghtX2 = m_obCapInsets.size.width;
304 const float lenghtX3 = w - lenghtX1 - lenghtX2;
305 const float lenghtY1 = m_obCapInsets.origin.y;
306 const float lenghtY2 = m_obCapInsets.size.height;
307 const float lenghtY3 = h - lenghtY1 - lenghtY2;
308
309 m_rFrame[0] = DRect(0, 0, lenghtX1, lenghtY1);
310 m_rFrame[1] = DRect(lenghtX1, 0, lenghtX2, lenghtY1);
311 m_rFrame[2] = DRect(lenghtX1 + lenghtX2, 0, lenghtX3, lenghtY1);
312 m_rFrame[3] = DRect(0, lenghtY1, lenghtX1, lenghtY2);
313 m_rFrame[4] = DRect(lenghtX1, lenghtY1, lenghtX2, lenghtY2);
314 m_rFrame[5] = DRect(lenghtX1 + lenghtX2, lenghtY1, lenghtX3, lenghtY2);
315 m_rFrame[6] = DRect(0, lenghtY1 + lenghtY2, lenghtX1, lenghtY3);
316 m_rFrame[7] = DRect(lenghtX1, lenghtY1 + lenghtY2, lenghtX2, lenghtY3);
317 m_rFrame[8] = DRect(lenghtX1 + lenghtX2, lenghtY1 + lenghtY2, lenghtX3, lenghtY3);
318
319 CC_RETURN_IF(m_pobImage == NULL);
320
321 if (m_pScale9ImageView)
322 {
323 for (int i=0; i<9; i++)
324 {
325 m_pImageView[i]->setImageRect(m_rFrame[i]);
326 }
327 this->updatePositions();
328 }
329}
330
331void CAScale9ImageView::updateDisplayedColor(const CrossApp::CAColor4B &color)
332{

Callers 7

updateWithImageMethod · 0.95
setContentSizeMethod · 0.95
setCapInsetsMethod · 0.95
setInsetLeftMethod · 0.95
setInsetTopMethod · 0.95
setInsetRightMethod · 0.95
setInsetBottomMethod · 0.95

Calls 3

updatePositionsMethod · 0.95
equalsMethod · 0.45
setImageRectMethod · 0.45

Tested by

no test coverage detected