view libclient/malikania/layout.hpp @ 76:858621081b95

Happy new year!
author David Demelier <markand@malikania.fr>
date Sun, 01 Jan 2017 13:35:37 +0100
parents 4bc4732fa1dd
children
line wrap: on
line source

/*
 * layout.hpp -- generic layout manager inside a frame
 *
 * Copyright (c) 2013-2017 Malikania Authors
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef MALIKANIA_CLIENT_LAYOUT_HPP
#define MALIKANIA_CLIENT_LAYOUT_HPP

/**
 * \brief Generic layout manager inside a frame.
 */

namespace mlk {

class mouse_click_event;
class rectangle;
class size;
class window;

/**
 * \brief Manages the widgets inside a frame.
 *
 * Layouts are responsible of positioning the widgets inside a frame. They
 * handle their positions and dispatch events if applicable.
 *
 * \see grid_layout
 */
class layout {
public:
    /**
     * Virtual destructor defaulted.
     */
    virtual ~layout() noexcept = default;

    /**
     * Handle mouse down.
     *
     * \param ev the mouse event
     */
    virtual void handle_mouse_down(const mouse_click_event& ev) = 0;

    /**
     * Handle mouse up.
     *
     * \param ev the event
     */
    virtual void handle_mouse_up(const mouse_click_event& ev) = 0;

    /**
     * Return the required minimum size to draw the whole layout.
     */
    virtual mlk::size size(window& win) const = 0;

    /**
     * Draw the layout content at the given position.
     *
     * \param win the window
     */
    virtual void draw(window& win, const rectangle& dst) = 0;
};

} // !mlk

#endif // !MALIKANIA_CLIENT_LAYOUT_HPP