Gesture-based zoom control method and device, equipment and storage medium
By detecting and calculating touch data in the zoom gesture on the touch screen, determining the target zoom magnification and applying it to the object to be scaled, the "empty stroke" problem of the zoom gesture when reaching the limit magnification in the prior art is solved, and the user experience is improved.
Patent Information
- Application Number
- CN202411447148.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-02-25
AI Technical Summary
The existing zoom gesture implementation method is prone to "empty stroke" when the object to be scaled reaches the maximum or minimum limit magnification, reducing the user experience.
By detecting the touch data of the current touch event on the touch screen, the first scaling factor of the current touch event and the second scaling factor of the last touch event are determined, the target scaling magnification is calculated, and the object to be scaled according to the magnification is scaled to ensure that the user gesture operations can be effectively identified and applied.
It effectively avoids the "empty stroke" phenomenon when the zoom gesture reaches the limit magnification, improves the real-time and accuracy of the zoom gesture operation, thereby improving the user experience.
Smart Images

Figure CN119512432A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of touch technology, and in particular to a gesture-based zoom control method, device, equipment and storage medium. Background Art
[0002] With the rapid development of touch technology, touch screen devices have become the mainstream interactive interface of modern electronic products, and are widely used in smart phones, tablet computers, e-book readers and various intelligent display terminals. On these devices, users interact with the devices through touch gestures, among which the zoom gesture is one of the common operations used by users to adjust the size of the content displayed on the screen (such as pictures, documents, maps, etc.).
[0003] In the traditional implementation of zoom gestures, when a user pinches or spreads his fingers on the touch screen, the system captures a series of touch events and infers the user's zoom intention based on the change in distance between touch focal points, thereby achieving zooming of the content displayed on the screen.
[0004] However, in the traditional method, when the current zoom ratio of the object to be zoomed reaches its maximum limit ratio or minimum limit ratio, it is easy for the user to continue to perform the zoom gesture without producing any actual zoom effect. This phenomenon is also called the "empty stroke" phenomenon, which not only reduces the user experience, but also may cause the user to mistakenly believe that the device has failed or is responding slowly. Summary of the invention
[0005] The present application provides a gesture-based zoom control method, device, equipment and storage medium to solve the technical problem that in the existing zoom gesture implementation method, when the current zoom magnification of the object to be zoomed reaches its maximum limit magnification or minimum limit magnification, the "empty travel" phenomenon is easily caused, thereby reducing the user experience.
[0006] In a first aspect, the present application provides a gesture-based zoom control method, the method comprising:
[0007] During a zoom gesture action on the touch screen, detecting a touch event currently triggered on the touch screen, and acquiring touch data generated by the current touch event;
[0008] determining a first scaling factor corresponding to the current touch event according to the touch data;
[0009] Obtaining a second scaling factor corresponding to a previous touch event of the current touch event;
[0010] determining a target zoom factor according to the first zoom factor and the second zoom factor;
[0011] The object to be scaled displayed on the touch screen is scaled according to the target scaling factor.
[0012] In a possible implementation manner, determining a target zoom ratio according to the first zoom factor and the second zoom factor includes:
[0013] Subtracting the first scaling factor from the second scaling factor to obtain a scaling factor increment of the current touch event compared to the previous touch event;
[0014] Obtaining the current zoom ratio of the object to be zoomed;
[0015] A target zoom factor is determined according to the zoom factor increment and a current zoom factor of the object to be zoomed.
[0016] In a possible implementation, the acquiring a second scaling factor corresponding to a previous touch event of the current touch event includes:
[0017] Acquire a current value of a first preset variable, and determine the current value of the first preset variable as a second scaling factor corresponding to a touch event previous to the current touch event;
[0018] The value of the first preset variable is updated in the following manner:
[0019] After the target zoom ratio is determined according to the first zoom factor and the second zoom factor each time, the value of the first preset variable is updated to the first zoom factor.
[0020] In a possible implementation manner, scaling the object to be scaled displayed on the touch screen according to the target scaling factor includes:
[0021] Comparing the target zoom ratio with a preset zoom ratio range;
[0022] In the case where it is found that the target zoom ratio falls within the zoom ratio range, the target zoom ratio is determined as an effective zoom ratio, and the object to be zoomed displayed on the touch screen is zoomed according to the effective zoom ratio;
[0023] In the case where it is found that the target zoom ratio exceeds the zoom ratio range, an effective zoom ratio is determined according to the zoom ratio range, and the object to be zoomed displayed on the touch screen is zoomed according to the effective zoom ratio.
[0024] In a possible implementation manner, determining the effective zoom ratio according to the zoom ratio range includes:
[0025] In a case where the target zoom ratio is greater than a maximum limit ratio of the zoom ratio range, determining the maximum limit ratio as an effective zoom ratio;
[0026] When the target zoom magnification is smaller than a minimum limit magnification of the zoom magnification range, the minimum limit magnification is determined as the effective zoom magnification.
[0027] In a possible implementation, the touch data includes position information on the touch screen of two or more touch focuses formed by the current touch event on the touch screen; and determining the first scaling factor corresponding to the current touch event according to the touch data includes:
[0028] determining a first virtual circle according to position information of a touch focus corresponding to the current touch event on the touch screen;
[0029] determining a second virtual circle according to position information of a touch focus corresponding to the first touch event on the touch screen;
[0030] The diameter of the first virtual circle is divided by the diameter of the second virtual circle to obtain a first scaling factor corresponding to the current touch event.
[0031] In a possible implementation manner, obtaining the current zoom factor of the object to be zoomed includes:
[0032] Acquire a current value of a second preset variable, and determine the current value of the second preset variable as a current zoom ratio of the object to be zoomed;
[0033] The value of the second preset variable is updated in the following manner:
[0034] After the object to be scaled displayed on the touch screen is scaled according to the target scaling factor each time, the value of the second preset variable is updated to the current scaling factor of the object to be scaled.
[0035] In a second aspect, an embodiment of the present application provides a gesture-based zoom control device, the device comprising:
[0036] A trigger module, used for acquiring a touch event currently triggered on the touch screen and acquiring touch data generated by the current touch event during a process of detecting a pinch gesture occurring on the touch screen;
[0037] A first factor determination module, configured to determine a first scaling factor corresponding to the current touch event according to the touch data;
[0038] A second factor determination module, used to obtain a second scaling factor corresponding to a touch event previous to the current touch event;
[0039] a target determination module, configured to determine a target zoom factor according to the first zoom factor and the second zoom factor;
[0040] The zoom processing module is used to zoom the object to be zoomed displayed on the touch screen according to the target zoom ratio.
[0041] In a possible implementation, the target determination module includes:
[0042] an increment calculation unit, configured to subtract the first scaling factor from the second scaling factor to obtain a scaling factor increment of the current touch event compared to the previous touch event;
[0043] A current magnification acquisition unit, used to acquire the current magnification of the object to be zoomed;
[0044] The target magnification determination unit is used to determine the target magnification according to the zoom factor increment and the current zoom magnification of the object to be zoomed.
[0045] In a possible implementation manner, the second factor determination module is specifically configured to:
[0046] Acquire a current value of a first preset variable, and determine the current value of the first preset variable as a second scaling factor corresponding to a touch event previous to the current touch event;
[0047] The device also includes:
[0048] A first updating module is used to update the value of the first preset variable in the following manner:
[0049] After the target zoom ratio is determined according to the first zoom factor and the second zoom factor each time, the value of the first preset variable is updated to the first zoom factor.
[0050] In a possible implementation, the scaling processing module includes:
[0051] A comparison unit, configured to compare the target zoom ratio with a preset zoom ratio range;
[0052] A first scaling unit, configured to determine the target scaling ratio as a valid scaling ratio when it is compared that the target scaling ratio falls within the scaling ratio range, and scale the object to be scaled displayed on the touch screen according to the valid scaling ratio;
[0053] The second scaling unit is configured to determine an effective scaling ratio according to the scaling ratio range if it is found that the target scaling ratio exceeds the scaling ratio range, and scale the object to be scaled displayed on the touch screen according to the effective scaling ratio.
[0054] In a possible implementation manner, the second scaling unit is specifically configured to:
[0055] In a case where the target zoom ratio is greater than a maximum limit ratio of the zoom ratio range, determining the maximum limit ratio as an effective zoom ratio;
[0056] When the target zoom magnification is smaller than a minimum limit magnification of the zoom magnification range, the minimum limit magnification is determined as the effective zoom magnification.
[0057] In a possible implementation manner, the touch data includes position information on the touch screen of two or more touch focuses formed by the current touch event on the touch screen; and the first factor determination module includes:
[0058] A first virtual circle forming unit, configured to determine a first virtual circle according to position information of a touch focus corresponding to the current touch event on the touch screen;
[0059] A second virtual circle forming unit, configured to determine a second virtual circle according to position information of a touch focus corresponding to a first touch event on the touch screen;
[0060] The first factor calculation unit is configured to divide the diameter of the first virtual circle by the diameter of the second virtual circle to obtain a first scaling factor corresponding to the current touch event.
[0061] In a possible implementation manner, the current magnification acquisition unit is specifically used to:
[0062] Acquire a current value of a second preset variable, and determine the current value of the second preset variable as a current zoom ratio of the object to be zoomed;
[0063] The device also includes:
[0064] The second updating module is configured to update the value of the second preset variable to the current zoom ratio of the object to be zoomed after the object to be zoomed displayed on the touch screen is zoomed according to the target zoom ratio each time.
[0065] In a third aspect, the present application provides a device, comprising: a processor and a memory, wherein the processor is used to execute a gesture-based zoom control program stored in the memory to implement the gesture-based zoom control method described in any one of the first aspects.
[0066] In a fourth aspect, the present application provides a storage medium storing one or more programs, wherein the one or more programs can be executed by one or more processors to implement the gesture-based zoom control method described in any one of the first aspects.
[0067] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application, by detecting the touch event currently triggered on the touch screen during a zoom gesture action occurring on the touch screen, and obtaining touch data generated by the current touch event, determining a first zoom factor corresponding to the current touch event according to the touch data of the current touch event, obtaining a second zoom factor corresponding to the last touch event of the current touch event, determining a target zoom ratio according to the first zoom factor and the second zoom factor, and zooming the object to be zoomed displayed on the touch screen according to the target zoom ratio, thereby achieving zooming of the object to be zoomed according to the increment between the zoom ratios intended to be achieved by the current touch event and the last touch event. In this way, even if the object to be zoomed has reached its zoom limit, the user's zoom gesture operation can still be effectively recognized and applied to the object to be zoomed, thereby solving the problem of "empty travel" in the user operation when the zoom limit is reached, improving the real-time and accuracy of the zoom gesture operation, and thus improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0069] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0070] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0071] Figure 1 A schematic diagram of the "empty travel" phenomenon that occurs in a traditional zoom gesture implementation;
[0072] Figure 2 A flowchart of an embodiment of a gesture-based zoom control method provided in an embodiment of the present application;
[0073] Figure 3 A schematic diagram of a touch focus on a touch screen for a touch event;
[0074] Figure 4 A flowchart of another embodiment of a gesture-based zoom control method provided in an embodiment of the present application;
[0075] Figure 5 A flowchart of an embodiment of scaling an object to be scaled displayed on a touch screen according to a target scaling ratio;
[0076] Figure 6 A block diagram of an embodiment of a gesture-based zoom control device provided in an embodiment of the present application;
[0077] Figure 7 A schematic diagram of the structure of a device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0078] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0079] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0080] In the zoom gesture application scenario, there are usually the following requirements: (1) The control responds to zooming in time when the user makes a zoom gesture; (2) Each time a zoom action is completed, the control needs to maintain the current zoom ratio, and the next zoom action is based on the current zoom ratio for incremental zooming; (3) The control has a limited zoom ratio range, such as 0.8X-2X, where 0.8X is the minimum limit ratio, indicating that the control can only be reduced to a minimum of 0.8 times, and 2X is the maximum limit ratio, indicating that the control can only be enlarged to a maximum of 2 times. In actual applications, affected by factors such as different hardware and different system versions, the zoom ratio range of the control is not a fixed value. For example, the maximum limit ratio of a 6-inch mobile phone is 6X, and the maximum limit ratio of a 13-inch tablet is 10X. The embodiments of the present application do not limit this.
[0081] In the traditional implementation of zoom gestures, the zoom factor (i.e., zoom ratio) is calculated as follows:
[0082] The expected zoom ratio of this zoom action = current zoom factor - 1 + the zoom ratio of the object to be zoomed last time Formula (I)
[0083] Among them, the current zoom factor is determined based on the touch focus formed on the touch screen by the current zoom action and the touch focus formed on the screen by the zoom action at the beginning of this zoom process. 1 represents the zoom ratio of the object to be zoomed at the beginning of this zoom process. At this time, the object to be zoomed is neither enlarged nor reduced, so the zoom ratio is 1.
[0084] In a simple zooming scenario, applying a traditional zooming gesture implementation method can usually smoothly and accurately obtain the zooming effect expected by the user. For example, assuming that the zooming gesture action made by the user is: two fingers touching the screen -> two fingers sliding and spreading on the screen -> two fingers lifting, in this process, the actual display effect of the object to be zoomed is: as the two fingers slide and spread on the screen, the object to be zoomed will start to zoom in from the initial state (here it is assumed to be 1 magnification, that is, the object to be zoomed is neither enlarged nor reduced) until the two fingers are lifted, or the object to be zoomed is enlarged to the maximum limit magnification, such as 2 magnification. For another example, assuming that the zooming gesture action made by the user is: two fingers touching the screen -> two fingers sliding and closing on the screen -> two fingers lifting, in this process, the actual display effect of the object to be zoomed is: as the two fingers slide and close on the screen, the object to be zoomed will start to zoom out from the initial state (here it is assumed to be 1 magnification, that is, the object to be zoomed is neither enlarged nor reduced) until the two fingers are lifted, or the object to be zoomed is zoomed to the minimum limit magnification, such as 0.8 magnification.
[0085] However, in some complex zooming scenarios, the "empty travel" phenomenon may occur when applying traditional zoom gesture implementation methods.
[0086] For example, suppose the zoom gesture performed by the user is: two fingers touch the screen -> two fingers slide open on the screen -> two fingers slide together on the screen -> two fingers lift up. In this process, the actual display effect of the object to be zoomed is:
[0087] Phase 1: As two fingers slide and open on the screen, the object to be scaled will start to be enlarged from the initial state (here it is assumed to be 1x, that is, the object to be scaled is neither enlarged nor reduced), and it is assumed to be enlarged to 2x;
[0088] Stage 2: As the two fingers continue to slide and open on the screen, the current zoom factor will be greater than 2. According to the calculation method shown in the above formula (1), the expected zoom ratio calculated at this time is still greater than 2. Since the object to be zoomed has been enlarged to the maximum allowed limit ratio (for example, 2), the object to be zoomed will maintain the current zoom ratio unchanged, and its display effect will not change.
[0089] Stage 3: As two fingers begin to slide together on the screen, there is a period of motion (such as Figure 1 The current zoom factor shown in the example is within the action range from 3X to 2X) and the current zoom factor is greater than 2. According to the calculation method shown in the above formula (1), the expected zoom ratio calculated within this action range is still greater than 2. However, since the object to be zoomed has been enlarged to the maximum allowed limit ratio (for example, 2), the object to be zoomed will maintain the current zoom ratio unchanged, and its display effect will not change.
[0090] It can be seen that in the above stage three, the object to be scaled fails to respond to the user's two-finger-to-one action to produce a reduced display effect, which produces the "empty travel phenomenon".
[0091] For another example, suppose the zoom gesture performed by the user is: two fingers touch the screen -> two fingers slide together on the screen -> two fingers slide apart on the screen -> two fingers lift up. In this process, the actual display effect of the object to be zoomed is:
[0092] Phase 1: As two fingers slide together on the screen, the object to be scaled will start to shrink from the initial state (here it is assumed to be 1x, that is, the object to be scaled is neither enlarged nor reduced), and it is assumed to be reduced to 0.8x;
[0093] Stage 2: As the two fingers continue to slide and close together on the screen, since the object to be scaled has been reduced to the minimum allowed limit magnification (for example, 0.8 magnification), the object to be scaled will maintain the current magnification unchanged, and its display effect will not change.
[0094] Stage 3: As two fingers begin to slide and open on the screen. Figure 1 The expected zoom ratio calculated within the action range from 0.8X to 1X in the current zoom factor shown in the example is less than 0.8x, but since the object to be zoomed has been reduced to the minimum allowed limit ratio at this time, the object to be zoomed will maintain the current zoom ratio unchanged, and its display effect will not change.
[0095] It can be seen that in the above stage three, the object to be zoomed fails to respond to the two-finger pinching action made by the user to produce an enlarged display effect, which produces the "empty travel phenomenon".
[0096] In order to solve the technical problem that, in the prior art of implementing zoom gestures, when the current zoom ratio of the object to be zoomed reaches its maximum limit ratio or minimum limit ratio, the "empty stroke" phenomenon is likely to occur, thereby reducing the user experience, the present application provides a gesture-based zoom control method, device, equipment and storage medium, which can solve the problem of "empty stroke" in user operations when the zoom limit is reached, improve the real-time and accuracy of zoom gesture operations, and improve user experience.
[0097] Figure 2 The flowchart of an embodiment of a gesture-based zoom control method provided in the embodiment of the present application. In one embodiment, the method is applied to a device, which can be a variety of electronic devices that support touch screens, including but not limited to smart phones, tablet computers, e-book readers, and various smart display terminals. Figure 2 As shown, the method comprises the following steps:
[0098] Step 201: During a zoom gesture action on the touch screen, a touch event currently triggered on the touch screen is detected, and touch data generated by the current touch event is acquired.
[0099] The zoom gesture is usually two fingers (or multiple fingers) sliding open or sliding together on the touch screen, which is used to trigger a zoom instruction for the object to be zoomed displayed on the touch screen. Among them, the object to be zoomed is a View control displayed on the touch screen, which can be a combination of one or more views. Two fingers (or multiple fingers) sliding open on the touch screen is used to trigger a zoom-in instruction, and two fingers (or multiple fingers) sliding together on the touch screen is used to trigger a zoom-out instruction. It can also be seen from this that the user's zoom gesture action on the touch screen is a continuous process. The starting point of the process is that the user touches the screen with two or more fingers, and the end point is that the user's fingers leave the screen. In this process, the user's fingers will continue to touch the screen, which means that in this process, the touch screen will continue to receive and process a series of touch events.
[0100] In one embodiment, in order to identify and process touch events occurring during a zoom gesture on the touch screen, a touch event listener is set on a relevant view of the application, and the touch event listener is responsible for monitoring and responding to touch events occurring on the touch screen. Optionally, the touch event listener is implemented by setting one or more touch event monitoring interfaces (such as the onTouch interface in the OnTouchListener class on the Android platform) for the view.
[0101] Based on the above description, in the technical solution provided in the embodiment of the present application, during the process of a zoom gesture action occurring on the touch screen, the touch events triggered on the touch screen will be continuously detected. Each time a currently triggered touch event is detected, step 101 and subsequent steps will be executed to ensure the accuracy and smoothness of the zoom operation.
[0102] In the technical solution provided by the embodiment of the present application, a touch event currently triggered on the touch screen is detected, and touch data generated by the current touch event is obtained. The touch data includes position information of two or more touch focuses formed on the touch screen by the current touch event. Optionally, the position information is represented by coordinate information, that is, coordinate information of the touch focus on the coordinate system corresponding to the touch screen.
[0103] See also Figure 3 , which is a schematic diagram of a touch event touching the focus on a touch screen. Figure 3 The example of sliding and spreading two fingers on the touch screen is used to illustrate the change of touch focus when the zoom gesture starts and ends. Figure 3 In the figure, touch focus 1 and touch focus 2 are touch focuses when the zoom gesture action starts, and touch focus 3 and touch focus 4 are touch focuses when the zoom gesture action ends.
[0104] Step 202: Determine a first scaling factor corresponding to the current touch event according to the touch data.
[0105] The zoom factor corresponding to the current touch event (hereinafter referred to as the first zoom factor for ease of description) is used to represent the zoom ratio (also referred to as the zoom ratio) that the user intends to achieve through the current touch event. It should be noted that the zoom ratio here is relative to the zoom ratio maintained by the object to be zoomed at the start of the zoom gesture action, and the zoom ratio here is only the zoom ratio that the user intends to achieve, not the zoom ratio to be ultimately achieved.
[0106] In one embodiment, a specific implementation of determining the first scaling factor corresponding to the current touch event based on the touch data of the current touch event includes: determining a first virtual circle based on the position information of the touch focus corresponding to the current touch event on the touch screen; determining a second virtual circle based on the position information of the touch focus corresponding to the first touch event on the touch screen; and dividing the diameter of the first virtual circle by the diameter of the second virtual circle to obtain the first scaling factor corresponding to the current touch event.
[0107] The first touch event mentioned above refers to the touch event at the beginning of the zoom gesture action. This is the first touch event detected when the zoom gesture action occurs on the touch screen, so it is called the first touch event.
[0108] by Figure 3For example, the first touch event corresponds to touch focus 1 and touch focus 2, and the current touch event corresponds to touch focus 3 and touch focus 4. According to the above description, the first virtual circle 5 is determined according to touch focus 3 and touch focus 4, and the second virtual circle 6 is determined according to touch focus 1 and touch focus 2. Then, the diameter of the first virtual circle 5 and the diameter of the second virtual circle are substituted into the following formula (II) to obtain the first scaling factor corresponding to the current touch event.
[0109] scaleFactor=mCurrSpan÷mPrevSpan formula (2)
[0110] In the above formula (II), scaleFactor represents the first scaling factor corresponding to the current touch event, mCurrSpan represents the diameter of the first virtual circle, and mPrevSpan represents the diameter of the second virtual circle.
[0111] pass Figure 3 It can be seen that when the user slides two fingers on the touch screen, the distance between the touch points corresponding to the two fingers increases, and the diameter of the virtual circle formed by the touch points also increases. Therefore, the first zoom factor is greater than 1, which means that the user intends to enlarge the object to be zoomed through the current touch event.
[0112] Similarly, when the user slides two fingers together on the touch screen, the distance between the touch points corresponding to the two fingers is reduced, and the diameter of the virtual circle formed by the touch points is also reduced. Therefore, the first zoom factor is less than 1, which means that the user intends to reduce the object to be zoomed through the current touch event.
[0113] As an optional implementation method, the virtual circle formed by the touch focus is determined by the following steps: the horizontal coordinates and vertical coordinates of two or more touch focuses (for example, touch focus 1 and touch focus 2) are added respectively, and then the addition result is divided by the number of touch focuses to obtain the average horizontal coordinate and the average vertical coordinate, and the location of the average horizontal coordinate and the average vertical coordinate is determined as the center point. Then, the distance from each touch point to the center point is calculated, and the maximum distance is found, and the maximum distance is regarded as the radius of the virtual circle. Finally, the above center point is used as the center of the virtual circle, and a virtual circle is determined with the maximum distance as the radius.
[0114] The above implementation is only an exemplary implementation of determining the virtual circle formed by the touch focus. In practical applications, there may be other implementations, for example, determining the average value of the distances from two or more touch focuses to the center point as the radius of the virtual circle. The present application embodiment does not limit this.
[0115] Step 203: Obtain a second scaling factor corresponding to the previous touch event of the current touch event.
[0116] The zoom factor corresponding to the last touch event of the current touch event (hereinafter referred to as the second zoom factor for the convenience of description) is used to indicate the zoom ratio that the user intends to achieve through the last touch event.
[0117] In order to obtain the scaling factor corresponding to the last touch event at present, the scaling factor corresponding to each trigger event can be saved. Among them, as an optional implementation method, a variable (hereinafter referred to as the first preset variable for convenience of description) is predefined, such as the variable name mLastScaleFactor, and the first preset variable is used to record the scaling factor corresponding to each trigger event, and is updated at an appropriate time to achieve that at the triggering moment of the current touch event, the first preset variable records the second scaling factor corresponding to the last touch event. Then, when obtaining the second scaling factor corresponding to the last touch event of the current touch event, the current value of the first preset variable can be obtained, and the current value of the first preset variable is determined as the second scaling factor corresponding to the last touch event of the current touch event. Optionally, the above-mentioned appropriate time is: after each determination of the target zoom ratio according to the first scaling factor and the second scaling factor, the value of the first preset variable is updated to the first scaling factor. The initial value of the first preset variable is 1, and the first preset variable is reset to 1 each time the finger starts to touch the screen.
[0118] The above implementation is only an exemplary implementation to ensure that the zoom factor corresponding to the last touch event can be obtained. In practical applications, there may be other methods, for example, the event number of each touch event and the corresponding zoom factor are recorded in association, and when obtaining the second zoom factor corresponding to the last touch event of the current touch event, the associated zoom factor can be found based on the event number of the last touch event. The embodiments of the present application are not limited to this.
[0119] As for the specific calculation process of the second scaling factor, please refer to the description in step 202, which will not be repeated here.
[0120] Step 204: Determine a target zoom factor according to the first zoom factor and the second zoom factor.
[0121] Step 205: Scale the object to be scaled displayed on the touch screen according to the target scaling factor.
[0122] It can be seen from the description of step 204 and step 205 that, different from the calculation method of the current zoom factor in the prior art, in the technical solution provided by the embodiment of the present application, the target zoom ratio applied to the object to be zoomed displayed on the touch screen is determined based on the first zoom factor and the second zoom factor, which means that the target zoom ratio is determined based on the increment between the zoom ratios intended to be achieved by the current touch event and the previous touch event. This method can effectively avoid the phenomenon of "empty travel" of the zoom gesture.
[0123] For example, suppose the zoom gesture performed by the user is: two fingers touch the screen -> two fingers slide open on the screen -> two fingers slide together on the screen -> two fingers lift up. In this process, the actual display effect of the object to be zoomed is:
[0124] Phase 1: As two fingers slide and open on the screen, the object to be scaled will start to be enlarged from the initial state (here it is assumed to be 1x, that is, the object to be scaled is neither enlarged nor reduced), and it is assumed to be enlarged to 2x;
[0125] Stage 2: As the two fingers continue to slide and spread on the screen, since the object to be scaled has been enlarged to the maximum allowed limit magnification (for example, 2 times), the object to be scaled will maintain the current magnification unchanged, and its display effect will not change.
[0126] Stage 3: As two fingers start to slide and move together on the screen, even if the first zoom factor corresponding to the current touch event may exceed 2, since the target zoom ratio is determined based on the incremental zoom ratio between the current touch event and the previous touch event, and the current stage is the two-finger-moving-together stage, the incremental zoom ratio between the current touch event and the previous touch event is a negative value, which means that the zoom ratio will be reduced based on the current zoom ratio of the object to be zoomed, so that the object to be zoomed will appear to be reduced in size.
[0127] It can be seen that in the above stage three, the object to be zoomed can still respond promptly to the user's two-finger pinching action to produce a zoomed-out display effect, thereby solving the problem in the prior art that when the object to be zoomed has been enlarged to the maximum allowed limit, the user's two-finger sliding action has "empty travel".
[0128] For another example, suppose the zoom gesture performed by the user is: two fingers touch the screen -> two fingers slide together on the screen -> two fingers slide apart on the screen -> two fingers lift up. In this process, the actual display effect of the object to be zoomed is:
[0129] Phase 1: As two fingers slide together on the screen, the object to be scaled will start to shrink from the initial state (here it is assumed to be 1x, that is, the object to be scaled is neither enlarged nor reduced), and it is assumed to be reduced to 0.8x;
[0130] Stage 2: As the two fingers continue to slide and close together on the screen, since the object to be scaled has been reduced to the minimum allowed limit magnification (for example, 0.8 magnification), the object to be scaled will maintain the current magnification unchanged, and its display effect will not change.
[0131] Stage three: As two fingers begin to slide and spread on the screen, even if the first zoom factor corresponding to the current touch event may still be lower than 0.8, since the target zoom factor is determined based on the incremental zoom factor between the current touch event and the previous touch event, and the current stage is the two-finger spread stage, the incremental zoom factor between the current touch event and the previous touch event is a positive value, which means that the zoom factor will be increased based on the current zoom factor of the object to be scaled, so that the object to be scaled will appear to be enlarged.
[0132] It can be seen that in the above stage three, the object to be zoomed can still respond promptly to the user's two-finger sliding and expanding action to produce an enlarged display effect, thereby solving the problem of "empty travel" in the prior art when the object to be zoomed has been reduced to the minimum allowed limit ratio and the two-finger sliding and expanding action performed by the user has a problem.
[0133] The technical solution provided by the embodiment of the present application detects the touch event currently triggered on the touch screen during a zoom gesture action occurring on the touch screen, and obtains touch data generated by the current touch event, determines a first zoom factor corresponding to the current touch event according to the touch data of the current touch event, obtains a second zoom factor corresponding to the last touch event of the current touch event, determines a target zoom ratio according to the first zoom factor and the second zoom factor, and zooms the object to be zoomed displayed on the touch screen according to the target zoom ratio, thereby achieving zooming of the object to be zoomed according to the increment between the zoom ratios intended to be achieved by the current touch event and its last touch event. In this way, even if the object to be zoomed has reached its zoom limit, the user's zoom gesture operation can still be effectively recognized and applied to the object to be zoomed, thereby solving the problem of "empty travel" in the user operation when the zoom limit is reached, improving the real-time and accuracy of the zoom gesture operation, and thus improving the user experience.
[0134] Figure 4 A flowchart of another embodiment of a gesture-based zoom control method provided in an embodiment of the present application. Figure 4 The process shown in Figure 2 Based on the process shown in FIG. 1 , the specific implementation of determining the target zoom ratio according to the first zoom factor and the second zoom factor is described in detail. Figure 4 As shown, the following steps are included:
[0135] Step 401: During a zoom gesture on the touch screen, a touch event currently triggered on the touch screen is detected, and touch data generated by the current touch event is acquired.
[0136] Step 402: Determine a first scaling factor corresponding to the current touch event according to the touch data.
[0137] For detailed description of step 401 and step 402, please refer to the relevant description in the above embodiment, which will not be repeated here.
[0138] Step 403: Obtain a second zoom factor corresponding to a touch event previous to the current touch event, and obtain a current zoom ratio of the object to be zoomed.
[0139] In one embodiment, a variable (hereinafter referred to as the second preset variable for convenience of description) is predefined, such as the variable name mLastZoom, and the second preset variable is used to record the magnification of the object to be scaled after the zoom magnification of the object to be scaled is updated based on the touch event each time a touch event is triggered. Based on this, each time the object to be scaled displayed on the touch screen is scaled according to the target zoom magnification, the value of the second preset variable is updated to the current zoom magnification of the object to be scaled. Then, when the current zoom magnification of the object to be scaled is obtained, the current value of the second preset variable can be obtained, and the current value of the second preset variable is determined as the current zoom magnification of the object to be scaled.
[0140] Step 404: Subtract the first scaling factor from the second scaling factor to obtain a scaling factor increment of the current touch event compared to the previous touch event.
[0141] Step 405: Determine a target zoom ratio according to the zoom factor increment and the current zoom ratio of the object to be zoomed.
[0142] The specific implementation of the above steps 404 and 405 can be expressed as the following formula (III):
[0143] expectScaleFactor=(scaleFactor-mLastScaleFactor)+mLastZoom
[0144] Formula (III)
[0145] In the above formula (III), expectScaleFactor is the target scaling factor, scaleFactor is the first scaling factor, mLastScaleFactor is the first preset variable, i.e., the second scaling factor, mLastZoom is the second preset variable, i.e., the current scaling factor of the object to be scaled, and (scaleFactor-mLastScaleFactor) is the scaling factor increment of the current touch event compared to the previous touch event.
[0146] It can be seen from formula (III) that each time a touch event is triggered, the current zoom factor of the object to be zoomed will be adjusted by the zoom factor increment of the current touch event compared to the previous touch event. This adjustment mechanism can solve the problem of "empty travel" in the zoom gesture action made by the user when the actual zoom factor of the object to be zoomed has reached the limit factor (maximum limit factor or minimum limit factor), thereby improving the real-time and accuracy of the zoom gesture operation, and further improving the user experience.
[0147] Step 406: Scale the object to be scaled displayed on the touch screen according to the target scaling factor.
[0148] It can be seen from the above description that in actual applications, due to factors such as hardware and system version, the object to be scaled has a limited zoom ratio range. Therefore, in step 406, it is not appropriate to directly apply the target zoom ratio to the object to be scaled.
[0149] In this regard, it is proposed Figure 5 As shown in the process. Figure 5 FIG. 1 is a flow chart of an embodiment of scaling an object to be scaled displayed on a touch screen according to a target scaling ratio. The process includes the following steps:
[0150] Step 4061, compare the target zoom ratio with the preset zoom ratio range; if the comparison shows that the target zoom ratio falls within the zoom ratio range, execute step 4062; if the comparison shows that the target zoom ratio exceeds the zoom ratio range and is greater than the maximum limit ratio of the zoom ratio range, execute step 4063; if the comparison shows that the target zoom ratio exceeds the zoom ratio range and is less than the minimum limit ratio of the zoom ratio range, execute step 4064.
[0151] Step 4062 , determine the target zoom ratio as the effective zoom ratio; execute step 3055 .
[0152] Step 4063, determine the maximum limit magnification as the effective zoom magnification; execute step 3055.
[0153] Step 4064: determine the minimum limit magnification as the effective zoom magnification.
[0154] Step 4065: Scale the object to be scaled displayed on the touch screen according to the effective zoom ratio.
[0155] The zoom ratio range is used to limit the zoom ratio of the object to be zoomed. For example, if the zoom ratio range is 0.8X-2X, 0.8X is the minimum limit ratio, which means that the control can only be reduced to 0.8 times, and 2X is the maximum limit ratio, which means that the control can only be enlarged to 2 times.
[0156] Based on this, the target zoom ratio is first compared with the preset zoom ratio range. If the target zoom ratio falls within the zoom ratio range, it means that the object to be zoomed is allowed to be zoomed to the target zoom ratio, so the target zoom ratio can be determined as the effective zoom ratio, and then the effective zoom ratio is applied to the object to be zoomed. If the target zoom ratio exceeds the zoom ratio range, it means that the object to be zoomed is not allowed to be zoomed to the target zoom ratio, and the effective zoom ratio can be determined according to the zoom ratio range.
[0157] Wherein, when it is compared that the target zoom ratio exceeds the zoom ratio range and is greater than the maximum limit ratio of the zoom ratio range, the maximum limit ratio is determined as the effective zoom ratio, and then the effective zoom ratio is applied to the object to be zoomed. When it is compared that the target zoom ratio exceeds the zoom ratio range and is less than the minimum limit ratio of the zoom ratio range, the minimum limit ratio is determined as the effective zoom ratio, and then the effective zoom ratio is applied to the object to be zoomed.
[0158] Figure 5 The process shown can meet the requirement in actual applications that the object to be scaled needs to be kept within a certain limited zoom ratio range due to factors such as hardware and system version.
[0159] Figure 4 The process shown in Figure 2 On the basis of the shown process, a specific implementation method is provided for zooming the object to be zoomed according to the increment between the zoom ratio intended to be achieved by the current touch event and its previous touch event. In this way, even if the object to be zoomed has reached its zoom limit, the user's zoom gesture operation can still be effectively recognized and applied to the object to be zoomed, thereby solving the problem of "empty travel" in user operations when the zoom limit is reached, improving the real-time and accuracy of the zoom gesture operation, and thus improving the user experience.
[0160] Figure 6 This is a block diagram of an embodiment of a gesture-based zoom control device provided in an embodiment of the present application. Figure 6 As shown, the device comprises:
[0161] The trigger module 61 is used to obtain the touch event currently triggered on the touch screen and the touch data generated by the current touch event during the process of detecting the pinch gesture on the touch screen;
[0162] A first factor determination module 62, configured to determine a first scaling factor corresponding to the current touch event according to the touch data;
[0163] A second factor determination module 63, used to obtain a second scaling factor corresponding to a touch event previous to the current touch event;
[0164] A target determination module 64, configured to determine a target zoom factor according to the first zoom factor and the second zoom factor;
[0165] The zoom processing module 65 is used to zoom the object to be zoomed displayed on the touch screen according to the target zoom ratio.
[0166] In a possible implementation, the target determination module 64 includes:
[0167] an increment calculation unit, configured to subtract the first scaling factor from the second scaling factor to obtain a scaling factor increment of the current touch event compared to the previous touch event;
[0168] A current magnification acquisition unit, used to acquire the current magnification of the object to be zoomed;
[0169] The target magnification determination unit is used to determine the target magnification according to the zoom factor increment and the current zoom magnification of the object to be zoomed.
[0170] In a possible implementation manner, the second factor determination module 63 is specifically configured to:
[0171] Acquire a current value of a first preset variable, and determine the current value of the first preset variable as a second scaling factor corresponding to a touch event previous to the current touch event;
[0172] The device also includes:
[0173] A first updating module is used to update the value of the first preset variable in the following manner:
[0174] After the target zoom ratio is determined according to the first zoom factor and the second zoom factor each time, the value of the first preset variable is updated to the first zoom factor.
[0175] In a possible implementation, the scaling processing module 65 includes:
[0176] A comparison unit, configured to compare the target zoom ratio with a preset zoom ratio range;
[0177] A first scaling unit, configured to determine the target scaling ratio as a valid scaling ratio when it is compared that the target scaling ratio falls within the scaling ratio range, and scale the object to be scaled displayed on the touch screen according to the valid scaling ratio;
[0178] The second scaling unit is configured to determine an effective scaling ratio according to the scaling ratio range if it is found that the target scaling ratio exceeds the scaling ratio range, and scale the object to be scaled displayed on the touch screen according to the effective scaling ratio.
[0179] In a possible implementation manner, the second scaling unit is specifically configured to:
[0180] In a case where the target zoom ratio is greater than a maximum limit ratio of the zoom ratio range, determining the maximum limit ratio as an effective zoom ratio;
[0181] When the target zoom magnification is smaller than a minimum limit magnification of the zoom magnification range, the minimum limit magnification is determined as the effective zoom magnification.
[0182] In a possible implementation manner, the touch data includes position information on the touch screen of two or more touch focuses formed by the current touch event on the touch screen; and the first factor determination module includes:
[0183] A first virtual circle forming unit, configured to determine a first virtual circle according to position information of a touch focus corresponding to the current touch event on the touch screen;
[0184] A second virtual circle forming unit, configured to determine a second virtual circle according to position information of a touch focus corresponding to a first touch event on the touch screen;
[0185] The first factor calculation unit is configured to divide the diameter of the first virtual circle by the diameter of the second virtual circle to obtain a first scaling factor corresponding to the current touch event.
[0186] In a possible implementation manner, the current magnification acquisition unit is specifically used to:
[0187] Acquire a current value of a second preset variable, and determine the current value of the second preset variable as a current zoom ratio of the object to be zoomed;
[0188] The device also includes:
[0189] The second updating module is configured to update the value of the second preset variable to the current zoom ratio of the object to be zoomed after the object to be zoomed displayed on the touch screen is zoomed according to the target zoom ratio each time.
[0190] like Figure 7 As shown, an embodiment of the present application provides a device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0191] Memory 113, used for storing computer programs;
[0192] In one embodiment of the present application, the processor 111 is used to execute the program stored in the memory 113 to implement the gesture-based zoom control method provided by any of the above method embodiments, including:
[0193] During a zoom gesture action on the touch screen, detecting a touch event currently triggered on the touch screen, and acquiring touch data generated by the current touch event;
[0194] determining a first scaling factor corresponding to the current touch event according to the touch data;
[0195] Obtaining a second scaling factor corresponding to a previous touch event of the current touch event;
[0196] determining a target zoom factor according to the first zoom factor and the second zoom factor;
[0197] The object to be scaled displayed on the touch screen is scaled according to the target scaling factor.
[0198] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the gesture-based zoom control method provided in any of the aforementioned method embodiments are implemented.
[0199] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0200] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0201] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0202] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A gesture-based zoom control method, characterized in that: The method comprises: During a zoom gesture action on the touch screen, detecting a touch event currently triggered on the touch screen, and acquiring touch data generated by the current touch event; determining a first scaling factor corresponding to the current touch event according to the touch data; Obtaining a second scaling factor corresponding to a previous touch event of the current touch event; determining a target zoom factor according to the first zoom factor and the second zoom factor; The object to be scaled displayed on the touch screen is scaled according to the target scaling factor.
2. The method according to claim 1, characterized in that The determining a target zoom ratio according to the first zoom factor and the second zoom factor includes: Subtracting the first scaling factor from the second scaling factor to obtain a scaling factor increment of the current touch event compared to the previous touch event; Obtaining the current zoom ratio of the object to be zoomed; A target zoom factor is determined according to the zoom factor increment and a current zoom factor of the object to be zoomed.
3. The method according to claim 1, characterized in that The obtaining a second scaling factor corresponding to a previous touch event of the current touch event includes: Acquire a current value of a first preset variable, and determine the current value of the first preset variable as a second scaling factor corresponding to a touch event previous to the current touch event; The value of the first preset variable is updated in the following manner: After the target zoom ratio is determined according to the first zoom factor and the second zoom factor each time, the value of the first preset variable is updated to the first zoom factor.
4. The method according to claim 1, characterized in that: Scaling the object to be scaled displayed on the touch screen according to the target zoom ratio includes: Comparing the target zoom ratio with a preset zoom ratio range; In the case where it is found that the target zoom ratio falls within the zoom ratio range, the target zoom ratio is determined as an effective zoom ratio, and the object to be zoomed displayed on the touch screen is zoomed according to the effective zoom ratio; In the case where it is found that the target zoom ratio exceeds the zoom ratio range, an effective zoom ratio is determined according to the zoom ratio range, and the object to be zoomed displayed on the touch screen is zoomed according to the effective zoom ratio.
5. The method according to claim 4, characterized in that The determining the effective zoom ratio according to the zoom ratio range includes: In a case where the target zoom ratio is greater than a maximum limit ratio of the zoom ratio range, determining the maximum limit ratio as an effective zoom ratio; When the target zoom magnification is smaller than a minimum limit magnification of the zoom magnification range, the minimum limit magnification is determined as the effective zoom magnification.
6. The method according to claim 1, characterized in that The touch data includes position information on the touch screen of two or more touch focuses formed by the current touch event on the touch screen; The determining, according to the touch data, a first scaling factor corresponding to the current touch event includes: determining a first virtual circle according to position information of a touch focus corresponding to the current touch event on the touch screen; determining a second virtual circle according to position information of a touch focus corresponding to the first touch event on the touch screen; The diameter of the first virtual circle is divided by the diameter of the second virtual circle to obtain a first scaling factor corresponding to the current touch event.
7. The method according to claim 2, characterized in that The obtaining the current zoom ratio of the object to be zoomed includes: Acquire a current value of a second preset variable, and determine the current value of the second preset variable as a current zoom ratio of the object to be zoomed; The value of the second preset variable is updated in the following manner: After the object to be scaled displayed on the touch screen is scaled according to the target scaling factor each time, the value of the second preset variable is updated to the current scaling factor of the object to be scaled.
8. A gesture-based zoom control device, characterized in that: The device comprises: A trigger module, used for acquiring a touch event currently triggered on the touch screen and acquiring touch data generated by the current touch event during a process of detecting a pinch gesture occurring on the touch screen; A first factor determination module, configured to determine a first scaling factor corresponding to the current touch event according to the touch data; A second factor determination module, used to obtain a second scaling factor corresponding to a touch event previous to the current touch event; a target determination module, configured to determine a target zoom factor according to the first zoom factor and the second zoom factor; The zoom processing module is used to zoom the object to be zoomed displayed on the touch screen according to the target zoom ratio.
9. A device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a gesture-based zoom control program stored in the memory to implement the gesture-based zoom control method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the gesture-based zoom control method described in any one of claims 1-7.
Citation Information
Patent Citations
Page scaling method and device
CN104866202A
Operation device
CN108475173A
Element scaling control method, device and equipment and storage medium
CN110286827A
Gesture zooming control method and device for touch equipment and related equipment
CN110286840A
View component adjusting method, equipment and medium
CN115700476A