Skip to content

Commit

Permalink
Fix splitview issue with nested panels
Browse files Browse the repository at this point in the history
  • Loading branch information
frang75 committed Jan 23, 2023
1 parent af7731d commit dfaf85f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 24 deletions.
2 changes: 1 addition & 1 deletion prj/build.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4158
4162
2 changes: 1 addition & 1 deletion src/gui/gui.inl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Image *_gui_respack_image(const ResId id, ResId *store_id);

const Cursor *_gui_cursor(const gui_cursor_t cursor, const Image *image, const real32_t hot_x, const real32_t hot_y);

#define GUI_COMPONENT_MAX_PANELS 2
#define GUI_COMPONENT_MAX_PANELS 32

__END_C

Expand Down
43 changes: 33 additions & 10 deletions src/gui/splitview.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ static void i_OnDrag(SplitView *split, Event *e)
real32_t dim0 = 0, dim1 = 0, fsize0 = 0, fsize1 = 0;
_component_dimension(split->child2, 0, &dim0, &dim1);
_component_dimension(split->child2, 1, &dim0, &dim1);
_component_expand(split->child2, 0, dim0, r1.size.width, &fsize0);
_component_expand(split->child2, 1, dim1, r1.size.height, &fsize1);
_component_expand(split->child2, 0, dim0, r2.size.width, &fsize0);
_component_expand(split->child2, 1, dim1, r2.size.height, &fsize1);
_component_locate(split->child2);
}
}
Expand Down Expand Up @@ -466,22 +466,45 @@ void _splitview_OnResize(SplitView *split, const S2Df *size)

/*---------------------------------------------------------------------------*/

void _splitview_panels(const SplitView *split, uint32_t *num_panels, Panel **panels)
static void i_accum_panels(const SplitView* split, uint32_t* num_panels, Panel** panels)
{
cassert_no_null(split);
cassert_no_null(num_panels);
cassert_no_null(panels);
*num_panels = 0;

if (split->child1 != NULL && split->child1->type == ekGUI_TYPE_PANEL)
if (split->child1 != NULL)
{
panels[*num_panels] = (Panel*)split->child1;
*num_panels += 1;
if (split->child1->type == ekGUI_TYPE_PANEL)
{
panels[*num_panels] = (Panel*)split->child1;
*num_panels += 1;
cassert(*num_panels < GUI_COMPONENT_MAX_PANELS);
}
else if(split->child1->type == ekGUI_TYPE_SPLITVIEW)
{
i_accum_panels((SplitView*)split->child1, num_panels, panels);
}
}

if (split->child2 != NULL && split->child2->type == ekGUI_TYPE_PANEL)
if (split->child2 != NULL)
{
panels[*num_panels] = (Panel*)split->child2;
*num_panels += 1;
if (split->child2->type == ekGUI_TYPE_PANEL)
{
panels[*num_panels] = (Panel*)split->child2;
*num_panels += 1;
cassert(*num_panels < GUI_COMPONENT_MAX_PANELS);
}
else if(split->child2->type == ekGUI_TYPE_SPLITVIEW)
{
i_accum_panels((SplitView*)split->child2, num_panels, panels);
}
}
}

/*---------------------------------------------------------------------------*/

void _splitview_panels(const SplitView *split, uint32_t *num_panels, Panel **panels)
{
*num_panels = 0;
i_accum_panels(split, num_panels, panels);
}
30 changes: 18 additions & 12 deletions src/osgui/gtk3/ossplit.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ static void i_set_capture(GtkWidget *widget, OSSplit *split)
else
{
OSControl *control = (OSControl*)g_object_get_data(G_OBJECT(widget), "OSControl");
if (control->type == ekGUI_TYPE_PANEL)
_ospanel_set_capture((OSPanel*)control, (OSControl*)split);
else if (control->type == ekGUI_TYPE_TEXTVIEW)
_ostext_set_capture((OSText*)control, (OSControl*)split);
else if (control->type == ekGUI_TYPE_CUSTOMVIEW)
_osview_set_capture((OSView*)control, (OSControl*)split);
if (control != NULL)
{
if (control->type == ekGUI_TYPE_PANEL)
_ospanel_set_capture((OSPanel*)control, (OSControl*)split);
else if (control->type == ekGUI_TYPE_TEXTVIEW)
_ostext_set_capture((OSText*)control, (OSControl*)split);
else if (control->type == ekGUI_TYPE_CUSTOMVIEW)
_osview_set_capture((OSView*)control, (OSControl*)split);
}
}
}

Expand All @@ -69,12 +72,15 @@ static void i_release_capture(GtkWidget *widget, gpointer data)
else
{
OSControl *control = (OSControl*)g_object_get_data(G_OBJECT(widget), "OSControl");
if (control->type == ekGUI_TYPE_PANEL)
_ospanel_release_capture((OSPanel*)control);
else if (control->type == ekGUI_TYPE_TEXTVIEW)
_ostext_release_capture((OSText*)control);
else if (control->type == ekGUI_TYPE_CUSTOMVIEW)
_osview_release_capture((OSView*)control);
if (control != NULL)
{
if (control->type == ekGUI_TYPE_PANEL)
_ospanel_release_capture((OSPanel*)control);
else if (control->type == ekGUI_TYPE_TEXTVIEW)
_ostext_release_capture((OSText*)control);
else if (control->type == ekGUI_TYPE_CUSTOMVIEW)
_osview_release_capture((OSView*)control);
}
}
}

Expand Down

0 comments on commit dfaf85f

Please sign in to comment.