Incredibly Simple Flexbox example needed[Simpler than current demo]


#1

for the life of me can’t get the demo to work in my ide(VisualStudio15).Says i am missing jucedemoheader.h…i looked in modules and it is not there…how do i go about fixing this or getting a little bit more simpler[bare minimum parts] working flexbox demo i can break down


#2

It’s in here: https://github.com/julianstorer/JUCE/tree/master/examples/Demo/Source

All the projects use relative paths so should just build out-of-the-box unless you’ve moved files around or something. Try re-cloning the whole repo?


#3

hi
here is a simple flexbox scenario, hope it will get you started

class Item : public Component {
    	public:
    	
    		Item(Colour &c) {
    			colour = c;
    		}
    	
    		void paint(Graphics& g) override {
    			g.fillAll(colour);
    		}
    	
    		void mouseDown(const MouseEvent&) override {
    			DBG(colour.toString());
    		}
    	
    		Colour colour;
    };

	class MainContentComponent : public Component {
	public:
	
		MainContentComponent() {
			for(int = 0; i < 11; i++)
		    	addFlexItem(Colour::fromHSV(Random::getSystemRandom().nextFloat(), 0.5f, 0.7f, 1.0f));
	
		    flexBox.alignContent = FlexBox::AlignContent::flexStart;
		    flexBox.flexDirection = FlexBox::Direction::row;
		    flexBox.justifyContent = FlexBox::JustifyContent::flexStart;
		    flexBox.alignItems = FlexBox::AlignItems::flexStart;
		    flexBox.flexWrap = FlexBox::Wrap::wrap;
	
		    setSize(600, 400);
		}
	
		~MainContentComponent() {}
	
		void paint(Graphics& g) override {
			g.fillAll(Colours::black);
	
		}
	
		void resized() override {
			flexBox.performLayout(getLocalBounds());
		}
	
		void addFlexItem(Colour colour) {
			flexBox.items.add(FlexItem(100, 100).withMargin(10));
	
		    auto &flexItem = flexBox.items.getReference(flexBox.items.size() - 1);
	
		    auto *item = new Item(colour);
		    items.add(item);
		    flexItem.associatedComponent = item;
		    addAndMakeVisible(item);
		}
	
	private:
	
		FlexBox flexBox;
		OwnedArray<Item> items;
	
		JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainContentComponent)
};

#4

i will try this today or over the weekend…thank you,much appreciated


#5

so when i want to view a demo in ide (VisualStudio15) im assuming i need to include all these in my project while using specific demo file
DemoUtilities.h(in my case i would load in the FlexBoxDemo.cpp?)
IntroScreen.cpp
JuceDemoHeader.h
Main.cpp
MainWindow.cpp
Mainwindow.h

thank you for helping


#6

Huh? No… to run the demo, just open the demo’s VS project and hit “run”. We don’t expect you to build your own projects just to run bits of it…