Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "MainComponent.h"
- void Box1::paint(Graphics& g)
- {
- std::cout << g.getClipBounds().toString() << "\n";
- g.setColour(Colour(150, 150, 150));
- g.fillRect(g.getClipBounds());
- g.setColour(Colour(200, 200, 200));
- g.drawRect(g.getClipBounds(), 1);
- g.drawText("I'm a wide box", getLocalBounds(), Justification::centred, true);
- }
- void Box2::paint(Graphics& g)
- {
- g.setColour(Colour(20, 20, 20));
- g.fillRect(g.getClipBounds());
- }
- MainComponent::MainComponent()
- {
- viewport.setViewedComponent(&box1);
- addAndMakeVisible(viewport);
- addAndMakeVisible(box2);
- setSize(600, 400);
- }
- void MainComponent::mouseDrag(const MouseEvent& m)
- {
- box2.setTopLeftPosition(m.x, m.y);
- };
- void MainComponent::paint(Graphics& g)
- {
- g.fillAll(getLookAndFeel().findColour(ResizableWindow::backgroundColourId));
- }
- void MainComponent::resized()
- {
- box1.setBounds(0, 0, 1000, 100);
- box2.setBounds(200, 200, 100, 100);
- viewport.setBounds(0, 0, getWidth(), getHeight());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement