/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#pragma once
#include "../libs.h"
#include "../util/flags.h"

#define ALIGN_POS_CENTER flagDefine(0)
#define ALIGN_POS_START flagDefine(1)
#define ALIGN_POS_END flagDefine(2)

#define ALIGN_SIZE_FILL flagDefine(3)
#define ALIGN_SIZE_ORIGINAL flagDefine(4)
#define ALIGN_SIZE_RATIO flagDefine(5)

typedef struct {
  float x, y;
  float width, height;
} align_t;

/**
 * Return the alignment for a specific access, really this doesn't need to be
 * used. Does not support the ALIGN_SIZE_RATIO alignment method.
 * 
 * @param align Alignment flags to get.
 * @param containerSize Size of the container.
 * @param childSize Size of the child.
 * @param childPos Currently unused.
 * @param outSize Pointer to a float for the size output.
 * @param outPos Poitner to a float for the position output.
 */
void alignmentGetAxis(
  uint8_t align,
  float containerSize, float childSize, float childPos,
  float *outSize, float *outPos
);

/**
 * Get the alignment set for a given set of options.
 * 
 * @param alignX Alignment options for the X axis.
 * @param alignY Alignment options for the Y axis.
 * @param containerWidth Width of the container.
 * @param containerHeight Height of the container.
 * @param childWidth Width of the child
 * @param childHeight Height of the child.
 * @param childX Currently unused.
 * @param childY Currently unused. 
 * @return The alignment calculation.
 */
align_t alignmentGet(
  uint8_t alignX, uint8_t alignY,
  float containerWidth, float containerHeight,
  float childWidth, float childHeight,
  float childX, float childY
);