ScrollView.cpp (1178B)
1 #include "ScrollView.h" 2 3 ScrollView::ScrollView (foleys::MagicGUIBuilder& builder, ValueTree node) 4 : foleys::GuiItem (builder, node), 5 baseView (builder, node) 6 { 7 addAndMakeVisible (viewport); 8 addAndMakeVisible (baseView); 9 viewport.setViewedComponent (&baseView, false); 10 11 viewport.setScrollBarsShown (true, false); 12 viewport.getVerticalScrollBar().setColour (ScrollBar::thumbColourId, Colour (0xFFEAA92C).withAlpha (0.7f)); 13 viewport.setScrollBarThickness (10); 14 viewport.setScrollOnDragMode (Viewport::ScrollOnDragMode::never); 15 16 dragToScrollListener = std::make_unique<DragToScrollListener> (viewport); 17 } 18 19 void ScrollView::resized() 20 { 21 viewport.setBounds (getLocalBounds()); 22 baseView.setSize (getWidth() - viewport.getScrollBarThickness(), jmax (465, getHeight())); 23 } 24 25 void ScrollView::update() 26 { 27 baseView.getConfigNode() = configNode.createCopy(); 28 baseView.update(); 29 } 30 31 void ScrollView::createSubComponents() 32 { 33 baseView.getConfigNode() = configNode.createCopy(); 34 baseView.createSubComponents(); 35 } 36 37 foleys::GuiItem* ScrollView::findGuiItemWithId (const String& name) 38 { 39 return baseView.findGuiItemWithId (name); 40 }