Method, system, device and storage medium for switching between horizontal and vertical screens in software

By obtaining the finger movement distance within the software, calculating the rotation angle, and updating the coordinate value of the display area, the existing technology problems of high complexity of horizontal and vertical screen switching and difficulty in maintaining the window width are solved, and convenient horizontal and vertical screen switching and window width maintenance are achieved. .

CN118981267BActive Publication Date: 2025-01-24深圳市云希谷科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411473331.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2025-01-24
Estimated Expiration
2044-10-22

AI Technical Summary

Technical Problem

The prior art has high complexity when switching horizontal and vertical screens, making the window width difficult to maintain, resulting in the window jitter after switching or the horizontal and vertical screen layout transformation and window width maintenance at the same time.

Method used

By obtaining the movement distance between the fingers in the horizontal and vertical directions in the software, calculate the sliding distance and rotation angle, and update the coordinate value of the display area to achieve horizontal and vertical screen switching and keep the width of the window unchanged.

Benefits of technology

It enables convenient switching between horizontal and vertical screens within the software, ensuring that the window width remains unchanged during the switching process, improving user experience and software usability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118981267B_ABST
    Figure CN118981267B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, system, device and storage medium for switching between horizontal and vertical screens in software, the method comprising obtaining the horizontal moving distance of a finger in the horizontal direction and the vertical moving distance in the vertical direction; calculating the sliding distance generated by the finger when dragging according to the horizontal moving distance and the vertical moving distance; obtaining the length of the current canvas and the width of the current canvas; calculating the current rotation angle according to the sliding distance; obtaining the vertex coordinates of the current canvas according to the display coordinates of the current canvas according to the length of the current canvas and the width of the current canvas; drawing the vertex coordinates of the target canvas according to the vertex coordinates of the current canvas and the rotation angle; replacing the vertex coordinates of the target canvas with the vertex coordinates of the current canvas, and moving based on the vertex coordinates of the target canvas, updating the coordinate values ​​of the display area, so as to achieve horizontal and vertical screen switching. The method can simultaneously meet the requirements of horizontal and vertical screen layout transformation and window width retention.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of screen display technology, and in particular to a method, system, device and storage medium for switching between horizontal and vertical screens in software. Background Art

[0002] At present, the function of switching the touch screen between horizontal and vertical is widely used in smart tablets and smart devices, which enables users to input text, browse web pages, and especially play videos conveniently and comfortably.

[0003] The more common method at present is to use the gravity sensor to obtain angle data to achieve horizontal and vertical screen switching. However, if you want to switch between horizontal and vertical screens at any time and want to keep the current window width unchanged when switching, that is, the window is dynamically adjusted as the screen rotates, then the current method will have certain difficulties.

[0004] In summary, the existing technology has the problem of high complexity in switching between horizontal and vertical screens, and it is difficult to maintain the window width after switching. Summary of the invention

[0005] The present invention provides a method, system, device and storage medium for switching between horizontal and vertical screens in software, so as to solve the technical problems in the prior art that the horizontal and vertical screen switching is highly complex and the window width is difficult to maintain after switching.

[0006] In a first aspect, in order to solve the above technical problem, the present invention provides a method for switching between horizontal and vertical screens in software, which is executed by a computer and includes:

[0007] When the window is displaced by dragging the finger, the horizontal moving distance and the vertical moving distance of the finger are obtained;

[0008] Performing a calculation operation according to the horizontal moving distance and the vertical moving distance to obtain a sliding distance generated by the finger when dragging;

[0009] Get the length and width of the current canvas;

[0010] Perform calculation operations according to the sliding distance to obtain a current rotation angle;

[0011] According to the length and the width of the current canvas, the vertex coordinates of the current canvas are calculated by the display coordinates of the current canvas;

[0012] Draw and obtain vertex coordinates of a target canvas according to the vertex coordinates of the current canvas and the rotation angle;

[0013] The vertex coordinates of the target canvas are replaced with the vertex coordinates of the current canvas, and the vertex coordinates of the target canvas are moved based on the vertex coordinates of the target canvas to update the coordinate values ​​of the display area to achieve horizontal and vertical screen switching.

[0014] In an optional implementation, the acquiring the horizontal movement distance of the finger in the horizontal direction and the vertical movement distance of the finger in the vertical direction includes:

[0015] Capture the action event when the finger touches the screen to determine whether the finger moves in the vertical and horizontal displacement directions;

[0016] When it is determined that the finger is dragging the sliding window, the position coordinates of the finger at the start time of dragging and the position coordinates of the finger at the end time of dragging are obtained;

[0017] The horizontal moving distance of the finger in the horizontal direction and the vertical moving distance in the vertical direction are obtained by subtracting the position coordinates at the time when the dragging starts and the position coordinates at the time when the dragging ends.

[0018] In an optional implementation, the calculating operation is performed according to the horizontal moving distance and the vertical moving distance to obtain the sliding distance generated by the finger during the dragging, including:

[0019] Multiply the horizontal movement distance by the width of the screen, and multiply the vertical movement distance by the length of the screen to obtain a first horizontal X-axis offset distance and a first vertical Y-axis offset distance;

[0020] The second horizontal X-axis offset distance and the second vertical Y-axis offset distance are obtained according to the first horizontal X-axis offset distance minus the length value of the layout and the first vertical Y-axis offset distance minus the width value of the layout.

[0021] The second horizontal X-axis offset distance and the second vertical Y-axis offset distance are the sliding distance.

[0022] In an optional implementation, the screen width value and the screen length value are respectively the width and length of the screen of the display device, and are obtained by directly reading the display device parameters;

[0023] The length value of the layout and the width value of the layout are respectively parameters obtained in the operation of obtaining the horizontal moving distance of the finger in the horizontal direction and the vertical moving distance of the finger in the vertical direction when the window is displaced by dragging the finger.

[0024] In an optional implementation manner, obtaining the length and width of the current canvas includes:

[0025] Draw a line on the initial canvas according to the sliding distance, and the x coordinate of the intersection with the 45-degree line in the horizontal and vertical directions is the length of the current canvas;

[0026] The width of the initial canvas multiplied by the canvas zoom factor is the width of the current canvas.

[0027] In an optional implementation, the width value of the initial canvas is a preset value;

[0028] The scaling factor is a value obtained by dividing the width value of the layout by the width value of the initial canvas.

[0029] In an optional implementation, performing a calculation operation according to the sliding distance to obtain a current rotation angle includes:

[0030] Multiply the sliding distance by 90 and divide by the screen width to get the current rotation angle.

[0031] In an optional implementation, the obtaining the vertex coordinates of the current canvas by calculating the display coordinates of the current canvas according to the length of the current canvas and the width of the current canvas includes:

[0032] Read the length and width of the current canvas;

[0033] Convert the length and width of the current canvas into the display coordinates;

[0034] Set the center of the canvas to , the length of the canvas is , the width is , then the coordinates of the vertices can be calculated as follows:

[0035] Vertex X coordinate : ;

[0036] Vertex Y coordinate : ;

[0037] in, is the X coordinate of the center of the canvas, is the Y coordinate of the center of the canvas, is the length of the canvas, The width of the canvas.

[0038] In a second aspect, the present invention provides a system for switching between horizontal and vertical screens in software, comprising:

[0039] A data acquisition module, used to acquire the horizontal movement distance of the finger and the vertical movement distance of the finger when the finger drags the window to move;

[0040] A distance calculation module, used to perform a calculation operation according to the horizontal movement distance and the vertical movement distance to obtain a sliding distance generated by the finger when dragging;

[0041] The length and width acquisition module is used to obtain the length and width of the current canvas;

[0042] A rotation direction determination module, used to perform a calculation operation according to the sliding distance to obtain a current rotation angle;

[0043] A vertex coordinate acquisition module, used to obtain the vertex coordinates of the current canvas by calculating the display coordinates of the current canvas according to the length and width of the current canvas;

[0044] A target coordinate calculation module, used for drawing and obtaining the vertex coordinates of the target canvas according to the vertex coordinates of the current canvas and the rotation angle;

[0045] The horizontal and vertical screen switching module is used to replace the vertex coordinates of the target canvas with the vertex coordinates of the current canvas, and move based on the vertex coordinates of the target canvas to update the coordinate value of the display area to achieve horizontal and vertical screen switching.

[0046] In a third aspect, the present invention also provides an electronic device comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, it implements any one of the above-described methods for switching between horizontal and vertical screens within software.

[0047] In a fourth aspect, the present invention further provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned methods for switching between horizontal and vertical screens within software.

[0048] Compared with the prior art, the present invention has the following beneficial effects:

[0049] The present invention discloses a method for switching between horizontal and vertical screens in software, including: when a finger drags to displace a window, obtaining the horizontal moving distance of the finger in the horizontal direction and the vertical moving distance in the vertical direction; performing a calculation operation based on the horizontal moving distance and the vertical moving distance to obtain the sliding distance generated by the finger when dragging; obtaining the length of the current canvas and the width of the current canvas; performing a calculation operation based on the sliding distance to obtain the current rotation angle; obtaining the vertex coordinates of the current canvas through the display coordinates of the current canvas based on the length of the current canvas and the width of the current canvas; drawing the vertex coordinates of the target canvas based on the vertex coordinates of the current canvas and the rotation angle: replacing the vertex coordinates of the target canvas with the vertex coordinates of the current canvas, and moving based on the vertex coordinates of the target canvas, updating the coordinate values ​​of the display area, so as to achieve horizontal and vertical screen switching. The calculation of the coordinate values ​​and the vertex replacement operation of the target canvas ensure that the width of the window remains unchanged during the switching process, making it more convenient to switch between horizontal and vertical screens in the software. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 is a schematic flow chart of a method for switching between horizontal and vertical screens in software provided by a first embodiment of the present invention;

[0051] Figure 2 This is a schematic diagram of a method for switching between horizontal and vertical screens in software provided by an embodiment of the present invention;

[0052] Figure 3 It is a schematic diagram of the system structure for switching between horizontal and vertical screens in software provided by the second embodiment of the present invention. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0054] At present, the function of switching the touch screen between horizontal and vertical is widely used in smart tablets and smart devices, which enables users to input text, browse web pages, and especially play videos conveniently and comfortably.

[0055] At present, the more common method is to use the gravity sensor to obtain angle data to achieve horizontal and vertical screen switching. However, if you want to switch between horizontal and vertical screens at any time and want to keep the current window width unchanged when switching, that is, the window is dynamically adjusted as the screen rotates, then the current methods will have certain difficulties. In summary, the horizontal and vertical screen switching in the existing technology has the problem of high complexity and difficulty in maintaining the window width after switching.

[0056] In order to solve the above technical problems, refer to Figure 1 The first embodiment of the present invention provides a method for switching between horizontal and vertical screens in software, comprising the following steps:

[0057] S1, when the window is displaced by dragging the finger, obtain the horizontal moving distance of the finger and the vertical moving distance of the finger;

[0058] S2, performing a calculation operation according to the horizontal moving distance and the vertical moving distance to obtain a sliding distance generated by the finger when dragging;

[0059] S3, obtain the length and width of the current canvas;

[0060] S4, performing a calculation operation according to the sliding distance to obtain a current rotation angle;

[0061] S5, obtaining vertex coordinates of the current canvas by calculating the display coordinates of the current canvas according to the length and the width of the current canvas;

[0062] S6, drawing and obtaining vertex coordinates of a target canvas according to the vertex coordinates of the current canvas and the rotation angle;

[0063] S7, replacing the vertex coordinates of the target canvas with the vertex coordinates of the current canvas, and moving based on the vertex coordinates of the target canvas, updating the coordinate values ​​of the display area, so as to achieve horizontal and vertical screen switching.

[0064] In step S1 , it is necessary to obtain the horizontal moving distance of the finger in the horizontal direction and the vertical moving distance in the vertical direction.

[0065] In a specific embodiment, obtaining the horizontal movement distance of the finger in the horizontal direction and the vertical movement distance in the vertical direction includes: capturing the action event of the finger when touching the screen to determine whether the finger moves in the vertical and horizontal displacement directions; when it is determined that the finger drags the sliding window, obtaining the position coordinates of the finger at the start time of dragging and the position coordinates of the finger at the end time of dragging; subtracting the position coordinates at the start time of dragging and the position coordinates at the end time of dragging to obtain the horizontal movement distance of the finger in the horizontal direction and the vertical movement distance in the vertical direction.

[0066] It should be noted that when the user slides on the screen, the horizontal and vertical movement distances can be calculated by comparing the changes in the finger positions in the two previous touch events. Specifically, the touch event processing function can be rewritten in the software, and two main action events can be focused on:

[0067] ACTION_DOWN: The event in which a finger touches the screen. The coordinates at this time are recorded as the starting point.

[0068] ACTION_MOVE: The event of the finger moving on the screen records the current coordinates and compares them with the starting point coordinates.

[0069] By calculating the difference between the two event coordinates, we can get the distance the user's finger has moved on the screen. The horizontal movement distance can be obtained by calculating the difference between the current X coordinate and the starting X coordinate; the vertical movement distance can be obtained by calculating the difference between the current Y coordinate and the starting Y coordinate.

[0070] For example, the window height is 600, the width is 400, the initial coordinates of the finger are at (200, 200), and when dragged to (300, 300), the horizontal movement distance of the finger is 100, and the vertical movement distance is 100. In this way, the displacement distance of the finger in the horizontal and vertical directions is determined.

[0071] In step S2, a calculation operation is performed according to the horizontal moving distance and the vertical moving distance to obtain the sliding distance generated by the finger during dragging, including:

[0072] Multiply the horizontal movement distance by the width value of the screen, and multiply the vertical movement distance by the length value of the screen to obtain a first horizontal X-axis offset distance and a first vertical Y-axis offset distance. Subtract the length value of the layout from the first horizontal X-axis offset distance and subtract the width value of the layout from the first vertical Y-axis offset distance to obtain a second horizontal X-axis offset distance and a second vertical Y-axis offset distance. The second horizontal X-axis offset distance and the second vertical Y-axis offset distance are the sliding distance.

[0073] It should be noted that: Assume that the initial touch point of the user's finger is , the position after moving is ,So:

[0074] Horizontal movement distance ;

[0075] Vertical moving distance ;

[0076] The sliding distance caused by dragging the finger It can be calculated by the following formula:

[0077] ;

[0078] in and are the moving distances in the horizontal and vertical directions, respectively. It is from the point To point The straight-line distance is the sliding distance generated when the finger is dragged.

[0079] In step S3, obtaining the length and width of the current canvas includes:

[0080] Draw a line on the initial canvas according to the sliding distance. The x coordinate of the intersection with the 45-degree line in the horizontal and vertical directions is the length of the current canvas. The width of the initial canvas multiplied by the zoom factor of the canvas is the width of the current canvas.

[0081] It should be noted that: starting from the center of the initial canvas, a line is drawn according to the sliding distance. This line intersects with the border of the canvas to form an intersection. In particular, this line intersects with the 45-degree lines in the horizontal and vertical directions. The length of the current canvas can be determined by finding the x-coordinate of the intersection of this line and the 45-degree line. Due to the characteristics of the 45-degree line, the x-coordinate of this intersection is actually the length of the current canvas.

[0082] The width of the current canvas can be obtained by multiplying the initial canvas width by the zoom factor.

[0083] In step S4, the calculation operation is performed according to the sliding distance to obtain the current rotation angle, including: multiplying the sliding distance by 90 and dividing by the width value of the screen to obtain the current rotation angle.

[0084] It should be noted that in another implementation, the rotation angle can also be calculated by calculating the angle between the sliding vector and the horizontal axis: This can be done using the inverse tangent function (atan2), which takes into account the case where the vector is in the second and fourth quadrants: ;

[0085] in, Is a mathematical function, the return value is a point arrive The angle (in radians) of the vector, taking into account that the vector is in the correct quadrant of the coordinate system.

[0086] Rotation Angle = ;

[0087] In step S5, the vertex coordinates of the current canvas are obtained by calculating the display coordinates of the current canvas according to the length and the width of the current canvas. The specific operations include:

[0088] Set the center of the canvas to , the length of the canvas is , the width is , then the coordinates of the vertices can be calculated as follows:

[0089] Vertex X coordinate : ;

[0090] Vertex Y coordinate : ;

[0091] in, is the X coordinate of the center of the canvas, is the Y coordinate of the center of the canvas, is the length of the canvas, The width of the canvas.

[0092] In step S6, the vertex coordinates of the target canvas are obtained by drawing according to the vertex coordinates of the current canvas and the rotation angle. The specific operations include:

[0093] Use the rotation matrix to calculate the rotated coordinates:

[0094] ;

[0095] in: is the vertex coordinate before rotation, are the coordinates of the rotated vertices, is the rotation center coordinate, is the rotation angle.

[0096] In step S7, the vertex coordinates of the target canvas are replaced with the vertex coordinates of the current canvas, and the vertex coordinates of the target canvas are moved based on the vertex coordinates of the target canvas to update the coordinate values ​​of the display area to achieve horizontal and vertical screen switching. The specific operations include:

[0097] Set the vertex coordinates of the current canvas Replace with the newly calculated vertex coordinates of the target canvas . Update the coordinate values ​​of the display area and move the canvas to the new position in the user interface. This can be achieved by changing the layout parameters of the canvas or using the corresponding functions of the graphics library. Call the drawing function to redraw the contents on the canvas. When redrawing, use the new target vertex coordinates as the reference point. Handle screen orientation changes and adjust the user interface layout to fit the screen according to the new screen orientation. Update the size and scale parameters of the view to ensure that the content is displayed correctly.

[0098] Exemplarily, the change in the device screen orientation is first detected, which is implemented by listening to system-level events or APIs, such as using the onConfigurationChanged method in Android, or listening to UIDeviceOrientationDidChangeNotification in iOS. Once the screen orientation change is detected, the four vertex coordinates of the current canvas (i.e., the current display interface) are obtained, and the coordinates define the position and size of the canvas on the screen. Next, the vertex coordinates of the target canvas (i.e., the new interface after the horizontal and vertical screens are switched) are obtained. Then, the software replaces the vertex coordinates of the current canvas with the vertex coordinates of the target canvas. After replacing the coordinates, the content on the canvas is repositioned according to the new vertex coordinates, including but not limited to the following operations: moving, scaling, or rearranging interface elements to ensure correct display in the new screen orientation. After the content is repositioned, the coordinate values ​​of the display area are updated. Among them, it includes updating the layout parameters of the view, adjusting the boundaries of the view, etc., to ensure that the new display area matches the vertex coordinates of the target canvas. Finally, the interface is redrawn to reflect the new layout after the horizontal and vertical screens are switched. For example, a drawing API is called to re-render interface elements (views, controls, etc.).

[0099] In another embodiment, the method for switching between horizontal and vertical screens in step S7 specifically includes: step S71 to step S72, as follows:

[0100] Step S71: Build an interface and rewrite the OnTouchEvent function of the window to capture the finger drag event and calculate the offset;

[0101] Step S72: switching;

[0102] In step S71, the specific operations of constructing the interface include:

[0103] The interface layout is LinearLayout, and two horizontally arranged Views are nested in LinearLayout. Both Views use a nine-square layout, in which a background image is placed. The two Views have different horizontal widths, and are called wide View and narrow View respectively. This interface layout is divided into wide layout and narrow layout.

[0104] Specifically: The width of the wide View is the screen width minus the layout interval, that is, L width. In the wide View, the aspect ratio of the wide View is 16:9.

[0105] The width of the narrow View is the screen height minus the layout interval, that is, L is narrow. In the narrow View, the aspect ratio of the wide View is 9:16.

[0106] That is, the aspect ratio of the wide View and the narrow View is equal to Lwidth / Lnarrow.

[0107] Rewrite the OnTouchEvent function of the window to capture finger drag events and calculate offsets. The specific operations include:

[0108] In the interface window, add a View that overrides the OnTouchEvent function.

[0109] In the OnTouchEvent function, when the finger is pressed, the coordinate value center of the window center is calculated, and the coordinate value of the pressed point (the position where the finger is pressed) is recorded.

[0110] When the finger slides, the sliding offset of the finger, the slope k of the line connecting the point pressed by the finger and the center point of the current window, and the angle theta formed by the line and the positive direction of the x-axis are recorded. The vector of the finger sliding is Vector2f ( , ), the vector connecting the point pressed by the finger and the center point of the current window is Vector2f( , ), the angle between them is , the calculation formula is as follows:

[0111] The finger sliding vector is decomposed into Vector2f( , ), the calculation formula is as follows, where beta is the ratio of horizontal sliding to the total vector size

[0112] in for , for , for , for .

[0113] Then, calculate the width and height of the two Views and narrow , the ratio of the length of the wide View in each direction to the length of the wide View is , the product of the ratio of the wide View to the narrow View in two directions is recorded as , the length of View is recorded as , the specific calculation formula is as follows:

[0114] = ,

[0115] = ,

[0116] Among them, Lwidth is the length of the wide View in the vertical direction, and Lnarrow is the length of the narrow View in the vertical direction.

[0117] Calculate the length of the wide View h and the length of the narrow View , the calculation formula is as follows:

[0118] ;

[0119] ;

[0120] In the wide View, the y-axis offset of the slide is , the offset on the x-axis is ;

[0121] In a narrow View, the y-axis offset of the slide is , the offset on the x-axis is ;

[0122] in, is the displacement of the finger on the y-axis, is the offset of the finger on the x-axis. In this way, the current rotation angle phi can be calculated, and the phi value can be converted into the distance the finger slides between the two Views. The calculation formula is as follows:

[0123] When the window is rotated to a positive angle, the value of the upward offset y axis is ,

[0124] Right now ,

[0125] When the window is rotated to a negative angle, the value of the upward offset y axis is ,

[0126] Right now

[0127] .

[0128] in, The distance that the narrow View needs to be offset upward.

[0129] When moving in the window, the current offset on the y-axis is calculated based on the offset at regular intervals. , the offset on the x-axis , calculate the offset and update the coordinates in the interface to achieve the moving effect.

[0130] The present invention calculates the offset coordinate value and the updated coordinate value based on the sliding distance and the layout size.

[0131] When the user drags a View in the layout horizontally or vertically during application, the layout will rotate with the user, and the rotated layout will be displayed in the center of the mobile terminal screen.

[0132] For example, in the narrow view, the window shifts downward, the wide view moves upward, and the narrow view moves downward. Specifically, when the user slides his finger downward, the wide view moves upward and the narrow view shifts downward until the finger leaves the interface to stop the shift of the wide view and the narrow view.

[0133] The background images in the wide View and the narrow View need to be rotated, and the rotation direction is determined according to the direction of the finger sliding.

[0134] Specifically: the wide View uses an aspect ratio of 16:9, and the narrow View uses an aspect ratio of 9:16.

[0135] When the user slides up in the vertical direction, that is, drags upward, the width View is offset upward and its aspect ratio is less than 9:16; when the user slides down in the vertical direction, that is, drags downward, the width View is offset downward and its aspect ratio is greater than 9:16.

[0136] When the user slides upward horizontally, that is, drags horizontally, the horizontal offset of the narrow View is smaller than the vertical offset. When the aspect ratio of the wide View is less than 9:16, the height of the narrow View is greater than the wide View, and its aspect ratio is greater than 16:9. When the aspect ratio of the wide View is greater than 9:16, the height of the narrow View is smaller than the wide View, and its aspect ratio is less than 16:9.

[0137] When the user slides down horizontally, that is, drags horizontally, the horizontal offset of the narrow View is greater than the vertical offset. When the aspect ratio of the wide View is less than 9:16, the height of the narrow View is greater than the wide View, and its aspect ratio is greater than 16:9. When the aspect ratio of the wide View is greater than 9:16, the height of the narrow View is less than the wide View, and its aspect ratio is less than 16:9.

[0138] In step S72, the specific switching operation includes:

[0139] After the rotation effect is achieved, the user can switch between horizontal and vertical screen display. In horizontal mode, in vertical mode, long press the lock screen unlock interface for 5 seconds, and the horizontal screen switch option will appear. Click the horizontal screen switch option to switch to horizontal mode. In horizontal mode, long press the lock screen unlock interface for 5 seconds, and the vertical screen switch option will appear. Click the vertical screen switch option to switch to vertical mode.

[0140] The present invention realizes screen rotation by dragging a finger, and expands the function of automatically rotating the display interface from the horizontal screen state to the vertical screen state in this function. The advantage of the present invention is that the horizontal screen and the vertical screen can be switched by dragging a finger in the horizontal screen display, giving the user a better user experience.

[0141] In order to facilitate the understanding of the present invention, some preferred embodiments of the present invention are further described below.

[0142] The following describes the working process of the present invention using a common scenario as an example. Figure 2 , which is Figure 1 Schematic diagram of the working scenario of the method.

[0143] When the user slides his finger on the screen to drag the View on the interface. When the user drags, the system will capture the sliding event of the finger and calculate the moving distance in the horizontal and vertical directions. The system will calculate the offset based on the initial position and current position of the finger. If the user wants to keep the window width unchanged when switching between landscape and portrait, the system will dynamically adjust the position of the window according to this offset. When the user drags the View to a certain angle, the system will update the displayed coordinate value according to the calculated offset distance and rotation angle to achieve the rotation effect. The user can trigger the option of switching between landscape and portrait by long pressing the lock screen unlock interface. After selecting, the system will switch to landscape or portrait state according to the user's input.

[0144] In summary, the present invention discloses a method for switching between horizontal and vertical screens in software, including: when a finger drags to displace a window, obtaining the horizontal moving distance of the finger in the horizontal direction and the vertical moving distance in the vertical direction; performing calculation operations based on the horizontal moving distance and the vertical moving distance to obtain the sliding distance generated by the finger when dragging; obtaining the length of the current canvas and the width of the current canvas; performing calculation operations based on the sliding distance to obtain the current rotation angle; obtaining the vertex coordinates of the current canvas based on the display coordinates of the current canvas based on the length of the current canvas and the width of the current canvas; drawing the vertex coordinates of the target canvas based on the vertex coordinates of the current canvas and the rotation angle: replacing the vertex coordinates of the target canvas with the vertex coordinates of the current canvas, and moving based on the vertex coordinates of the target canvas, updating the coordinate values ​​of the display area, so as to achieve horizontal and vertical screen switching. The calculation of the coordinate values ​​and the vertex replacement operation of the target canvas ensure that the width of the window remains unchanged during the switching process, making it more convenient to switch between horizontal and vertical screens in the software.

[0145] The present invention solves the problems in the prior art such as high complexity, difficulty in maintaining window width, window jitter, difficulty in switching non-standard angles, and inability to simultaneously satisfy horizontal and vertical screen layout conversion and window width maintenance.

[0146] Switching between landscape and portrait modes within the software can improve the user experience and adapt to different usage scenarios. For example, in landscape mode, video playback and gaming applications can provide a wider field of view and enhance immersion; reading applications can display more content in landscape mode to improve reading efficiency. In addition, map and navigation applications can display more detailed map information in landscape mode, making it easier for users to plan routes. This flexibility allows the software to better adapt to user needs and improve software usability and satisfaction.

[0147] Reference Figure 3 A second embodiment of the present invention provides a system for switching between horizontal and vertical screens in software, comprising:

[0148] A data acquisition module, used to acquire the horizontal movement distance of the finger and the vertical movement distance of the finger when the finger drags the window to move;

[0149] A distance calculation module, used to perform a calculation operation according to the horizontal movement distance and the vertical movement distance to obtain a sliding distance generated by the finger when dragging;

[0150] The length and width acquisition module is used to obtain the length and width of the current canvas;

[0151] A rotation direction determination module, used to perform a calculation operation according to the sliding distance to obtain a current rotation angle;

[0152] A vertex coordinate acquisition module, used to obtain the vertex coordinates of the current canvas by calculating the display coordinates of the current canvas according to the length and width of the current canvas;

[0153] A target coordinate calculation module, used for drawing and obtaining the vertex coordinates of the target canvas according to the vertex coordinates of the current canvas and the rotation angle;

[0154] The horizontal and vertical screen switching module is used to replace the vertex coordinates of the target canvas with the vertex coordinates of the current canvas, and move based on the vertex coordinates of the target canvas to update the coordinate value of the display area to achieve horizontal and vertical screen switching.

[0155] Preferably, the data acquisition module specifically includes:

[0156] An event judgment unit is used to capture the action event of the finger touching the screen to determine whether the finger moves in the vertical and horizontal displacement directions;

[0157] A position coordinate unit, used to obtain the position coordinates of the finger at the start time of dragging and the position coordinates of the finger at the end time of dragging when it is determined that the finger drags the sliding window;

[0158] The distance acquisition unit is used to obtain the horizontal movement distance of the finger in the horizontal direction and the vertical movement distance in the vertical direction by subtracting the position coordinates at the start time of the dragging and the position coordinates at the end time of the dragging.

[0159] Preferably, the distance calculation module includes:

[0160] A unit for acquiring the horizontal movement distance of the finger in the horizontal direction and the vertical movement distance of the finger in the vertical direction, used for acquiring the numerical information of the horizontal movement distance of the finger in the horizontal direction and the vertical movement distance of the finger in the vertical direction into a memory;

[0161] A first offset distance calculating unit is used to multiply the numerical information of the horizontal movement distance of the finger in the horizontal direction and the vertical movement distance in the vertical direction by the numerical information of the length of the screen to obtain a first horizontal X-axis offset distance and a first vertical Y-axis offset distance;

[0162] A second offset distance calculation unit is used to obtain a second horizontal X-axis offset distance and a second vertical Y-axis offset distance by subtracting a length value of the layout from the first horizontal X-axis offset distance and a width value of the layout from the first vertical Y-axis offset distance;

[0163] The sliding distance conversion unit is used to convert the obtained second horizontal X-axis offset distance and the second vertical Y-axis offset distance into a sliding distance.

[0164] Preferably, the length and width acquisition module includes:

[0165] The current canvas length acquisition unit is used to draw a line on the initial canvas according to the sliding distance, and convert the x coordinate of the intersection point with the 45-degree line in the horizontal and vertical directions into the current canvas length;

[0166] The current canvas width obtaining unit is used to obtain the current canvas width by multiplying the initial canvas width by the scaling factor.

[0167] Preferably, the rotation direction determination module comprises:

[0168] A sliding distance acquisition unit, used to acquire the sliding distance value from the memory;

[0169] The calculation unit is used to multiply the sliding distance by 90 and divide it by the width of the screen to obtain the current rotation angle and determine the rotation direction.

[0170] Preferably, the vertex coordinate acquisition module includes:

[0171] A value acquisition unit, used to acquire the center coordinates of the canvas, the length of the canvas, and the width of the canvas pre-stored in the internal memory;

[0172] The vertex coordinate calculation unit is used to calculate the center coordinates of the canvas, the length of the canvas, and the width of the canvas obtained from the value acquisition unit through pre-set parameters to obtain the vertex coordinates of the current canvas.

[0173] Preferably, the target coordinate calculation module includes:

[0174] A data acquisition unit, used to obtain the vertex coordinates and rotation angle of the current canvas;

[0175] The target coordinate calculation unit is used to obtain the vertex coordinates and rotation angle of the current canvas and calculate the target coordinates through a formula.

[0176] Preferably, the horizontal and vertical screen switching module includes:

[0177] A coordinate replacement unit is used to replace the vertex coordinates of the current canvas with the vertex coordinates of the newly calculated target canvas;

[0178] The display update unit is used to update the coordinate value of the display area and move the canvas to a new position on the user interface.

[0179] In summary, the present invention discloses a system for switching between horizontal and vertical screens in software, including: when a finger drags to displace a window, obtaining the horizontal moving distance of the finger in the horizontal direction and the vertical moving distance in the vertical direction; performing calculation operations based on the horizontal moving distance and the vertical moving distance to obtain the sliding distance generated by the finger when dragging; obtaining the length of the current canvas and the width of the current canvas; performing calculation operations based on the sliding distance to obtain the current rotation angle; obtaining the vertex coordinates of the current canvas based on the display coordinates of the current canvas based on the length of the current canvas and the width of the current canvas; drawing the vertex coordinates of the target canvas based on the vertex coordinates of the current canvas and the rotation angle: replacing the vertex coordinates of the target canvas with the vertex coordinates of the current canvas, and moving based on the vertex coordinates of the target canvas, updating the coordinate values ​​of the display area, so as to achieve horizontal and vertical screen switching. The calculation of the coordinate values ​​and the vertex replacement operation of the target canvas ensure that the width of the window remains unchanged during the switching process, making it more convenient to switch between horizontal and vertical screens in the software.

[0180] Switching between landscape and portrait modes within the software can improve the user experience and adapt to different usage scenarios. For example, in landscape mode, video playback and gaming applications can provide a wider field of view and enhance immersion; reading applications can display more content in landscape mode to improve reading efficiency. In addition, map and navigation applications can display more detailed map information in landscape mode, making it easier for users to plan routes. This flexibility allows the software to better adapt to user needs and improve software usability and satisfaction.

[0181] The invention provides a method for switching between horizontal and vertical screens in software. The core of the invention is to realize flexible rotation of the software interface through a simple drag operation of the user's finger, so as to freely switch between horizontal and vertical screens. The invention makes full use of the interactive advantages of touch screen devices, makes the operation of switching between horizontal and vertical screens more intuitive and convenient, and greatly improves the user experience.

[0182] Specifically, the present invention achieves accurate capture of finger drag events by rewriting the OnTouchEvent event of the window. When the user slides on the screen, the system will record the starting and ending positions of the finger in real time, and calculate the displacement distance of the finger in the horizontal and vertical directions. This process is not only simple and efficient, but also can effectively avoid switching caused by misoperation, thereby ensuring the accuracy of switching.

[0183] On this basis, the present invention further calculates the offset distance in combination with the layout size, and converts the offset distance into the sliding distance. In this way, the system can accurately control the rotation angle of the window according to the drag amplitude of the user, thereby achieving a more natural and smooth switching effect. In addition, the present invention also takes into account the compatibility issues of different screen sizes and resolutions, and can automatically adjust the switching effect according to different device parameters to ensure that users can get a consistent experience on different devices.

[0184] In order to achieve the rotation effect of the window, the present invention updates the display coordinate value by calculating the offset coordinate value. Specifically, the system calculates the new vertex coordinates according to the center point, rotation angle and offset distance of the current window, and applies it to the display of the window. In this way, the system can rotate the window from the current position to the target position, thereby achieving the effect of switching between horizontal and vertical screens.

[0185] It is worth mentioning that the present invention also provides detailed steps and calculation methods, including rewriting the OnTouchEvent event, calculating the offset distance, determining the rotation angle, calculating the display coordinates, etc., which can realize the horizontal and vertical screen switching function. In addition, the present invention also has the advantages of perfect technology, rich functions, optimized experience, safety and reliability, etc., which can effectively avoid problems such as misoperation and safety risks, and ensure the safety and stability of users during use.

[0186] In summary, the present invention provides a method for switching between horizontal and vertical screens within software that is simple, easy to use, powerful, and has a good experience, which can effectively improve the convenience and comfort of users when using mobile devices, and can bring users a more convenient, efficient, and pleasant user experience.

[0187] It should be noted that a system for switching between horizontal and vertical screens within software provided by an embodiment of the present invention is used to execute all the process steps of a method for switching between horizontal and vertical screens within software in the above embodiment. The working principles and beneficial effects of the two correspond one to one, and thus will not be elaborated upon.

[0188] The embodiment of the present invention further provides an electronic device. The electronic device includes: a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a computing operation program. When the processor executes the computer program, the steps in the above-mentioned data acquisition method embodiments are implemented, such as Figure 1 Alternatively, when the processor executes the computer program, the functions of the modules / units in the above-mentioned device embodiments are realized, such as the vertex coordinate acquisition module.

[0189] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the electronic device.

[0190] The electronic device may be a computing device such as a desktop computer, a notebook, a PDA, and a smart tablet. The electronic device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the above components are merely examples of electronic devices and do not constitute a limitation on the electronic device. The electronic device may include more or fewer components than the above components, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0191] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device.

[0192] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the electronic device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0193] Wherein, if the module / unit integrated in the electronic device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0194] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.

[0195] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for switching between horizontal and vertical screens in software, characterized in that: Executed by a computer, including: When the window is displaced by dragging the finger, the horizontal moving distance and the vertical moving distance of the finger are obtained; Performing a calculation operation according to the horizontal moving distance and the vertical moving distance to obtain a sliding distance generated by the finger when dragging; Get the length and width of the current canvas; Perform calculation operations according to the sliding distance to obtain a current rotation angle; According to the length and the width of the current canvas, the vertex coordinates of the current canvas are calculated by the display coordinates of the current canvas; Draw and obtain vertex coordinates of a target canvas according to the vertex coordinates of the current canvas and the rotation angle; Replace the vertex coordinates of the target canvas with the vertex coordinates of the current canvas, move based on the vertex coordinates of the target canvas, and update the coordinate value of the display area to achieve horizontal and vertical screen switching; The step of obtaining the horizontal movement distance of the finger in the horizontal direction and the vertical movement distance of the finger in the vertical direction includes: Capture the action event when the finger touches the screen to determine whether the finger moves in the vertical and horizontal displacement directions; When it is determined that the finger is dragging the sliding window, the position coordinates of the finger at the start time of dragging and the position coordinates of the finger at the end time of dragging are obtained; Subtracting the position coordinates at the start time of dragging from the position coordinates at the end time of dragging to obtain a horizontal movement distance of the finger in the horizontal direction and a vertical movement distance of the finger in the vertical direction; The calculating operation is performed according to the horizontal moving distance and the vertical moving distance to obtain the sliding distance generated by the finger when dragging, including: Multiply the horizontal movement distance by the width of the screen, and multiply the vertical movement distance by the length of the screen to obtain a first horizontal X-axis offset distance and a first vertical Y-axis offset distance; A second horizontal X-axis offset distance and a second vertical Y-axis offset distance are obtained by subtracting the length of the layout from the first horizontal X-axis offset distance and subtracting the width of the layout from the first vertical Y-axis offset distance; The second horizontal X-axis offset distance and the second vertical Y-axis offset distance are the sliding distance; The screen width value and the screen length value are respectively the width and length of the screen of the display device, and are obtained by directly reading the display device parameters; The length value of the layout and the width value of the layout are respectively parameters obtained in the operation of obtaining the horizontal moving distance of the finger in the horizontal direction and the vertical moving distance of the finger in the vertical direction when the window is displaced by dragging the finger.

2. The method for switching between horizontal and vertical screens in software according to claim 1, characterized in that: The obtaining of the length and width of the current canvas includes: Draw a line on the initial canvas according to the sliding distance, and the x coordinate of the intersection with the 45-degree line in the horizontal and vertical directions is the length of the current canvas; The width of the initial canvas multiplied by the canvas zoom factor is the width of the current canvas.

3. The method for switching between horizontal and vertical screens in software according to claim 2, characterized in that: The width of the initial canvas is a preset value; The scaling factor is a value obtained by dividing the width value of the layout by the width value of the initial canvas.

4. The method for switching between horizontal and vertical screens in software according to claim 1, characterized in that: The calculating operation is performed according to the sliding distance to obtain the current rotation angle, including: Multiply the sliding distance by 90 and divide by the screen width to get the current rotation angle.

5. The method for switching between horizontal and vertical screens in software according to claim 3, characterized in that: The step of obtaining the vertex coordinates of the current canvas by calculating the display coordinates of the current canvas according to the length and the width of the current canvas includes: Read the length and width of the current canvas; Convert the length and width of the current canvas into the display coordinates; The vertex coordinates of the current canvas are calculated using the following formula: Set the center of the canvas to , the length of the canvas is , the width is , then the coordinates of the vertices can be calculated as follows: Vertex X coordinate : ; Vertex Y coordinate : ; in, is the X coordinate of the center of the canvas, is the Y coordinate of the center of the canvas, is the length of the canvas, The width of the canvas.

6. A system for switching between horizontal and vertical screens in software, characterized in that: include: A data acquisition module, used to acquire the horizontal movement distance of the finger and the vertical movement distance of the finger when the finger drags the window to move; A distance calculation module, used to perform a calculation operation according to the horizontal movement distance and the vertical movement distance to obtain a sliding distance generated by the finger when dragging; The length and width acquisition module is used to obtain the length and width of the current canvas; A rotation direction determination module, used to perform a calculation operation according to the sliding distance to obtain a current rotation angle; A vertex coordinate acquisition module, used to obtain the vertex coordinates of the current canvas by calculating the display coordinates of the current canvas according to the length and width of the current canvas; A target coordinate calculation module, used for drawing and obtaining the vertex coordinates of the target canvas according to the vertex coordinates of the current canvas and the rotation angle; A horizontal and vertical screen switching module, used to replace the vertex coordinates of the target canvas with the vertex coordinates of the current canvas, and move based on the vertex coordinates of the target canvas to update the coordinate value of the display area to achieve horizontal and vertical screen switching; The step of obtaining the horizontal movement distance of the finger in the horizontal direction and the vertical movement distance of the finger in the vertical direction includes: Capture the action event when the finger touches the screen to determine whether the finger moves in the vertical and horizontal displacement directions; When it is determined that the finger is dragging the sliding window, the position coordinates of the finger at the start time of dragging and the position coordinates of the finger at the end time of dragging are obtained; Subtracting the position coordinates at the start time of dragging from the position coordinates at the end time of dragging to obtain a horizontal movement distance of the finger in the horizontal direction and a vertical movement distance of the finger in the vertical direction; The calculating operation is performed according to the horizontal moving distance and the vertical moving distance to obtain the sliding distance generated by the finger when dragging, including: Multiply the horizontal movement distance by the width of the screen, and multiply the vertical movement distance by the length of the screen to obtain a first horizontal X-axis offset distance and a first vertical Y-axis offset distance; A second horizontal X-axis offset distance and a second vertical Y-axis offset distance are obtained by subtracting the length of the layout from the first horizontal X-axis offset distance and subtracting the width of the layout from the first vertical Y-axis offset distance; The second horizontal X-axis offset distance and the second vertical Y-axis offset distance are the sliding distance; The screen width value and the screen length value are respectively the width and length of the screen of the display device, and are obtained by directly reading the display device parameters; The length value of the layout and the width value of the layout are respectively parameters obtained in the operation of obtaining the horizontal moving distance of the finger in the horizontal direction and the vertical moving distance of the finger in the vertical direction when the window is displaced by dragging the finger.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the method for switching between horizontal and vertical screens in software as claimed in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Dynamic display method and device of electronic signature, medium and product

    CN113722031A

  • Character recognition method and device based on direction correction, medium, equipment and product

    CN116012848A