A method and system for realizing horizontal equidistant movement of interface controls across levels

By converting the relative coordinates of the interface control into world coordinates and calculating the control spacing value, the interface controls are arranged horizontally across levels, solving the problem that different levels of controls in the existing technology is difficult to arrange equally, and improving the accuracy of arrangement Sex and efficiency.

CN114968218BActive Publication Date: 2025-02-07FUJIAN TQ ONLINE INTERACTIVE INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210404703.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-18
Publication Date
2025-02-07
Estimated Expiration
2042-04-18

AI Technical Summary

Technical Problem

The prior art is difficult to realize horizontal and equidistant arrangement of interface controls at different levels, and requires manual calculation of locations, which is cumbersome and inconvenient.

Method used

By converting the relative coordinates of the interface control into world coordinates, sorting them according to the world coordinate positions, calculating the control spacing value, determining the position of the next control in turn, and moving the control to the new coordinate position, achieving horizontal and equidistant movement across levels.

Benefits of technology

The interface controls are arranged horizontally across levels, improving the accuracy and efficiency of arrangement. Both controls at the same level and at different levels can achieve isometric functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114968218B_ABST
    Figure CN114968218B_ABST
Patent Text Reader

Abstract

The present invention provides a method for realizing horizontal equidistant movement of interface controls across levels, the method comprising: step S1, selecting multiple controls that need to be processed horizontally equidistantly on the interface; step S2, converting all relative coordinates of the selected controls in the scene into world coordinates, and sorting the multiple controls according to the world coordinate positions; step S3, selecting the first two controls after sorting, and obtaining the spacing value of the two controls; step S4, traversing all selected controls, and determining the position of the next control of the two controls in turn; step S5, according to the new coordinate position of the next control obtained, moving the interface control to the new coordinate position to realize horizontal equidistant movement. The present invention can set horizontal equidistant for controls on the user interface across levels, and facilitates the arrangement and placement of interface controls.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of interface control production, and in particular to a method and system for realizing cross-level horizontal equidistant movement of interface controls. Background Art

[0002] When editing the user interface, the alignment of control positions is a relatively important function, and it is often necessary to arrange and place multiple button controls, image controls, or text controls. When arranging and aligning controls, it is generally necessary to keep the spacing between each control equal. Usually, the interface layout (such as horizontal layout or vertical layout) is set to keep the spacing between controls consistent. However, this method has certain limitations. First, if a horizontal layout is used to keep the horizontal spacing of each control equal, these controls must be placed in the same layout container, but it is possible that these controls belong to different layout containers, which conflicts with the original interface layout design. In addition, if the selected controls are at different levels, many current programs do not support it, and only support the horizontal spacing function of controls at the same level.

[0003] The existing technology mainly has the following disadvantages: the existing technology mainly realizes the horizontal equal spacing function of multiple controls on the interface through the horizontal layout function, and only supports the equal spacing of controls at the same level. It is difficult to realize the equal spacing function for multiple controls at different levels. If the equal spacing function of controls at different levels needs to be realized, the position needs to be manually calculated to achieve it, which is relatively cumbersome. Summary of the invention

[0004] To overcome the above problems, the purpose of the present invention is to provide a method for realizing horizontal equidistant movement of interface controls across levels, which can set horizontal equidistant positions of controls on the user interface across levels, facilitate the arrangement and placement of interface controls, and arrange them accurately.

[0005] The present invention is implemented by the following scheme: a method for realizing horizontal equidistant movement of interface controls across levels, the method comprising the following steps:

[0006] Step S1, selecting multiple controls that need to be processed with horizontal equidistant spacing on the interface;

[0007] Step S2: convert all relative coordinates of the selected controls in the scene into world coordinates, and sort the multiple controls according to their world coordinate positions;

[0008] Step S3, selecting the first two controls after sorting, and obtaining the spacing value between the two controls;

[0009] Step S4, traverse all selected controls and determine the position of the next control of the two controls in turn;

[0010] Step S5: according to the obtained new coordinate position of the next control, move the interface control to the new coordinate position to achieve horizontal equidistant movement.

[0011] Furthermore, the step S2 is further specified as follows: obtaining the relative coordinate position of the selected control in the scene, wherein the interface controls all use relative coordinate positions, and the relative coordinate positions are represented by corresponding scale values ​​and offsets; the scale value is the scale of the current control relative to its parent control; the offset is the scale of the current control relative to its parent control, and there are still pixel values ​​that need to be offset; converting all the relative coordinates of the selected controls into world coordinates, and sorting them from left to right according to the world coordinate positions of these selected controls; setting the control at the leftmost position as the first control, and so on to set the second control, the third control, and so on, until the last control.

[0012] Furthermore, the conversion of all relative coordinates of the selected controls into world coordinates is specifically as follows: the calculation is performed based on the scale value and the offset, and the calculation method is: if ParentWidth represents the width of the parent control of the current control, Scale represents the scale value of the current control relative to the parent control, and Offset represents the pixel value of the offset of the current control, then the world horizontal coordinate PosX of the current control is: PosX=ParentWidth*Scale+Offset. Due to the horizontal movement, the vertical coordinate position of the control remains unchanged.

[0013] Furthermore, the step S3 is further specified as follows: select the two leftmost controls after sorting, i.e., the first control and the second control, and then calculate the horizontal spacing value of the two controls, the horizontal spacing value being the difference between the horizontal coordinates of the two controls minus the width value of the first control; the calculation method is: set Space to represent the spacing value, FirstPosX to represent the horizontal coordinate position of the first control, SecondPosX to represent the horizontal coordinate position of the second control, and FirstWidth to represent the width of the first control, then the spacing value of the two controls is: Space = SecondPosX-FirstPosX-FirstWidth.

[0014] Furthermore, the step S4 is further specifically as follows: traverse all the controls selected in the interface, and determine the world horizontal coordinate position of the next control in turn according to the spacing value of the first two controls. The world horizontal coordinate position of the next control is calculated as follows:

[0015] (1) Set CurrentPosX to represent the horizontal coordinate position of the current control, CurrentWidth to represent the width of the current control, and Space to represent the spacing between two controls. Then the world horizontal coordinate position of the next control after moving, NextNewPosX, is:

[0016] NextNewPosX=CurrentPosX+CurrentWidth+Space; The current control refers to the control before the next control to be calculated;

[0017] (2) NextOldPosX represents the horizontal coordinate position of the next control before it moves. The difference between the positions of the next control before and after it moves is represented by Diff, and Diff is: Diff = NextNewPosX - NextOldPosX;

[0018] (3) Since there are two ways to move a control, only changing the offset of the control position, or only changing the scale value of the control position; the coordinate position of the control after the final movement can be obtained by the calculated horizontal coordinate position and the original vertical coordinate position; if the control offset, i.e., the offset OffSet, is kept unchanged, and only the control scale value Scale is changed, then the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is: Scale = (NextNewAbsPosX-OffSet) / ParentWidth; NextNewAbsPosX = ParentWidth*Scale+Offset;

[0019] 2) If the scale value of the control, i.e. the scale value Scale, remains unchanged and only the offset value Offset of the control is changed, the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is as follows:

[0020] NextNewAbsPosX=ParentWidth*Scale+Offset+Diff.

[0021] Furthermore, the step S5 is further specified as follows: according to the new coordinate position of the next control obtained, the interface controls are moved in sequence to their corresponding positions to achieve horizontal equidistant processing of the interface controls across levels. Since the world coordinate positions are used, the equidistant function can be achieved regardless of whether the controls are at the same level or at different levels.

[0022] The present invention also provides a system for realizing horizontal equidistant movement of interface controls across levels, the system comprising a selection module, a coordinate conversion module, a control spacing acquisition module, a position confirmation module, and a movement module;

[0023] The selection module is used to select multiple controls that need to be processed with horizontal equal spacing on the interface;

[0024] The coordinate conversion module is used to convert all relative coordinates of the selected controls in the scene into world coordinates, and sort the multiple controls according to the world coordinate positions;

[0025] The control spacing acquisition module selects the first two controls after sorting and obtains the spacing value between the two controls;

[0026] The position confirmation module traverses all selected controls and determines the position of the next control of the two controls in sequence;

[0027] The moving module moves the interface control to the new coordinate position according to the obtained new coordinate position of the next control, thereby realizing horizontal equidistant movement.

[0028] Furthermore, the implementation method of the coordinate conversion module is further specified as follows: obtaining the relative coordinate position of the selected control in the scene, wherein the interface controls all use relative coordinate positions, and the relative coordinate positions are represented by corresponding scale values ​​and offsets; the scale value is the scale of the current control relative to its parent control; the offset is the scale of the current control relative to its parent control, and there are still pixel values ​​that need to be offset; converting all the relative coordinates of the selected controls into world coordinates, and sorting them from left to right according to the world coordinate positions of these selected controls; setting the control at the leftmost position as the first control, and so on to set the second control, the third control, and so on, until the last control.

[0029] Furthermore, the conversion of all relative coordinates of the selected controls into world coordinates is specifically as follows: the calculation is performed based on the scale value and the offset, and the calculation method is: if ParentWidth represents the width of the parent control of the current control, Scale represents the scale value of the current control relative to the parent control, and Offset represents the pixel value of the offset of the current control, then the world horizontal coordinate PosX of the current control is: PosX=ParentWidth*Scale+Offset. Due to the horizontal movement, the vertical coordinate position of the control remains unchanged.

[0030] Furthermore, the implementation method of the control spacing acquisition module is further specifically as follows: select the two leftmost controls after sorting, namely the first control and the second control, and then calculate the horizontal spacing value of the two controls, the horizontal spacing value being the difference between the horizontal coordinates of the two controls minus the width value of the first control; the calculation method is: set Space to represent the spacing value, FirstPosX to represent the horizontal coordinate position of the first control, SecondPosX to represent the horizontal coordinate position of the second control, and FirstWidth to represent the width of the first control, then the spacing value of the two controls is: Space = SecondPosX-FirstPosX-FirstWidth.

[0031] Furthermore, the implementation method of the position confirmation module is further specifically as follows: traverse all the controls selected in the interface, and determine the world horizontal coordinate position of the next control in turn according to the spacing value of the first two controls. The world horizontal coordinate position calculation method of the next control is:

[0032] (1) Set CurrentPosX to represent the horizontal coordinate position of the current control, CurrentWidth to represent the width of the current control, and Space to represent the spacing between two controls. Then the world horizontal coordinate position of the next control after moving, NextNewPosX, is:

[0033] NextNewPosX=CurrentPosX+CurrentWidth+Space; The current control refers to the control before the next control to be calculated;

[0034] (2) NextOldPosX represents the horizontal coordinate position of the next control before it moves. The difference between the positions of the next control before and after it moves is represented by Diff, and Diff is: Diff = NextNewPosX - NextOldPosX;

[0035] (3) Since there are two ways to move a control, only changing the offset of the control position, or only changing the scale value of the control position; the coordinate position of the control after the final movement can be obtained by the calculated horizontal coordinate position and the original vertical coordinate position; if the control offset, i.e., the offset OffSet, is kept unchanged, and only the control scale value Scale is changed, then the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is: Scale = (NextNewAbsPosX-OffSet) / ParentWidth; NextNewAbsPosX = ParentWidth*Scale+Offset;

[0036] 2) If the scale value of the control, i.e. the scale value Scale, remains unchanged and only the offset value Offset of the control is changed, the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is as follows:

[0037] NextNewAbsPosX=ParentWidth*Scale+Offset+Diff.

[0038] Furthermore, the implementation method of the moving module is further specified as follows: according to the new coordinate position of the next control obtained, the interface controls are moved to their corresponding positions in sequence to achieve horizontal equidistant processing of interface controls across levels. Since the world coordinate positions are used, the equidistant function can be achieved regardless of whether the controls are at the same level or at different levels.

[0039] The beneficial effect of the present invention is that the present invention calculates the world positions of all selected controls in the scene after horizontal equidistance (normal controls are relative positions, and these relative positions need to be converted into world positions), and then calculates the distance that the control needs to move according to the starting world positions and control widths of these controls. Because the world positions on the interface are calculated, not the relative positions, the distance after the control is moved can maintain the horizontal equidistance function on the world position regardless of the same level or different levels; the controls on the user interface are set to be horizontally equidistant across levels, which facilitates the arrangement and placement of the interface controls, and helps to improve the efficiency of user editing the interface. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a schematic flow chart of the method of the present invention.

[0041] Figure 2 It is a system principle block diagram of the present invention.

[0042] Figure 3 It is a schematic diagram of the cross-layer equidistant effect of the control ABCD in one embodiment of the present invention. DETAILED DESCRIPTION

[0043] The present invention will be further described below in conjunction with the accompanying drawings.

[0044] like Figure 1 As shown, a method for realizing horizontal equidistant movement of interface controls across levels of the present invention comprises the following steps:

[0045] Step S1, selecting multiple controls that need to be processed with horizontal equidistant spacing on the interface;

[0046] Step S2: convert all relative coordinates of the selected controls in the scene into world coordinates, and sort the multiple controls according to their world coordinate positions;

[0047] Step S3, selecting the first two controls after sorting, and obtaining the spacing value between the two controls;

[0048] Step S4, traverse all selected controls and determine the position of the next control of the two controls in turn;

[0049] Step S5: according to the obtained new coordinate position of the next control, move the interface control to the new coordinate position to achieve horizontal equidistant movement.

[0050] The present invention will be further described below in conjunction with a specific embodiment:

[0051] The present invention requires selecting more than three controls on the interface, and then converting their scene position coordinates from relative coordinates to world coordinates, and then sorting them according to these world coordinates to obtain the first two interface controls. Then, the distance between the two controls is obtained through the positions of the world coordinates of the first two interface controls, and then the world coordinate positions of all subsequent controls after horizontal equidistance are recursively calculated to calculate the distance that each control needs to move for movement, and finally the cross-level horizontal equidistance function of the interface controls is realized.

[0052] A method for realizing cross-level horizontal equidistant movement of interface controls of the present invention is as follows:

[0053] 1. Select the controls that need to be horizontally spaced on the interface. You need to select at least three controls;

[0054] First, select the controls that need to be horizontally spaced equally on the interface. At least three controls need to be selected because two controls are needed to determine the horizontal spacing value between the two controls, and the third and subsequent controls are moved according to the spacing value to achieve consistent horizontal spacing for all interface controls.

[0055] 2. Convert all scene-relative coordinates of the selected controls to world coordinates and sort them from left to right according to the positions of these world coordinates.

[0056] Get the coordinate positions of all selected controls, and convert the relative coordinates of all selected controls into world coordinates. Sort the selected controls from left to right according to their coordinate positions. Set the leftmost control as the first control, and so on to the second, third, and last control. Since the interface controls must meet the settings of different scene resolutions (that is, when the scene resolution changes, the control positions under the corresponding interface must also change proportionally), the interface controls all use relative coordinate positions, and the corresponding relative coordinate positions can be directly obtained from the beginning (the relative coordinate position is represented by the corresponding scale value and offset, and can be obtained directly). The world coordinate position of the control is calculated based on the scale value (that is, the scale of the current control relative to its parent control) and the offset (that is, after the scale of the current control relative to its parent control, there are still pixel values ​​that need to be offset). The calculation method is as follows:

[0057] If ParentWidth represents the width of the parent control of the current control, Scale represents the scale of the current control relative to the parent control, and Offset represents the pixel value of the current control offset, then the world horizontal coordinate (PosX) of the current control is:

[0058] PosX=ParentWidth*Scale+Offset;

[0059] 3. Select the two leftmost controls after sorting and calculate the spacing between the two controls

[0060] Select the two leftmost controls after sorting, namely the first control and the second control, and then calculate the horizontal spacing value of the two controls. The horizontal spacing value is the difference between the horizontal coordinates of the two controls minus the width value of the first control. As shown below:

[0061] If Space represents the spacing value, FirstPosX represents the horizontal coordinate position of the first control, SecondPosX represents the horizontal coordinate position of the second control (that is, according to the PosX method, the horizontal coordinate position of the first control FirstPosX and the horizontal coordinate position of the second control SecondPosX can be obtained), FirstWidth represents the width of the first control, then the calculated spacing value of the two controls is: Space = SecondPosX-FirstPosX-FirstWidth.

[0062] 4. Traverse all selected controls and determine the position of the next control in turn

[0063] Traverse all the controls selected in the interface, and determine the position of the next control in turn according to the spacing value of the first two controls. The position of the next control is calculated as follows:

[0064] (1) If CurrentPosX represents the horizontal coordinate position of the current control (the current control refers to the control before the next control to be calculated. For example, if the horizontal coordinate position of the third control is to be calculated, the current control is the second control, and so on), CurrentWidth represents the width of the current control, and Space represents the spacing between two controls, then the new horizontal coordinate position of the next control (represented by NextNewPosX) is:

[0065] NextNewPosX=CurrentPosX+CurrentWidth+Space;

[0066] (2) NextOldPosX represents the original horizontal coordinate position of the next control. The difference between the previous and next positions of the next control (represented by Diff) is:

[0067] Diff=NextNewPosX-NextOldPosX

[0068] (3) Because there are two ways to move a control, you can change only the offset of the control position, or only change the proportional value of the control position. Since it is horizontally equidistant, the vertical coordinate position of the control remains unchanged, so you only need to calculate the horizontal coordinate of the control after the move to find the coordinate position of the control. The coordinate position of the control after the calculation and the original vertical coordinate position can be obtained.

[0069] 1) If the control offset (Offset) remains unchanged and only the control scale value (Scale) is changed, the horizontal coordinate position of the control after horizontal equidistance is calculated as follows:

[0070] Scale=(NextNewAbsPosX-OffSet) / ParentWidth;

[0071] NextNewAbsPosX=ParentWidth*Scale+Offset;

[0072] 2) If the scale value of the control (Scale) remains unchanged and only the offset (Offset) of the control is changed, the calculation method of the horizontal coordinate position of the control after horizontal equidistance is as follows:

[0073] NextNewAbsPosX=ParentWidth*Scale+Offset+Diff;

[0074] 5. According to the calculated position of the new control, move the interface control to the specified position to achieve horizontal equidistance

[0075] Finally, according to the absolute position of the control calculated in the previous step, the interface controls are moved to their corresponding positions in order to achieve horizontal equidistance between the interface controls across levels. Because absolute positions are used, the equidistance function can be achieved regardless of the same level or different levels.

[0076] like Figure 2 As shown, the present invention also provides a system for realizing horizontal equidistant movement of interface controls across levels, the system comprising a selection module, a coordinate conversion module, a control spacing acquisition module, a position confirmation module, and a movement module;

[0077] The selection module is used to select multiple controls that need to be processed with horizontal equal spacing on the interface;

[0078] The coordinate conversion module is used to convert all relative coordinates of the selected controls in the scene into world coordinates, and sort the multiple controls according to the world coordinate positions;

[0079] The control spacing acquisition module selects the first two controls after sorting and obtains the spacing value between the two controls;

[0080] The position confirmation module traverses all selected controls and determines the position of the next control of the two controls in sequence;

[0081] The moving module moves the interface control to the new coordinate position according to the obtained new coordinate position of the next control, thereby realizing horizontal equidistant movement.

[0082] Among them, the implementation method of the coordinate conversion module is further specified as follows: obtaining the relative coordinate position of the selected control in the scene, wherein the interface controls all use relative coordinate positions, and the relative coordinate positions are represented by corresponding scale values ​​and offsets; the scale value is the scale of the current control relative to its parent control; the offset is the scale of the current control relative to its parent control, and there are still pixel values ​​that need to be offset; converting all the relative coordinates of the selected controls into world coordinates, and sorting them from left to right according to the world coordinate positions of these selected controls; setting the control at the leftmost position as the first control, and setting the second control, the third control, and so on, until the last control.

[0083] The specific method of converting all relative coordinates of the selected controls into world coordinates is as follows: the coordinates are obtained by calculation based on the scale value and the offset. The calculation method is: if ParentWidth represents the width of the parent control of the current control, Scale represents the scale value of the current control relative to the parent control, and Offset represents the pixel value of the offset of the current control, then the world horizontal coordinate PosX of the current control is: PosX=ParentWidth*Scale+Offset. Due to horizontal movement, the vertical coordinate position of the control remains unchanged.

[0084] The implementation method of the control spacing acquisition module is further specifically as follows: select the two leftmost controls after sorting, namely the first control and the second control, and then calculate the horizontal spacing value of the two controls, where the horizontal spacing value is the difference between the horizontal coordinates of the two controls minus the width value of the first control; the calculation method is as follows: set Space to represent the spacing value, FirstPosX to represent the horizontal coordinate position of the first control, SecondPosX to represent the horizontal coordinate position of the second control, and FirstWidth to represent the width of the first control, then the spacing value of the two controls is: Space = SecondPosX-FirstPosX-FirstWidth.

[0085] The implementation method of the position confirmation module is further specifically as follows: traverse all the controls selected in the interface, and determine the world horizontal coordinate position of the next control in turn according to the spacing value of the first two controls. The world horizontal coordinate position calculation method of the next control is:

[0086] (1) Set CurrentPosX to represent the horizontal coordinate position of the current control, CurrentWidth to represent the width of the current control, and Space to represent the spacing between two controls. Then the world horizontal coordinate position of the next control after moving, NextNewPosX, is:

[0087] NextNewPosX=CurrentPosX+CurrentWidth+Space; The current control refers to the control before the next control to be calculated;

[0088] (2) NextOldPosX represents the horizontal coordinate position of the next control before it moves. The difference between the positions of the next control before and after it moves is represented by Diff, and Diff is: Diff = NextNewPosX - NextOldPosX;

[0089] (3) Since there are two ways to move a control, only changing the offset of the control position, or only changing the scale value of the control position; the coordinate position of the control after the final movement can be obtained by the calculated horizontal coordinate position and the original vertical coordinate position; if the control offset, i.e., the offset OffSet, is kept unchanged, and only the control scale value Scale is changed, then the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is: Scale = (NextNewAbsPosX-OffSet) / ParentWidth; NextNewAbsPosX = ParentWidth*Scale+Offset;

[0090] 2) If the scale value of the control, i.e. the scale value Scale, remains unchanged and only the offset value Offset of the control is changed, the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is as follows:

[0091] NextNewAbsPosX=ParentWidth*Scale+Offset+Diff.

[0092] The implementation method of the moving module is further specified as follows: according to the new coordinate position of the next control obtained, the interface controls are moved to their corresponding positions in sequence to achieve horizontal equidistant processing of interface controls across levels. Since the world coordinate positions are used, the equidistant function can be achieved regardless of whether the controls are at the same level or at different levels.

[0093] The application scenarios of the present invention are:

[0094] First, select the controls that need to be horizontally spaced equally on the interface. At least three controls need to be selected because two controls are needed to determine the horizontal spacing between the two controls, and the third and subsequent controls are moved according to the spacing value to achieve the purpose of consistent horizontal spacing for all interface controls. Figure 3 As shown, for example, if you select four interface controls, namely control A, control B, control C and control D, if you want to make the horizontal spacing of all interface controls consistent, and the control positions are arranged from A to D, then the ultimate goal is to make the distance from control A to control B equal to the distance from control B to control C, and equal to the distance from control C to control D.

[0095] Then, get the coordinate positions of all selected controls, and convert all the horizontal coordinates of the selected controls into world horizontal coordinates. Sort the selected controls from left to right according to their world coordinate positions. Set the control at the leftmost position as the first control, and set the second control, the third control, and so on until the last control. For example, you can set control A above as the first control, control B as the second control, control C as the third control, and control D as the fourth control. Since the interface controls must meet the settings of different scene resolutions (that is, the scene resolution changes, and the control positions under the corresponding interface must also change proportionally), the interface controls use relative coordinate positions, and the corresponding relative coordinate positions can be directly obtained at the beginning. The world coordinate position of the control is calculated based on the scale value (that is, the ratio of the current control to its parent control) and the offset (that is, after the ratio of the current control to its parent control, there is still a pixel value that needs to be offset). The calculation method is as follows:

[0096] If ParentWidth represents the width of the parent control of the current control, Scale represents the scale of the current control relative to the parent control, and Offset represents the pixel value of the current control offset, then the world horizontal coordinate (PosX) of the current control is:

[0097] PosX=ParentWidth*Scale+Offset;

[0098] Next, select the two leftmost controls after sorting, namely, control A and control B, and then calculate the horizontal spacing value of the two controls. The horizontal spacing value is the difference between the horizontal coordinates of the two controls minus the width value of the first control, that is, the horizontal spacing value of control A and control B is the horizontal coordinate of control B minus the horizontal coordinate of control A minus the width value of control A. If Space represents the spacing value, A_PosX represents the world horizontal coordinate position of the first control, B_PosX represents the world horizontal coordinate position of the second control, and A_Width represents the width of the first control, then the calculated spacing value of the two spaces is:

[0099] Space=A_PosX-B_PosX-A_Width;

[0100] After calculating the spacing value of the first two controls, it is necessary to traverse all the controls selected in the interface and determine the position of the next control in turn according to the spacing value of the first two controls.

[0101] The position of the next control is calculated as follows:

[0102] (1) If CurrentPosX represents the horizontal coordinate position of the current control (the current control refers to the control before the next control to be calculated. For example, if the horizontal coordinate position of the third control is to be calculated, the current control is the second control, and so on), CurrentWidth represents the width of the current control, and Space represents the spacing between two controls, then the new horizontal coordinate position of the next control (represented by NextNewPosX) is:

[0103] NextNewPosX=CurrentPosX+CurrentWidth+Space;

[0104] That is, the horizontal coordinate position of control C after horizontal equidistance (expressed by C_New_PosX) is:

[0105] C_New_PosX=B_PosX+B_Width+Space;

[0106] The horizontal coordinate position of control D after horizontal equidistance (expressed by D_New_PosX) is:

[0107] D_New_PosX=C_PosX+C_Width+Space;

[0108] (2) NextOldPosX represents the original horizontal coordinate position of the next control. The difference between the previous and next positions of the next control (represented by Diff) is:

[0109] Diff=NextNewPosX-NextOldPosX;

[0110] If C_PosX represents the original position of control C, the difference between the previous and next positions of control C (represented by C_Diff) is:

[0111] C_Diff = C_New_PosX - C_PosX;

[0112] If D_PosX represents the original position of control D, the difference between the front and back positions of control D (represented by D_Diff) is:

[0113] D_Diff = D_New_PosX - D_PosX;

[0114] (3) Because there are two ways to move a control, you can change only the offset of the control position, or only change the proportional value of the control position. Since it is horizontally equidistant, the vertical coordinate position of the control remains unchanged, so you only need to calculate the horizontal coordinate of the control after the move to find the coordinate position of the control. The coordinate position of the control after the calculation and the original vertical coordinate position can be obtained.

[0115] 1) If the control offset (Offset) remains unchanged and only the control scale value (Scale) is changed, the horizontal coordinate position of the control after horizontal equidistance is calculated as follows:

[0116] Scale=(Next_New_PosX-OffSet) / ParentWidth;

[0117] Next_New_PosX=ParentWidth*Scale+Offset;

[0118] That is, the proportional value of control C after equal spacing (expressed by C_New_Scale) is:

[0119] C_New_Scale=(C_New_PosX-C_Offset) / ParentWidth;

[0120] The horizontal coordinate position of control C after equidistant movement is:

[0121] C_New_PosX=C_New_Scale*ParentWidth+C_Offset;

[0122] 2) If the scale value of the control (Scale) remains unchanged and only the offset (Offset) of the control is changed, the calculation method of the horizontal coordinate position of the control after horizontal equidistance is as follows:

[0123] NextNewAbsPosX=ParentWidth*Scale+Offset+Diff;

[0124] That is, the horizontal coordinate position of control C after equidistant movement is:

[0125] C_New_PosX=C_Scale*ParentWidth+C_Offset+C_Diff;

[0126] Finally, according to the absolute position of the control calculated in the previous step, the interface controls are moved to their corresponding positions in order to achieve horizontal equidistance between the interface controls across levels. Because absolute positions are used, the equidistance function can be achieved regardless of the same level or different levels. Figure 3 It means there are 4 controls, namely control A, control B, control C and control D. Control A, control B and control D are at the same level, and control C is located inside control D. Select control A, control B and control C, and then achieve their equal spacing. Because the distance between control A and control B is 80, the distance between control C and control B after equal spacing will also be 80.

[0127] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.

Claims

1. A method for realizing horizontal equidistant movement of interface controls across levels, characterized by: The method comprises the following steps: Step S1, selecting multiple controls that need to be processed with horizontal equidistant spacing on the interface; Step S2: convert all relative coordinates of the selected controls in the scene into world coordinates, and sort the multiple controls according to their world coordinate positions; Step S3, selecting the first two controls after sorting, and obtaining the spacing value between the two controls; Step S4, traverse all selected controls and determine the position of the next control of the two controls in turn; Step S5: according to the obtained new coordinate position of the next control, move the interface control to the new coordinate position to achieve horizontal equidistant movement; The step S2 is further specifically as follows: obtaining the relative coordinate position of the selected control in the scene, wherein the interface controls all use relative coordinate positions, and the relative coordinate positions are represented by corresponding ratio values ​​and offsets; the ratio value is the ratio of the current control to its parent control; the offset is the ratio of the current control to its parent control, and there is still a pixel value that needs to be offset; converting all the relative coordinates of the selected controls into world coordinates, and sorting them from left to right according to the world coordinate positions of these selected controls; setting the control at the leftmost position as the first control, and setting the second control, the third control, and so on, until the last control; The specific method of converting all relative coordinates of the selected controls to world coordinates is: to obtain the world coordinates by calculation according to the scale value and the offset. The calculation method is: if ParentWidth represents the width of the parent control of the current control, Scale represents the scale value of the current control relative to the parent control, and Offset represents the pixel value of the current control offset, then the world horizontal coordinate PosX of the current control is: PosX = ParentWidth * Scale + Offset. Due to horizontal movement, the vertical coordinate position of the control remains unchanged. The step S4 is further specifically as follows: traverse all the controls selected in the interface, and determine the world horizontal coordinate position of the next control in turn according to the spacing value of the first two controls. The world horizontal coordinate position of the next control is calculated as follows: (1) Set CurrentPosX to represent the horizontal coordinate position of the current control, CurrentWidth to represent the width of the current control, and Space to represent the spacing between two controls. Then the world horizontal coordinate position of the next control after moving, NextNewPosX, is: NextNewPosX = CurrentPosX + CurrentWidth + Space; The current control refers to the control before the next control to be calculated; (2) NextOldPosX represents the horizontal coordinate position of the next control before it moves. The difference between the positions of the next control before and after it moves is represented by Diff, and Diff is: Diff = NextNewPosX - NextOldPosX; (3) Since there are two ways to move a control, only changing the offset of the control position, or only changing the scale of the control position; the coordinate position of the control after the final move can be obtained by the calculated horizontal coordinate position and the original vertical coordinate position; if the control offset, i.e., the offset OffSet, remains unchanged and only the control scale value Scale is changed, the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is: Scale = (NextNewAbsPosX - OffSet) / ParentWidth; NextNewAbsPosX = ParentWidth * Scale + Offset; 2) If the scale value of the control, i.e. the scale value Scale, remains unchanged and only the offset value Offset of the control is changed, the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is as follows: NextNewAbsPosX = ParentWidth * Scale + Offset + Diff.

2. A method for realizing cross-level horizontal equidistant movement of interface controls according to claim 1, characterized in that: The step S3 is further specifically as follows: select the two leftmost controls after sorting, i.e., the first control and the second control, and then calculate the horizontal spacing value of the two controls, where the horizontal spacing value is the difference between the horizontal coordinates of the two controls minus the width of the first control; the calculation method is: set Space to represent the spacing value, FirstPosX to represent the horizontal coordinate position of the first control, SecondPosX to represent the horizontal coordinate position of the second control, and FirstWidth to represent the width of the first control, then the spacing value of the two controls is: Space = SecondPosX - FirstPosX - FirstWidth.

3. A method for realizing cross-level horizontal equidistant movement of interface controls according to claim 1, characterized in that: The step S5 is further specified as follows: according to the new coordinate position of the next control obtained, the interface controls are moved in sequence to their corresponding positions to achieve horizontal equidistant processing of the interface controls across levels. Since the world coordinate positions are used, the equidistant function can be achieved regardless of whether the controls are at the same level or at different levels.

4. A system for realizing horizontal equidistant movement of interface controls across levels, characterized by: The system includes a selection module, a coordinate conversion module, a control spacing acquisition module, a position confirmation module, and a movement module; The selection module is used to select multiple controls that need to be processed with horizontal equal spacing on the interface; The coordinate conversion module is used to convert all relative coordinates of the selected controls in the scene into world coordinates, and sort multiple controls according to the world coordinate positions; The control spacing acquisition module selects the first two controls after sorting and obtains the spacing value between the two controls; The position confirmation module traverses all the selected controls and determines the position of the next control of the two controls in sequence; The moving module moves the interface control to the new coordinate position according to the obtained new coordinate position of the next control, so as to achieve horizontal equidistant movement; The implementation method of the coordinate conversion module is further specifically as follows: obtaining the relative coordinate position of the selected control in the scene, wherein the interface controls all use relative coordinate positions, and the relative coordinate positions are represented by corresponding scale values ​​and offsets; the scale value is the scale of the current control relative to its parent control; the offset is the scale of the current control relative to its parent control, and there is still a pixel value that needs to be offset; converting all the relative coordinates of the selected controls into world coordinates, and sorting them from left to right according to the world coordinate positions of these selected controls; setting the control at the leftmost position as the first control, and setting the second control, the third control, and so on, until the last control; The specific method of converting all relative coordinates of the selected controls to world coordinates is: to obtain the world coordinates by calculation according to the scale value and the offset. The calculation method is: if ParentWidth represents the width of the parent control of the current control, Scale represents the scale value of the current control relative to the parent control, and Offset represents the pixel value of the current control offset, then the world horizontal coordinate PosX of the current control is: PosX = ParentWidth * Scale + Offset. Due to horizontal movement, the vertical coordinate position of the control remains unchanged. The implementation method of the position confirmation module is further specifically as follows: traverse all the controls selected in the interface, and determine the world horizontal coordinate position of the next control in turn according to the spacing value of the first two controls. The world horizontal coordinate position calculation method of the next control is: (1) Set CurrentPosX to represent the horizontal coordinate position of the current control, CurrentWidth to represent the width of the current control, and Space to represent the spacing between two controls. Then the world horizontal coordinate position of the next control after moving, NextNewPosX, is: NextNewPosX = CurrentPosX + CurrentWidth + Space; The current control refers to the control before the next control to be calculated; (2) NextOldPosX represents the horizontal coordinate position of the next control before it moves. The difference between the positions of the next control before and after it moves is represented by Diff, and Diff is: Diff = NextNewPosX - NextOldPosX; (3) Since there are two ways to move a control, only changing the offset of the control position, or only changing the scale of the control position; the coordinate position of the control after the final move can be obtained by the calculated horizontal coordinate position and the original vertical coordinate position; if the control offset, i.e., the offset OffSet, remains unchanged and only the control scale value Scale is changed, the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is: Scale = (NextNewAbsPosX - OffSet) / ParentWidth; NextNewAbsPosX = ParentWidth * Scale + Offset; 2) If the scale value of the control, i.e. the scale value Scale, remains unchanged and only the offset value Offset of the control is changed, the calculation method of the horizontal coordinate position NextNewAbsPosX of the control after horizontal equidistance is as follows: NextNewAbsPosX = ParentWidth * Scale + Offset + Diff.

5. A system for realizing cross-level horizontal equidistant movement of interface controls according to claim 4, characterized in that: The implementation method of the control spacing acquisition module is further specifically as follows: select the two leftmost controls after sorting, namely the first control and the second control, and then calculate the horizontal spacing value of the two controls, where the horizontal spacing value is the difference between the horizontal coordinates of the two controls minus the width value of the first control; the calculation method is: set Space to represent the spacing value, FirstPosX to represent the horizontal coordinate position of the first control, SecondPosX to represent the horizontal coordinate position of the second control, and FirstWidth to represent the width of the first control, then the spacing value of the two controls is: Space = SecondPosX - FirstPosX -FirstWidth.

6. A system for realizing cross-level horizontal equidistant movement of interface controls according to claim 4, characterized in that: The implementation method of the moving module is further specified as follows: according to the new coordinate position of the next control obtained, the interface controls are moved to their corresponding positions in sequence to achieve horizontal equidistant processing of interface controls across levels. Since the world coordinate positions are used, the equidistant function can be achieved regardless of whether the controls are at the same level or at different levels.

Citation Information

Patent Citations

  • Robot walking obstacle detection method and device, computer device, and storage medium

    CN108628306A

  • Chart coordinate conversion method for hydrometeorological monitoring

    CN108776952A