added VLayer object.

This commit is contained in:
Martin Preuss
2023-11-19 00:40:42 +01:00
parent 9624dda3f5
commit ff72f5f0ce
3 changed files with 110 additions and 0 deletions

View File

@@ -65,6 +65,7 @@
o_layout.h o_layout.h
o_hlayout.h o_hlayout.h
o_hlayout-t.h o_hlayout-t.h
o_vlayout.h
</headers> </headers>
@@ -79,6 +80,7 @@
o_layout.c o_layout.c
o_hlayout.c o_hlayout.c
o_hlayout-t.c o_hlayout-t.c
o_vlayout.c
</sources> </sources>

View File

@@ -0,0 +1,84 @@
/****************************************************************************
* This file is part of the project AqDiagram.
* AqDiagram (c) by 2023 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "o_vlayout.h"
#include "o_layout.h"
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
static int _layout(AQDG_OBJECT *object);
/* ------------------------------------------------------------------------------------------------
* implementations
* ------------------------------------------------------------------------------------------------
*/
AQDG_OBJECT *AQDG_VLayoutObject_new(AQDG_OBJECT *parent, uint32_t options)
{
AQDG_OBJECT *object;
object=AQDG_Object_new();
AQDG_Object_SetOptions(object, options);
AQDG_Object_SetLayoutFn(object, _layout);
if (parent)
AQDG_Object_Tree2_AddChild(parent, object);
return object;
}
int _layout(AQDG_OBJECT *object)
{
int num;
num=AQDG_LayoutObject_CountDirectChildren(object);
if (num) {
AQDG_PLACEMENT_LAYOUT_ELEMENT *elements;
AQDG_LayoutObject_SetChildrenHeights(object);
elements=AQDG_LayoutObject_Children2ElementsY(object, num);
if (elements) {
AQDG_Placement_LayoutAndStretch(elements, num,
AQDG_Object_GetHeight(object),
AQDG_Object_GetBorderTop(object),
AQDG_Object_GetBorderBottom(object),
AQDG_Object_GetVSpacing(object));
AQDG_LayoutObject_ChildrenFromElementsY(object, elements, num);
free(elements);
}
AQDG_LayoutObject_SetChildrenWidths(object);
elements=AQDG_LayoutObject_Children2ElementsX(object, num);
if (elements) {
AQDG_Placement_LayoutSecondaryAxis(elements, num,
AQDG_Object_GetWidth(object),
AQDG_Object_GetBorderLeft(object),
AQDG_Object_GetBorderRight(object));
AQDG_LayoutObject_ChildrenFromElementsX(object, elements, num);
free(elements);
}
}
return 0;
}

View File

@@ -0,0 +1,24 @@
/****************************************************************************
* This file is part of the project AqDiagram.
* AqDiagram (c) by 2023 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef AQDG_PLACEMENT_O_VLAYOUT_H
#define AQDG_PLACEMENT_O_VLAYOUT_H
#include <aqdiagram/aqdg_api.h>
#include <aqdiagram/placement/object.h>
AQDG_API AQDG_OBJECT *AQDG_VLayoutObject_new(AQDG_OBJECT *parent, uint32_t options);
#endif