void BackdropNodeGadget::doRender( const Style *style ) const { // this is our bound in gadget space Box2f bound = boundPlug()->getValue(); // but because we're going to draw our contents at an arbitrary scale, // we need to compute a modified bound which will be in the right place // following scaling. const Backdrop *backdrop = static_cast<const Backdrop *>( node() ); const float scale = backdrop->scalePlug()->getValue(); bound.min /= scale; bound.max /= scale; glPushMatrix(); glScalef( scale, scale, scale ); const Box3f titleCharacterBound = style->characterBound( Style::HeadingText ); const float titleBaseline = bound.max.y - g_margin - titleCharacterBound.max.y; if( IECoreGL::Selector::currentSelector() ) { // when selecting we render in a simplified form. // we only draw a thin strip around the edge of the backdrop // to allow the edges to be grabbed for dragging, and a strip // at the top to allow the title header to be grabbed for moving // around. leaving the main body of the backdrop as a hole is // necessary to allow the GraphGadget to continue to perform // drag selection on the nodes on top of the backdrop. const float width = hoverWidth() / scale; style->renderSolidRectangle( Box2f( bound.min, V2f( bound.min.x + width, bound.max.y ) ) ); // left style->renderSolidRectangle( Box2f( V2f( bound.max.x - width, bound.min.y ), bound.max ) ); // right style->renderSolidRectangle( Box2f( bound.min, V2f( bound.max.x, bound.min.y + width ) ) ); // bottom style->renderSolidRectangle( Box2f( V2f( bound.min.x, bound.max.y - width ), bound.max ) ); // top style->renderSolidRectangle( Box2f( V2f( bound.min.x, titleBaseline - g_margin ), bound.max ) ); // heading } else { // normal drawing mode style->renderBackdrop( bound, getHighlighted() ? Style::HighlightedState : Style::NormalState ); const std::string title = backdrop->titlePlug()->getValue(); if( title.size() ) { Box3f titleBound = style->textBound( Style::HeadingText, title ); glPushMatrix(); glTranslatef( bound.center().x - titleBound.size().x / 2.0f, titleBaseline, 0.0f ); style->renderText( Style::HeadingText, title ); glPopMatrix(); } if( m_hovered ) { style->renderHorizontalRule( V2f( bound.center().x, titleBaseline - g_margin / 2.0f ), bound.size().x - g_margin * 2.0f, Style::HighlightedState ); } Box2f textBound = bound; textBound.min += V2f( g_margin ); textBound.max = V2f( textBound.max.x - g_margin, titleBaseline - g_margin ); if( textBound.hasVolume() ) { std::string description = backdrop->descriptionPlug()->getValue(); style->renderWrappedText( Style::BodyText, description, textBound ); } } glPopMatrix(); }