GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_system_view_fold.c Lines: 21 21 100.0 %
Date: 2024-12-05 08:52:37 Branches: 18 18 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   System Management (System)                                          */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_system.h"
28
#include "gx_utility.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_system_view_fold                                PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function combines adjcent views.                               */
44
/*                                                                        */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    win                                   Window to add view to         */
49
/*    view                                  Rectangle defining new view   */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    GX_TRUE | GX_FALSE                                                  */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    _gx_system_view_add                   Link a view to window's view  */
62
/*                                            list                        */
63
/*                                                                        */
64
/*  RELEASE HISTORY                                                       */
65
/*                                                                        */
66
/*    DATE              NAME                      DESCRIPTION             */
67
/*                                                                        */
68
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70
/*                                            resulting in version 6.1    */
71
/*                                                                        */
72
/**************************************************************************/
73
7147
GX_BOOL _gx_system_view_fold(GX_WINDOW *win, GX_RECTANGLE *view)
74
{
75
7147
GX_VIEW *oldview = win -> gx_window_views;
76
77
16087
    while (oldview)
78
    {
79
        /* check for two views stacked vertically:*/
80
81
9017
        if ((oldview -> gx_view_rectangle.gx_rectangle_left == view -> gx_rectangle_left) &&
82
4168
            (oldview -> gx_view_rectangle.gx_rectangle_right == view -> gx_rectangle_right))
83
        {
84
1452
            if (oldview -> gx_view_rectangle.gx_rectangle_bottom == (view -> gx_rectangle_top - 1))
85
            {
86
                /* New view is right below existing view, expand bottom of
87
                   existing: */
88
6
                oldview -> gx_view_rectangle.gx_rectangle_bottom = view -> gx_rectangle_bottom;
89
6
                return GX_TRUE;
90
            }
91
92
1446
            if (oldview -> gx_view_rectangle.gx_rectangle_top == (view -> gx_rectangle_bottom + 1))
93
            {
94
                /* new view is right above existing view, just expand existing
95
                   view top: */
96
69
                oldview -> gx_view_rectangle.gx_rectangle_top = view -> gx_rectangle_top;
97
69
                return GX_TRUE;
98
            }
99
        }
100
        else
101
        {
102
            /* check for views right beside each other horizontally: */
103
7565
            if (oldview -> gx_view_rectangle.gx_rectangle_top == view -> gx_rectangle_top &&
104
1306
                oldview -> gx_view_rectangle.gx_rectangle_bottom == view -> gx_rectangle_bottom)
105
            {
106
1303
                if (oldview -> gx_view_rectangle.gx_rectangle_right == (view -> gx_rectangle_left - 1))
107
                {
108
                    /* new view is to the right of existing view, expand right side of
109
                       existing:*/
110
1
                    oldview -> gx_view_rectangle.gx_rectangle_right = view -> gx_rectangle_right;
111
1
                    return GX_TRUE;
112
                }
113
114
1302
                if (oldview -> gx_view_rectangle.gx_rectangle_left == (view -> gx_rectangle_right + 1))
115
                {
116
                    /* new view is to the left of existing view, expand left side of
117
                       existing view: */
118
1
                    oldview -> gx_view_rectangle.gx_rectangle_left = view -> gx_rectangle_left;
119
1
                    return GX_TRUE;
120
                }
121
            }
122
        }
123
8940
        oldview = oldview -> gx_view_next;
124
    }
125
7070
    return GX_FALSE;
126
}
127