<commit_before>#ifndef GUI_FRAME_H
#define GUI_FRAME_H

#include "panel.h"
#include "layoutmanager.h"
#include "graphic.h"

#include <mw/window.h>
#include <mw/color.h>
#include <mw/signal.h>

#include <SDL.h>

#include <string>
#include <queue>

namespace gui {

	class Frame;
	using WindowListener = mw::Signal<Frame&, const SDL_Event&>;
	using SdlEventListener = mw::Signal<Frame&, const SDL_Event&>;
	using DrawListener = mw::Signal<Frame&, double>;

	class Frame : public mw::Window {
	public:
		Frame();

		// Add the default panel in the back of the internal vector.
		// The panel index is returned.
		int addPanelBack();

		// Add the provided panel in the back of the internal vector.
		// The panel index is returned.
		int pushBackPanel(const std::shared_ptr<Panel>& panel);

        // Add the component, with the provided layoutIndex.
		// Will assert if the component already added.
		template <class Comp, class... Args>
		std::shared_ptr<Comp> addDefault(Args... args) {
			auto c = std::make_shared<Comp>(args...);
			add(DEFAULT_INDEX, c);
			return c;
		}

		// Add the component, with the default index layout.
		// Will assert if the component already added.
		std::shared_ptr<Component> addDefault(const std::shared_ptr<Component>& component);

		// Add the component, with the provided layoutIndex.
		// Will assert if the component already added.
		template <class Comp, class... Args>
		std::shared_ptr<Comp> add(int layoutIndex, Args... args) {
			auto c = std::make_shared<Comp>(args...);
			add(layoutIndex, c);
			return c;
		}

		// Add the component, with the default index layout.
		// Will assert if the component already added.
		std::shared_ptr<Component> add(int layoutIndex, const std::shared_ptr<Component>& component);

		// Same as add(int layoutIndex, Component* component) but added to
		// a traversal group too.
		template <class Comp, class... Args>
		std::shared_ptr<Comp> addDefaultToGroup(Args... args) {
			auto c = std::make_shared<Comp>(args...);
			addToGroup(DEFAULT_INDEX, c);
			return c;
		}

		// Same as add(int layoutIndex, Component* component) but added to
		// a traversal group too.
		std::shared_ptr<Component> addDefaultToGroup(const std::shared_ptr<Component>& component);

		// Same as add(int layoutIndex, Component* component) but added to
		// a traversal group too.
		template <class Comp, class... Args>
		std::shared_ptr<Comp> addToGroup(int layoutIndex, Args... args) {
			auto c = std::make_shared<Comp>(args...);
			addToGroup(layoutIndex, c);
			return c;
		}

		// Same as add(int layoutIndex, Component* component) but added to
		// a traversal group too.
		std::shared_ptr<Component> addToGroup(int layoutIndex, const std::shared_ptr<Component>& component);

		// Set the layout manager.
		std::shared_ptr<LayoutManager> setLayout(const std::shared_ptr<LayoutManager>& layoutManager);

		template <class LManager, class... Args>
		std::shared_ptr<LManager> setLayout(Args... args) {
			auto m = std::make_shared<LManager>(args...);
			setLayout(m);
			return m;
		}

		// Get the current layout manager.
		std::shared_ptr<LayoutManager> getLayout() const;

		std::vector<std::shared_ptr<Panel>>::iterator begin();
		std::vector<std::shared_ptr<Panel>>::iterator end();

		// Add a window listener. A callback be be made when a SDL_WINDOWEVENT is called
		// for this window.
		mw::signals::Connection addWindowListener(const WindowListener::Callback& callback);

		// Add a SDL event listener. A callback be be made when any SDL event is called
		// for any window.
		mw::signals::Connection addSdlEventListener(const SdlEventListener::Callback& callback);

		// Set the default closing true or false.
		// Makes the window's close by clicking the quit button or by
		// pressing the ESQ key if set to true. if set to false
		// nothing happens.
		void setDefaultClosing(bool defaultClosing);

		// Returns if the default closing is active or not.
		bool isDefaultClosing() const;

		inline int getPanelsCount() const {
			return panels_.size();
		}

		inline int getCurrentPanelIndex() const {
			return currentPanel_;
		}

		void setCurrentPanel(int index);

		inline std::shared_ptr<Panel> getCurrentPanel() const {
			return panels_[currentPanel_];
		}

		// Add a key listener to the current panel.
		inline mw::signals::Connection addKeyListener(const KeyListener::Callback& callback) {
			return getCurrentPanel()->addKeyListener(callback);
		}

		// Add a mouse listener to the current panel.
		inline mw::signals::Connection addMouseListener(const MouseListener::Callback& callback) {
			return getCurrentPanel()->addMouseListener(callback);
		}

		// Add a focus listener to the current panel.
		inline mw::signals::Connection addFocusListener(const FocusListener::Callback& callback) {
			return getCurrentPanel()->addFocusListener(callback);
		}

		// Add a action listener to the current panel.
		inline mw::signals::Connection addActionListener(const ActionListener::Callback& callback) {
			return getCurrentPanel()->addActionListener(callback);
		}

		// Add a panel change listener to the current panel.
		inline mw::signals::Connection addPanelChangeListener(const PanelChangeListener::Callback& callback) {
			return getCurrentPanel()->addPanelChangeListener(callback);
		}

		// Add a update listener to the current panel.
		inline mw::signals::Connection addDrawListener(const DrawListener::Callback& callback) {
			return getCurrentPanel()->addDrawListener(callback);
		}

	private:
		virtual void initPreLoop() override;
<commit_msg>protected function in Frame.<commit_after>#ifndef GUI_FRAME_H
#define GUI_FRAME_H

#include "panel.h"
#include "layoutmanager.h"
#include "graphic.h"

#include <mw/window.h>
#include <mw/color.h>
#include <mw/signal.h>

#include <SDL.h>

#include <string>
#include <queue>

namespace gui {

	class Frame;
	using WindowListener = mw::Signal<Frame&, const SDL_Event&>;
	using SdlEventListener = mw::Signal<Frame&, const SDL_Event&>;
	using DrawListener = mw::Signal<Frame&, double>;

	class Frame : public mw::Window {
	public:
		Frame();

		// Add the default panel in the back of the internal vector.
		// The panel index is returned.
		int addPanelBack();

		// Add the provided panel in the back of the internal vector.
		// The panel index is returned.
		int pushBackPanel(const std::shared_ptr<Panel>& panel);

        // Add the component, with the provided layoutIndex.
		// Will assert if the component already added.
		template <class Comp, class... Args>
		std::shared_ptr<Comp> addDefault(Args... args) {
			auto c = std::make_shared<Comp>(args...);
			add(DEFAULT_INDEX, c);
			return c;
		}

		// Add the component, with the default index layout.
		// Will assert if the component already added.
		std::shared_ptr<Component> addDefault(const std::shared_ptr<Component>& component);

		// Add the component, with the provided layoutIndex.
		// Will assert if the component already added.
		template <class Comp, class... Args>
		std::shared_ptr<Comp> add(int layoutIndex, Args... args) {
			auto c = std::make_shared<Comp>(args...);
			add(layoutIndex, c);
			return c;
		}

		// Add the component, with the default index layout.
		// Will assert if the component already added.
		std::shared_ptr<Component> add(int layoutIndex, const std::shared_ptr<Component>& component);

		// Same as add(int layoutIndex, Component* component) but added to
		// a traversal group too.
		template <class Comp, class... Args>
		std::shared_ptr<Comp> addDefaultToGroup(Args... args) {
			auto c = std::make_shared<Comp>(args...);
			addToGroup(DEFAULT_INDEX, c);
			return c;
		}

		// Same as add(int layoutIndex, Component* component) but added to
		// a traversal group too.
		std::shared_ptr<Component> addDefaultToGroup(const std::shared_ptr<Component>& component);

		// Same as add(int layoutIndex, Component* component) but added to
		// a traversal group too.
		template <class Comp, class... Args>
		std::shared_ptr<Comp> addToGroup(int layoutIndex, Args... args) {
			auto c = std::make_shared<Comp>(args...);
			addToGroup(layoutIndex, c);
			return c;
		}

		// Same as add(int layoutIndex, Component* component) but added to
		// a traversal group too.
		std::shared_ptr<Component> addToGroup(int layoutIndex, const std::shared_ptr<Component>& component);

		// Set the layout manager.
		std::shared_ptr<LayoutManager> setLayout(const std::shared_ptr<LayoutManager>& layoutManager);

		template <class LManager, class... Args>
		std::shared_ptr<LManager> setLayout(Args... args) {
			auto m = std::make_shared<LManager>(args...);
			setLayout(m);
			return m;
		}

		// Get the current layout manager.
		std::shared_ptr<LayoutManager> getLayout() const;

		std::vector<std::shared_ptr<Panel>>::iterator begin();
		std::vector<std::shared_ptr<Panel>>::iterator end();

		// Add a window listener. A callback be be made when a SDL_WINDOWEVENT is called
		// for this window.
		mw::signals::Connection addWindowListener(const WindowListener::Callback& callback);

		// Add a SDL event listener. A callback be be made when any SDL event is called
		// for any window.
		mw::signals::Connection addSdlEventListener(const SdlEventListener::Callback& callback);

		// Set the default closing true or false.
		// Makes the window's close by clicking the quit button or by
		// pressing the ESQ key if set to true. if set to false
		// nothing happens.
		void setDefaultClosing(bool defaultClosing);

		// Returns if the default closing is active or not.
		bool isDefaultClosing() const;

		inline int getPanelsCount() const {
			return panels_.size();
		}

		inline int getCurrentPanelIndex() const {
			return currentPanel_;
		}

		void setCurrentPanel(int index);

		inline std::shared_ptr<Panel> getCurrentPanel() const {
			return panels_[currentPanel_];
		}

		// Add a key listener to the current panel.
		inline mw::signals::Connection addKeyListener(const KeyListener::Callback& callback) {
			return getCurrentPanel()->addKeyListener(callback);
		}

		// Add a mouse listener to the current panel.
		inline mw::signals::Connection addMouseListener(const MouseListener::Callback& callback) {
			return getCurrentPanel()->addMouseListener(callback);
		}

		// Add a focus listener to the current panel.
		inline mw::signals::Connection addFocusListener(const FocusListener::Callback& callback) {
			return getCurrentPanel()->addFocusListener(callback);
		}

		// Add a action listener to the current panel.
		inline mw::signals::Connection addActionListener(const ActionListener::Callback& callback) {
			return getCurrentPanel()->addActionListener(callback);
		}

		// Add a panel change listener to the current panel.
		inline mw::signals::Connection addPanelChangeListener(const PanelChangeListener::Callback& callback) {
			return getCurrentPanel()->addPanelChangeListener(callback);
		}

		// Add a update listener to the current panel.
		inline mw::signals::Connection addDrawListener(const DrawListener::Callback& callback) {
			return getCurrentPanel()->addDrawListener(callback);
		}
	protected:
		virtual void initPreLoop() override;

	private:
{'fraction_non_alphanumeric': 0.11585585585585585, 'fraction_numerical': 0.0, 'mean_word_length': 4.226459510357816, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2045392', 'n_tokens_mistral': 3537, 'n_tokens_neox': 3188, 'n_words': 1044}