CN117389556A - Component arrangement method and device, computer equipment and storage medium - Google Patents

Component arrangement method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN117389556A
CN117389556A CN202311317901.9A CN202311317901A CN117389556A CN 117389556 A CN117389556 A CN 117389556A CN 202311317901 A CN202311317901 A CN 202311317901A CN 117389556 A CN117389556 A CN 117389556A
Authority
CN
China
Prior art keywords
component
moved
width value
target row
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311317901.9A
Other languages
Chinese (zh)
Inventor
郭士君
杜绍江
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Lifesmart Technology Co ltd
Original Assignee
Hangzhou Lifesmart Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Lifesmart Technology Co ltd filed Critical Hangzhou Lifesmart Technology Co ltd
Priority to CN202311317901.9A priority Critical patent/CN117389556A/en
Publication of CN117389556A publication Critical patent/CN117389556A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0481Interaction techniques based on graphical user interfaces [GUI] based on specific properties of the displayed interaction object or a metaphor-based environment, e.g. interaction with desktop elements like windows or icons, or assisted by a cursor's changing behaviour or appearance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention relates to the field of computers, and discloses a component arrangement method, a device, computer equipment and a storage medium, wherein the method comprises the following steps: when a component moving instruction triggered by a user is detected, acquiring a width value of a component to be moved; acquiring a width value corresponding to a blank position of a target row; judging whether the component to be moved can be placed at the blank position of the target row or not according to the relation between the width value of the component to be moved and the corresponding width value of the blank position of the target row; if the components to be moved can be placed at the blank positions of the target rows, the components to be moved are controlled to move to the blank positions of the target rows until all the components to be moved are arranged.

Description

Component arrangement method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for arranging components, a computer device, and a storage medium.
Background
With the popularity of smartphones, front-end technology is also continually innovating and developing in order to provide users with more flow, flexible and friendly interfaces and interaction experiences. With the advent of front-end frameworks and component libraries, front-end development editing is more efficient and standardized, and frameworks and components provide rich functionality for components, state management, etc.
In the prior art, the components are laid out based on the frame, so that each component is required to meet the requirements of the components in the frame, such as the requirements of fixed aspect ratio of the components, and only the components with fixed aspect ratio can be arranged, so that the constraint on the components is higher, and the flexibility is lower.
Disclosure of Invention
In view of the above, the present invention provides a component arrangement method, apparatus, computer device and storage medium, so as to solve the problem of improving the flexibility of the layout of components.
In a first aspect, the present invention provides a component arrangement method, the method comprising:
when a component moving instruction triggered by a user is detected, acquiring a width value of a component to be moved;
acquiring a width value corresponding to a blank position of a target row;
judging whether the component to be moved can be placed at the blank position of the target row or not according to the relation between the width value of the component to be moved and the corresponding width value of the blank position of the target row;
and if the components to be moved can be placed at the blank positions of the target rows, controlling the components to be moved to the blank positions of the target rows until all the components to be moved are arranged.
The invention compares the width value of the component to be moved with the width value of the blank position of the target row to judge whether the component to be moved can be placed at the blank position of the target row, and arranges the components according to the judging result, so that the limitation of the aspect ratio is avoided when the components are arranged, and the components are freely arranged only according to the relation between the width value of the component and the width value of the blank position, thereby reducing the constraint on the components and improving the flexibility of the arrangement of the components.
In an optional implementation manner, the determining whether the component to be moved can be placed in the blank position of the target row according to the relationship between the width value of the component to be moved and the width value corresponding to the blank position of the target row includes:
determining the minimum unit width corresponding to the width value of the component to be moved;
judging whether the width value corresponding to the blank position of the target row is an integral multiple of the minimum unit width or not;
and if the width value corresponding to the blank position of the target row is not integral multiple of the minimum unit width, determining that the component to be moved cannot be placed at the blank position of the target row.
According to the method, whether the component to be moved can be placed at the blank position or not is primarily judged according to the relation between the minimum unit width of the width value of the component to be moved and the width value of the blank position, and when the corresponding width value of the blank position of the target row is not integral multiple of the minimum unit width, the fact that the component to be moved cannot be placed at the blank position of the target row is determined, so that the step of judging that the width of the component to be moved is compared with the width of the blank position is omitted.
In an alternative embodiment, the method further comprises:
if the width value corresponding to the blank position of the target row is a multiple of the minimum unit width, judging whether the width value corresponding to the blank position of the target row is larger than the width value of the component to be moved or not;
if the width value corresponding to the blank position of the target row is larger than or equal to the width value of the component to be moved, determining that the component to be moved can be placed at the blank position of the target row;
and if the width value corresponding to the blank position of the target row is smaller than the width value of the component to be moved, determining that the component to be moved cannot be placed at the blank position of the target row.
On the premise that the width value corresponding to the blank position of the target row is a multiple of the minimum unit width, the width value corresponding to the blank position of the target row and the width of the component to be moved are compared to determine whether the component to be moved can be placed at the blank position of the target row, so that the arrangement of the components is realized.
In an optional embodiment, the determining the minimum unit width corresponding to the width value of the component to be moved includes:
and calculating the smallest common divisor of the width values of the components to be moved, and determining the smallest common divisor as the smallest unit width.
The invention calculates the least common divisor of the width values of each component to be moved so as to judge the relation between the blank position and the minimum unit width.
In an alternative embodiment, the method further comprises:
acquiring an initial position and a target movement position of a component to be moved;
and controlling the movement of the component to be moved according to the relation between the initial position and the target movement position.
According to the invention, the position change of the component is recorded, and the component movement is controlled according to the relation between the initial position of the component and the target movement position, so that the dragging ordering of the component is realized.
In an alternative embodiment, the controlling the movement of the component to be moved according to the relation between the initial position and the target movement position includes:
and calculating the offset of the initial position and the target moving position, and controlling the component to be moved to move based on the offset.
According to the invention, the component to be moved is correspondingly moved by calculating the offset of the component to be moved, so that the jitter in the moving process of the component is prevented.
In an alternative embodiment, the controlling the component to be moved to move based on the offset includes:
respectively acquiring identification information of a component to be moved and component identification information corresponding to a target movement position;
and if the identification information of the component to be moved and the component identification information corresponding to the target movement position are unchanged within the preset time, carrying out position exchange on the component to be moved and the component corresponding to the target movement position.
The invention records the identification information of the component to be moved and the change of the identification information of the target mobile position component so as to exchange the position of the component when the identification information is unchanged, thereby preventing the error of the exchange of the position of the component.
In a second aspect, the present invention provides a component arranging apparatus comprising:
the first acquisition module is used for acquiring a width value of the component to be moved when detecting a component movement instruction triggered by a user;
the second acquisition module is used for acquiring a width value corresponding to the blank position of the target row;
the judging module is used for judging whether the component to be moved can be placed at the blank position of the target row according to the relation between the width value of the component to be moved and the corresponding width value of the blank position of the target row;
and the first control module is used for controlling the components to be moved to the blank positions of the target row if the components to be moved can be placed at the blank positions of the target row until all the components to be moved are arranged.
In a third aspect, the present invention provides a computer device comprising: the device comprises a memory and a processor, wherein the memory and the processor are in communication connection, the memory stores computer instructions, and the processor executes the computer instructions, so that the component arrangement method of the first aspect or any corresponding embodiment of the first aspect is executed.
In a fourth aspect, the present invention provides a computer-readable storage medium having stored thereon computer instructions for causing a computer to execute the component arranging method of the first aspect or any of the embodiments corresponding thereto.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a component arranging method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another component arrangement method according to an embodiment of the invention;
FIG. 3 is a flow chart of yet another component arrangement method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the location of a component exchange according to an embodiment of the invention;
FIG. 5 is a block diagram of a component arranging apparatus according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a hardware structure of a computer device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the related art, the Bootstrap grid framework is adopted as a basis for component layout, so that the constraint on components is higher, the autonomous layout cannot be realized, the UI framework is more preferred, the dependency on the framework is stronger, or the implementation mode is more single, only unidirectional layout is supported, the flexibility is poor, and the interactivity is poor.
In accordance with an embodiment of the present invention, there is provided an arrangement of components method embodiments, it being noted that the steps shown in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in an order other than that shown or described herein.
In this embodiment, a component arranging method is provided, which may be used in a mobile terminal, such as a mobile phone, a tablet, etc., fig. 1 is a flowchart of a component arranging method according to an embodiment of the present invention, and as shown in fig. 1, the flowchart includes the following steps:
step S101, when a component moving instruction triggered by a user is detected, a width value of a component to be moved is obtained.
In the embodiment of the invention, when the component is moved, a user drags the component on a screen of the mobile terminal, and when the operation triggered by the user is detected, the width value of the component to be moved is obtained so as to move the component to be moved.
Step S102, a width value corresponding to a blank position of the target line is obtained.
In the embodiment of the invention, the row where the target arrangement position of the component to be moved is located is determined as the target row, the blank position of the target row is determined according to the arranged components of the target row, and the width value of the blank position is determined so as to judge whether the component to be moved can be placed at the blank position of the target row.
Step S103, judging whether the component to be moved can be placed at the blank position of the target row according to the relation between the width value of the component to be moved and the corresponding width value of the blank position of the target row.
In the embodiment of the invention, the width value of the component to be moved is compared with the width value of the blank position of the target row, and whether the component to be moved can be placed in the blank position of the target row is judged according to the comparison result.
Step S104, if the components to be moved can be placed at the blank positions of the target row, the components to be moved are controlled to move to the blank positions of the target row until all the components to be moved are arranged.
In the embodiment of the invention, if the component to be moved can be placed at the blank position of the target row according to the comparison result of the width value of the component to be moved and the width value of the blank position of the target row, the component to be moved is moved to the blank position.
And sequentially judging whether the components to be moved can be placed in the blank positions of the target rows according to the sequence of the moving instructions of the components triggered by the user, sequentially moving the components to be moved, arranging the components to be moved according to the rows until the components to be moved are fully arranged according to the rows, and placing the components to be moved in the next row until all the components to be moved are arranged.
It should be noted that, first, the components to be moved are arranged in rows, and when the rows are full, the components to be moved are placed in the next row. The height value of the component to be moved is considered when placing the component to be moved in the next row. Firstly, acquiring a height value of a component to be moved and a height value of a blank position of a blank column, judging whether the component to be moved can be placed at the blank position of a target row according to the relation between the height value of the component to be moved and the height value corresponding to the blank position of the target row, and if the component to be moved can be placed at the blank position of the target row, controlling the component to be moved to move to the blank position of the target row until all the components to be moved are arranged.
According to the component arrangement method provided by the embodiment, the width value of the component to be moved is compared with the width value of the blank position of the target row to judge whether the component to be moved can be placed in the blank position of the target row, and the components are arranged according to the judging result, so that the limitation of the aspect ratio is avoided when the components are arranged, and the components are freely arranged only according to the relation between the width value of the component and the width value of the blank position, so that the constraint on the components is reduced, and the flexibility of component arrangement is improved.
In this embodiment, a component arranging method is provided, which may be used in the above-mentioned mobile terminal, such as a mobile phone, a tablet, etc., fig. 2 is a flowchart of a component arranging method according to an embodiment of the present invention, and as shown in fig. 2, the flowchart includes the following steps:
step S201, when a component moving instruction triggered by a user is detected, a width value of a component to be moved is obtained.
Please refer to step S101 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S202, a width value corresponding to a blank position of the target line is obtained.
Please refer to step S102 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S203, judging whether the component to be moved can be placed at the blank position of the target row according to the relation between the width value of the component to be moved and the corresponding width value of the blank position of the target row.
Specifically, the step S203 includes:
in step S2031, a minimum unit width corresponding to the width value of the component to be moved is determined.
Step S2032, determines whether the width value corresponding to the blank position of the target line is an integer multiple of the minimum unit width.
In step S2033, if the width value corresponding to the blank position of the target row is not an integer multiple of the minimum unit width, it is determined that the component to be moved cannot be placed in the blank position of the target row.
In the embodiment of the invention, the minimum unit width corresponding to the width value of the component to be moved is calculated, for example, the width values of the component to be moved are respectively 4, 8 and 4, the minimum unit width is 4, and the width values of the component to be moved are respectively 2, 4 and 6, and the minimum unit width is 2.
And judging whether the width value of the blank position of the target row is an integral multiple of the minimum unit width according to the width value of the blank position of the target row, for example, if the width value of the blank position of the target row is 3 and the minimum unit width is 4, the to-be-moved component cannot be placed at the blank position of the target row.
According to the relation between the minimum unit width of the width value of the component to be moved and the width value of the blank position, whether the component to be moved can be placed at the blank position is primarily judged, and when the width value corresponding to the blank position of the target row is not integral multiple of the minimum unit width, the fact that the component to be moved cannot be placed at the blank position of the target row is determined, so that the step of judging that the width of the component to be moved is compared with the width of the blank position is omitted.
Step S2034, if the width value corresponding to the blank position of the target row is a multiple of the minimum unit width, determining whether the width value corresponding to the blank position of the target row is greater than the width value of the component to be moved.
In step S2035, if the width value corresponding to the blank position of the target row is greater than or equal to the width value of the component to be moved, it is determined that the component to be moved can be placed at the blank position of the target row.
In step S2036, if the width value corresponding to the blank position of the target row is smaller than the width value of the component to be moved, it is determined that the component to be moved cannot be placed in the blank position of the target row.
In the embodiment of the invention, if the width value of the blank position of the target row is a multiple of the minimum unit width, the blank position of the target row where the component to be moved can be placed is primarily judged, and then whether the width value corresponding to the blank position of the target row is larger than the width value of the component to be moved is judged to determine that the component to be moved can be placed at the blank position of the target row.
Specifically, the step S2031 includes:
in step S20311, a smallest common divisor of the width values of the respective components to be moved is calculated, and the smallest common divisor is determined as the smallest unit width.
In the embodiment of the invention, the width values of all the components to be moved are determined, the least common divisor of the width values of all the components to be moved is calculated, and the least common divisor is determined as the minimum unit width.
And calculating the least common divisor of the width values of each component to be moved so as to judge the relation between the blank position and the minimum unit width.
In step S204, if the to-be-moved component can be placed at the blank position of the target row, the to-be-moved component is controlled to move to the blank position of the target row until all to-be-moved components are arranged.
Please refer to step S104 in the embodiment shown in fig. 1 in detail, which is not described herein.
The scheme supports a horizontal layout and a vertical layout, and the following is realized according to the vertical layout:
(1) The width and height of the minimum unit are determined. The minimum width and height are calculated from all the components to be laid out, and are used for determining the maximum minimum unit number which can be placed in each row in the blank page, and the minimum unit number is calculated as RowMaxCount.
(2) The components to be moved are arranged fully in rows. And according to the width multiple of each to-be-moved component and the minimum unit, summing the minimum unit of the current row as NowRowCellCount, and arranging the to-be-moved components to NowRowCellCount < = RowMaxCount according to the row. Meanwhile, the wide-high set of the components arranged in the current row is recorded in the layout process and is counted as a NowRowWidget.
(3) It is determined whether the current row can place the next component. And judging whether the next component W1 to be laid out can be put on the current line according to the NowRowWidget, namely, whether a space for placing the W1 exists in the NowRowWidget, and if so, placing the component and refreshing the component width and height recorded by the NowRowWidget. Otherwise, the line feed is performed.
Specifically, assuming that the components to be moved are full in rows, first, denoted as width cells wc and height cells hc.
First, it is checked how many wc components should be placed in each row, and if 10wc is placed in each row, an array with a length of 10 is generated, and the array is calculated as column h= [0,0,0,0,0,0,0,0,0,0].
When placing component w1 (3 wc,2 hc), the maximum height of the current column h is first obtained as maxhight. At this point, 0, then directly placed while columnH was modified to [2,2,2,0,0,0,0,0,0,0].
When the next component w2 (6 wc,3 hc) is placed, the maxhight is acquired again, and first, whether all are maxhight in columnH is judged, if not, whether a component with the width of 6wc can be placed in a region which does not reach maxhight in columnH is checked, namely, columnH is modified to [2,2,2,3,3,3,3,3,3,0].
When the next component w3 (2 wc,2 hc) is placed, the maxhight is obtained again, firstly, whether all maxhight is in columnH is judged, if not, whether the component with the width of 2wc can be placed in the area which does not reach the maxhight in columnH is checked, if so, whether the area with the height of 2hc can be placed in the area which can be placed is judged, namely, the value +2hc < maxhight of the area where columnH can be placed is judged, if not, line feed is carried out, and meanwhile, the value of columH is refreshed to be maxhight, namely [3,3,3,3,3,3,3,3,3,3]. And then replace w3.
According to the component arrangement method provided by the embodiment, on the premise that the width value corresponding to the blank position of the target row is a multiple of the minimum unit width, the width value corresponding to the blank position of the target row and the width of the component to be moved are compared to be large or small, so that whether the component to be moved can be placed in the blank position of the target row or not is determined, and therefore the arrangement of the components is achieved.
In this embodiment, a component arranging method is provided, which may be used in the above-mentioned mobile terminal, such as a mobile phone, a tablet, etc., fig. 3 is a flowchart of a component arranging method according to an embodiment of the present invention, and as shown in fig. 3, the flowchart includes the following steps:
in step S301, when a component movement instruction triggered by a user is detected, a width value of a component to be moved is obtained.
Please refer to step S101 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S302, a width value corresponding to a blank position of the target line is obtained.
Please refer to step S102 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S303, judging whether the component to be moved can be placed at the blank position of the target row according to the relation between the width value of the component to be moved and the corresponding width value of the blank position of the target row.
Please refer to step S103 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S304, if the components to be moved can be placed at the blank positions of the target row, the components to be moved are controlled to move to the blank positions of the target row until all the components to be moved are arranged.
Please refer to step S104 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S305, acquiring an initial position and a target movement position of the component to be moved.
Step S306, controlling the movement of the component to be moved according to the relation between the initial position and the target movement position.
In the embodiment of the invention, after all the components to be moved are arranged, an initial position set of all the component sequences is recorded and is recorded as AllWIdgetLayout. And (5) recalculating the target position set of each component after dragging, and recording as a RenderAllWidget.
And determining that the component with the position movement exists according to the initial position set allWidgetLayout and the target position set RenderAllWidget, and controlling the component to be moved to move.
And by recording the position change of the component, the component is controlled to move according to the relation between the initial position of the component and the target moving position, so that the dragging ordering of the component is realized.
In some alternative embodiments, the step S306 includes:
in step S3061, the offset of the initial position and the target movement position is calculated, and the component to be moved is controlled to move based on the offset.
In the embodiment of the invention, the coordinate positions of all components before ordering and the coordinate positions of all components after ordering are recorded, the coordinates of the same components in the two components are subjected to difference processing to obtain the offset of the initial position and the target movement position, the offset set is marked as a needlerender, and corresponding animation movement is performed according to the offset set needlerender, so that drag ordering is realized.
And correspondingly moving the component to be moved by calculating the offset of the component to be moved so as to prevent the jitter in the moving process of the component.
In some optional embodiments, controlling the component to be moved to move based on the offset in step S3061 includes:
step S30011, respectively acquiring the identification information of the component to be moved and the component identification information corresponding to the target movement position.
Step S30612, if the identification information of the component to be moved and the component identification information corresponding to the target movement position are not changed within the preset time, the position of the component to be moved and the component corresponding to the target movement position are exchanged.
In the embodiment of the invention, the identification information nonwMoveIndex of the component to be moved and the component identification information nonwAcceptIndex corresponding to the target movement position are respectively provided. When the components are moved and dragged, the nonwMoveIndex and the nonwAcceptIndex are recorded, a delay task is started at the same time, after waiting for 100ms, if the two identification information are unchanged, the components to be moved and the components corresponding to the target movement positions are subjected to position exchange.
The component position exchange is performed when the identification information is unchanged by recording the identification information of the component to be moved and the change of the identification information of the target mobile position component, so that the component position exchange error is prevented.
When both the dragging component and the receiving component exist, as shown in fig. 4, the dragging path is Id8-Id4-Id0 from Id8 to Id0. From Id8 to Id4, drag component 8, receive component 4, record the current state R1. From Id4 to Id0, drag element 4, receive element 0, record current state R2. When the component position exchange is performed, the state Rn is recorded, a timer is started, and after 100ms, whether the recording state is still Rn is checked. If the state is still Rn, the position exchange is carried out, otherwise, the position exchange is not carried out.
According to the component arrangement method provided by the embodiment, through the custom layout, the position layout of components with different sizes and the position change of corresponding components in dragging are calculated, and an anti-shake mechanism is added, so that the functions of irregular graphic layout and dragging reordering are realized, and the use experience is good.
The embodiment also provides a device for arranging components, which is used for realizing the above embodiment and the preferred implementation, and is not described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The present embodiment provides a component arrangement apparatus, as shown in fig. 5, including:
the first obtaining module 501 is configured to obtain a width value of a component to be moved when a component movement instruction triggered by a user is detected.
A second obtaining module 502, configured to obtain a width value corresponding to the blank position of the target line.
A judging module 503, configured to judge whether the component to be moved can be placed in the blank position of the target row according to the relationship between the width value of the component to be moved and the width value corresponding to the blank position of the target row.
The first control module 504 is configured to control the to-be-moved component to move to the blank position of the target row if the to-be-moved component can be placed at the blank position of the target row until all to-be-moved components complete the arrangement.
In some alternative embodiments, the determining module 503 includes:
and the first determining unit is used for determining the minimum unit width corresponding to the width value of the component to be moved.
And the first judging unit is used for judging whether the width value corresponding to the blank position of the target row is an integral multiple of the minimum unit width.
And the second determining unit is used for determining that the component to be moved cannot be placed at the blank position of the target row if the width value corresponding to the blank position of the target row is not integral multiple of the minimum unit width.
In some alternative embodiments, the determining module 503 further includes:
and the second judging unit is used for judging whether the width value corresponding to the blank position of the target row is larger than the width value of the component to be moved if the width value corresponding to the blank position of the target row is a multiple of the minimum unit width.
And the third determining unit is used for determining that the component to be moved can be placed at the blank position of the target row if the width value corresponding to the blank position of the target row is larger than or equal to the width value of the component to be moved.
And the fourth determining unit is used for determining that the component to be moved cannot be placed at the blank position of the target row if the width value corresponding to the blank position of the target row is smaller than the width value of the component to be moved.
In some alternative embodiments, the first determining unit includes:
and the first determination subunit is used for calculating the least common divisor of the width values of the components to be moved and determining the least common divisor as the minimum unit width.
In some alternative embodiments, the apparatus further comprises:
and the third acquisition module is used for acquiring the initial position and the target movement position of the component to be moved.
And the second control module is used for controlling the movement of the component to be moved according to the relation between the initial position and the target movement position.
In some alternative embodiments, the second control module includes:
and the control unit is used for calculating the offset of the initial position and the target movement position and controlling the component to be moved to move based on the offset.
In some alternative embodiments, the control unit includes:
the acquisition subunit is used for respectively acquiring the identification information of the component to be moved and the component identification information corresponding to the target movement position.
And the position exchange unit is used for carrying out position exchange on the components to be moved and the components corresponding to the target moving positions if the identification information of the components to be moved and the component identification information corresponding to the target moving positions are unchanged within preset time.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The component arrangements of the present embodiments are presented in terms of functional units, where a unit refers to an ASIC (Application Specific Integrated Circuit ) circuit, a processor and memory executing one or more software or firmware programs, and/or other devices that can provide the functionality described above.
The embodiment of the invention also provides computer equipment, which is provided with the component arrangement device shown in the figure 5.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a computer device according to an alternative embodiment of the present invention, as shown in fig. 6, the computer device includes: one or more processors 10, memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the computer device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple computer devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 10 is illustrated in fig. 6.
The processor 10 may be a central processor, a network processor, or a combination thereof. The processor 10 may further include a hardware chip, among others. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform a method for implementing the embodiments described above.
The memory 20 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 20 may optionally include memory located remotely from processor 10, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
Memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk, or solid state disk; the memory 20 may also comprise a combination of the above types of memories.
The computer device further comprises input means 30 and output means 40. The processor 10, memory 20, input device 30, and output device 40 may be connected by a bus or other means, for example in fig. 6.
The input means 30 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the computer device, such as a touch screen or the like. The output means 40 may comprise a display device or the like.
The embodiments of the present invention also provide a computer readable storage medium, and the method according to the embodiments of the present invention described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, a solid state disk or the like; further, the storage medium may also comprise a combination of memories of the kind described above. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.

Claims (10)

1. A method of arranging components, the method comprising:
when a component moving instruction triggered by a user is detected, acquiring a width value of a component to be moved;
acquiring a width value corresponding to a blank position of a target row;
judging whether the component to be moved can be placed at the blank position of the target row or not according to the relation between the width value of the component to be moved and the corresponding width value of the blank position of the target row;
and if the components to be moved can be placed at the blank positions of the target rows, controlling the components to be moved to the blank positions of the target rows until all the components to be moved are arranged.
2. The method according to claim 1, wherein the determining whether the component to be moved can be placed in the blank position of the target row according to the relation between the width value of the component to be moved and the width value corresponding to the blank position of the target row includes:
determining the minimum unit width corresponding to the width value of the component to be moved;
judging whether the width value corresponding to the blank position of the target row is an integral multiple of the minimum unit width or not;
and if the width value corresponding to the blank position of the target row is not integral multiple of the minimum unit width, determining that the component to be moved cannot be placed at the blank position of the target row.
3. The method according to claim 2, wherein the method further comprises:
if the width value corresponding to the blank position of the target row is a multiple of the minimum unit width, judging whether the width value corresponding to the blank position of the target row is larger than the width value of the component to be moved or not;
if the width value corresponding to the blank position of the target row is larger than or equal to the width value of the component to be moved, determining that the component to be moved can be placed at the blank position of the target row;
and if the width value corresponding to the blank position of the target row is smaller than the width value of the component to be moved, determining that the component to be moved cannot be placed at the blank position of the target row.
4. The method according to claim 2, wherein determining the minimum unit width corresponding to the width value of the component to be moved comprises:
and calculating the smallest common divisor of the width values of the components to be moved, and determining the smallest common divisor as the smallest unit width.
5. The method according to claim 1, wherein the method further comprises:
acquiring an initial position and a target movement position of a component to be moved;
and controlling the movement of the component to be moved according to the relation between the initial position and the target movement position.
6. The method of claim 5, wherein controlling movement of the component to be moved according to the relationship between the initial position and the target movement position comprises:
and calculating the offset of the initial position and the target moving position, and controlling the component to be moved to move based on the offset.
7. The method of claim 6, wherein the controlling the component to be moved to move based on the offset comprises:
respectively acquiring identification information of a component to be moved and component identification information corresponding to a target movement position;
and if the identification information of the component to be moved and the component identification information corresponding to the target movement position are unchanged within the preset time, carrying out position exchange on the component to be moved and the component corresponding to the target movement position.
8. A component arranging apparatus, characterized in that the apparatus comprises:
the first acquisition module is used for acquiring a width value of the component to be moved when detecting a component movement instruction triggered by a user;
the second acquisition module is used for acquiring a width value corresponding to the blank position of the target row;
the judging module is used for judging whether the component to be moved can be placed at the blank position of the target row according to the relation between the width value of the component to be moved and the corresponding width value of the blank position of the target row;
and the first control module is used for controlling the components to be moved to the blank positions of the target row if the components to be moved can be placed at the blank positions of the target row until all the components to be moved are arranged.
9. A computer device, comprising:
a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the component arrangement method of any of claims 1 to 7.
10. A computer-readable storage medium having stored thereon computer instructions for causing a computer to execute the component arrangement method according to any one of claims 1 to 7.
CN202311317901.9A 2023-10-11 2023-10-11 Component arrangement method and device, computer equipment and storage medium Pending CN117389556A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311317901.9A CN117389556A (en) 2023-10-11 2023-10-11 Component arrangement method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311317901.9A CN117389556A (en) 2023-10-11 2023-10-11 Component arrangement method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117389556A true CN117389556A (en) 2024-01-12

Family

ID=89471286

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311317901.9A Pending CN117389556A (en) 2023-10-11 2023-10-11 Component arrangement method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117389556A (en)

Similar Documents

Publication Publication Date Title
KR102323333B1 (en) Application data processing method and apparatus, and storage medium
CN109634598B (en) Page display method, device, equipment and storage medium
CN107608609B (en) Event object sending method and device
CN111221643A (en) Task processing method and task processing device
CN111399941A (en) Batch configuration method, device and equipment for BMC (baseboard management controller) functions
CN103970434A (en) Method and electronic equipment for responding operation
CN110471700B (en) Graphic processing method, apparatus, storage medium and electronic device
CN111400633A (en) Page resource loading method and device
JP6751778B2 (en) Methods, electronic devices and storage media for realizing communication between business systems and multi-assembly
CN113741753A (en) Revocation method, electronic device, storage medium, and computer program product
CN112799768A (en) Method and device for realizing horse race lamp and electronic equipment
CN113407254A (en) Form generation method and device, electronic equipment and storage medium
CN106713962B (en) Video display method, apparatus and terminal device
KR101390467B1 (en) Method and device for movement of image object
CN117389556A (en) Component arrangement method and device, computer equipment and storage medium
CN109246468B (en) Video list switching method, device and storage medium based on education system
CN115951959A (en) Floating window display, device, electronic equipment and storage medium
CN113676677B (en) Dynamic picture synthesis method and device, electronic equipment and readable storage medium
CN104423950B (en) Information processing method and electronic equipment
CN115390976A (en) Layout method of interface design, display method of interface and related equipment
CN109271538A (en) A kind of picture storage method and relevant device
WO2018205390A1 (en) Control layout display control method, system, and apparatus, and computer readable storage medium
CN114490266A (en) Data acquisition method, device, equipment and storage medium
US8395641B1 (en) Method for inserting graphic elements
CN112306838A (en) Page layout compatibility testing method, device and equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination