/*
 * This source file is part of RmlUi, the HTML/CSS Interface Middleware
 *
 * For the latest information, see http://github.com/mikke89/RmlUi
 *
 * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
 * Copyright (c) 2019-2024 The RmlUi Team, and contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */

#ifndef RMLUI_CORE_RENDERBOX_H
#define RMLUI_CORE_RENDERBOX_H

#include "Types.h"

namespace Rml {

// Ordered by top, right, bottom, left.
using EdgeSizes = Array<float, 4>;
// Ordered by top-left, top-right, bottom-right, bottom-left.
using CornerSizes = Array<float, 4>;

/**
    Provides the data needed to generate a mesh for a given element's box.
 */

class RenderBox {
public:
	RenderBox(Vector2f fill_size, Vector2f border_offset, EdgeSizes border_widths, CornerSizes border_radius) :
		fill_size(fill_size), border_offset(border_offset), border_widths(border_widths), border_radius(border_radius)
	{}

	/// Returns the size of the fill area of the box.
	Vector2f GetFillSize() const { return fill_size; }
	/// Sets the size of the fill area of the box.
	void SetFillSize(Vector2f value) { fill_size = value; }
	/// Returns the offset from the border area to the fill area of the box.
	Vector2f GetFillOffset() const { return {border_widths[3], border_widths[0]}; }

	/// Returns the offset to the border area of the box.
	Vector2f GetBorderOffset() const { return border_offset; }
	/// Sets the border offset.
	void SetBorderOffset(Vector2f value) { border_offset = value; }

	/// Returns the border widths of the box.
	EdgeSizes GetBorderWidths() const { return border_widths; }
	/// Sets the border widths of the box.
	void SetBorderWidths(EdgeSizes value) { border_widths = value; }

	/// Returns the border radius of the box.
	CornerSizes GetBorderRadius() const { return border_radius; }
	/// Sets the border radius of the box.
	void SetBorderRadius(CornerSizes value) { border_radius = value; }

private:
	Vector2f fill_size;
	Vector2f border_offset;
	EdgeSizes border_widths;
	CornerSizes border_radius;
};

} // namespace Rml
#endif
