From 031357d2fb6883268e883db4d0c6c3dc9a32f509 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Fri, 26 Dec 2025 11:21:32 +0100 Subject: [PATCH] hide labels which don't fit inside the axis widget. --- src/lib/aqdiagram/graph/w_axis.c | 43 +++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/lib/aqdiagram/graph/w_axis.c b/src/lib/aqdiagram/graph/w_axis.c index 2edb841..fbf5204 100644 --- a/src/lib/aqdiagram/graph/w_axis.c +++ b/src/lib/aqdiagram/graph/w_axis.c @@ -36,7 +36,10 @@ static GWENHYWFAR_CB void _freeData(void *bp, void *p); static void _setupObjectTree(AQDG_OBJECT *o); static void _createTickLabelsForLevel(AQDG_OBJECT *o, AQDG_GRAPH *graph, const AQDG_GRAPH_TICK_LIST *tickList, int level); +static int _doesCollideWithOtherChildren(const AQDG_OBJECT *object, const AQDG_OBJECT *newObject); +static int _fitsIntoAxisWidget(const AQDG_OBJECT *o, AQDG_OBJECT *child); static int _hasLabelCollisions(const AQDG_OBJECT *o); +static void _hideNonFittingLabels(const AQDG_OBJECT *o); static int _hideEverySecondLabel(AQDG_OBJECT *o); @@ -196,6 +199,8 @@ void AQDG_AxisWidget_HideCollidingChildren(AQDG_OBJECT *o) { int doRun=1; + _hideNonFittingLabels(o); + while(doRun) { if (_hasLabelCollisions(o)) doRun=(_hideEverySecondLabel(o)<0)?0:1; @@ -334,11 +339,31 @@ int _doesCollideWithOtherChildren(const AQDG_OBJECT *object, const AQDG_OBJECT * +int _fitsIntoAxisWidget(const AQDG_OBJECT *o, AQDG_OBJECT *child) +{ + int xLeft; + int xRight; + int yTop; + int yBottom; + int parentWidth; + int parentHeight; + + parentWidth=AQDG_Object_GetWidth(o); + parentHeight=AQDG_Object_GetHeight(o); + xLeft=AQDG_Object_GetRelativeX(child); + xRight=xLeft+AQDG_Object_GetWidth(child); + yTop=AQDG_Object_GetRelativeY(child); + yBottom=yTop+AQDG_Object_GetHeight(child); + + return ((xLeft>=0) && (xRight=0) && (yBottom