blender/scripts/startup/bl_operators/touch.py
Dalai Felinto bbd3bb5ce1 iOS: Inward Edge Swipe Gestures
Supported gestures:
* Inwards left edge.
* Inwards right edge.

This calls an operator (screen.edge_swipe) which is supposed to handle
all edge swipes. At the moment it only works for the viewport to bring
the Tools and Properties Region in when in Focus Mode.

I could not get outwards edge swipe to work. It requires a regular pan
gesture, and it fights with other gestures (including the edge swipe).

Co-authored-by: Jonas Holzman <jonas@holzman.fr>
Pull Request: https://projects.blender.org/blender/blender/pulls/144849
2025-08-20 11:18:57 +02:00

57 lines
1.5 KiB
Python

# SPDX-FileCopyrightText: 2025 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
from __future__ import annotations
from bpy.types import Operator
from bpy.props import EnumProperty
class SCREEN_OT_edge_swipe(Operator):
"""Handle edge swipe (for touch screens)"""
bl_idname = "screen.edge_swipe"
bl_label = "Edge Swipe"
bl_options = {'REGISTER'}
direction: EnumProperty(
name='Direction',
description="Edge swipe direction",
items=(
('IN_LEFT', 'In Left', 'Inward edge swipe from the left edge'),
('IN_RIGHT', 'In Right', 'Inward edge swipe from the right edge'),
),
default='IN_LEFT',
options={'SKIP_SAVE'},
)
@classmethod
def poll(cls, context):
# Only run in the 3D viewport
if context.area is None or context.area.type != 'VIEW_3D':
return False
# Must be in fullscreen with panels hidden
if not context.screen.is_focus_mode:
return False
return True
def execute(self, context):
space = context.space_data
# Show the properties/tools region
if self.direction == 'IN_RIGHT':
space.show_region_ui = True
else:
space.show_region_toolbar = True
return {'FINISHED'}
classes = (
SCREEN_OT_edge_swipe,
)
if __name__ == "__main__": # Only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)