转载

juce viewport使用

1、设置内容组件

void PropertyPanel::init() {     messageWhenEmpty = TRANS("(nothing selected)");       addAndMakeVisible (viewport);     viewport.setViewedComponent (propertyHolderComponent = new PropertyHolderComponent());     viewport.setFocusContainer (true); }

2、设置大小

void PropertyPanel::resized() {     viewport.setBounds (getLocalBounds());     updatePropHolderLayout(); }

3、布局内容。

void PropertyPanel::updatePropHolderLayout() const {  const int maxWidth = viewport.getMaximumVisibleWidth();  propertyHolderComponent->updateLayout (maxWidth);  const int newMaxWidth = viewport.getMaximumVisibleWidth();  if (maxWidth != newMaxWidth)  {   // need to do this twice because of scrollbars changing the size, etc.   propertyHolderComponent->updateLayout (newMaxWidth);  } } 

具体原理还是没如何弄明白,应当是监听了子控件的大小变化。

正文到此结束
Loading...