MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / calcItemWidth

Method calcItemWidth

source/MRViewer/MRRibbonButtonDrawer.cpp:211–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211RibbonButtonDrawer::ButtonItemWidth RibbonButtonDrawer::calcItemWidth( const MenuItemInfo& item, DrawButtonParams::SizeType sizeType ) const
212{
213 ButtonItemWidth res;
214 if ( sizeType == DrawButtonParams::SizeType::Big )
215 {
216 const float cMinItemSize = cRibbonItemMinWidth * UI::scale();
217
218 float maxTextWidth = 0.f;
219 for ( const auto& i : item.captionSize.splitInfo )
220 maxTextWidth = std::max( maxTextWidth, i.second );
221
222 res.baseWidth = maxTextWidth + 2 * cRibbonButtonWindowPaddingX * UI::scale();
223
224 if ( item.item->type() == RibbonItemType::ButtonWithDrop )
225 {
226 auto additionalSize = 3 * cSmallIconSize * UI::scale();
227 if ( cMinItemSize - res.baseWidth < additionalSize )
228 res.baseWidth += additionalSize;
229 }
230
231 if ( res.baseWidth < cMinItemSize )
232 res.baseWidth = cMinItemSize;
233 return res;
234 }
235 else if ( sizeType == DrawButtonParams::SizeType::SmallText )
236 {
237 res.baseWidth = ( cSmallIconSize +
238 2.0f * cRibbonButtonWindowPaddingX +
239 2.0f * cRibbonItemInterval ) * UI::scale() +
240 item.captionSize.baseSize;
241
242 if ( item.item->type() == RibbonItemType::ButtonWithDrop )
243 res.additionalWidth = cSmallItemDropSizeModifier * ( cSmallIconSize + 2.0f * cRibbonButtonWindowPaddingX ) * UI::scale();
244 }
245 else
246 {
247 res.baseWidth = ( cSmallIconSize + 2.0f * cRibbonButtonWindowPaddingX ) * UI::scale();
248
249 if ( item.item->type() == RibbonItemType::ButtonWithDrop )
250 res.additionalWidth = cSmallItemDropSizeModifier * res.baseWidth;
251 }
252 return res;
253}
254
255void RibbonButtonDrawer::drawButtonItem( const MenuItemInfo& item, const DrawButtonParams& params ) const
256{

Callers 4

drawWindow_Method · 0.80
drawBigButtonItem_Method · 0.80
drawSmallButtonsSet_Method · 0.80

Calls 2

maxFunction · 0.85
scaleFunction · 0.70

Tested by

no test coverage detected