Skip to content

Commit

Permalink
add setting for pinch to zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Feb 10, 2024
1 parent b11f9f9 commit 4756145
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
16 changes: 12 additions & 4 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
"type": "bool",
"default": true,
"name": "Zoom Towards Cursor",
"description": "When enabled and while holding down the CTRL key, zooming in the editor with the scroll wheel will be zoomed toward the cursor and not the center of the screen"
"description": "When enabled and while holding down the CTRL key, zooming in the editor with the scroll wheel will be zoomed toward the cursor and not the center of the screen",
"platforms": ["windows", "macos"]
},
"better-font-select": {
"pinch-to-zoom": {
"type": "bool",
"default": true,
"name": "Better Font Select",
"description": "Replaces the old font select screen with a better one with scrolling"
"name": "Pinch to Zoom",
"description": "When enabled, you can use two fingers to zoom",
"platforms": ["android32", "android64"]
},
"scale-factor": {
"type": "float",
Expand All @@ -61,6 +63,12 @@
"name": "Scale Build Tabs",
"description": "Whether the tabs above the object selection area should be scaled according to the scale factor aswell"
},
"better-font-select": {
"type": "bool",
"default": true,
"name": "New Font Selection Menu",
"description": "Replaces the old font select screen with a better one with scrolling"
},
"new-color-menu": {
"type": "bool",
"default": true,
Expand Down
12 changes: 12 additions & 0 deletions src/features/PinchToZoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class $modify(EditorUI) {

$override
bool ccTouchBegan(CCTouch* touch, CCEvent* event) override {
if (!Mod::get()->getSettingValue<bool>("pinch-to-zoom")) {
return EditorUI::ccTouchBegan(touch, event);
}
if (m_fields->touches.size() == 1 || EditorUI::ccTouchBegan(touch, event)) {
m_fields->touches.insert(touch);
return true;
Expand All @@ -26,6 +29,9 @@ class $modify(EditorUI) {

$override
void ccTouchMoved(CCTouch* touch, CCEvent* event) override {
if (!Mod::get()->getSettingValue<bool>("pinch-to-zoom")) {
return EditorUI::ccTouchMoved(touch, event);
}
if (m_fields->touches.size() == 2) {
// thanks https://math.stackexchange.com/questions/4408515/calculate-coordinates-after-pinch-to-zoom-gesture!!

Expand Down Expand Up @@ -76,12 +82,18 @@ class $modify(EditorUI) {

$override
void ccTouchEnded(CCTouch* touch, CCEvent* event) override {
if (!Mod::get()->getSettingValue<bool>("pinch-to-zoom")) {
return EditorUI::ccTouchEnded(touch, event);
}
EditorUI::ccTouchEnded(touch, event);
m_fields->touches.erase(touch);
}

$override
void ccTouchCancelled(CCTouch* touch, CCEvent* event) override {
if (!Mod::get()->getSettingValue<bool>("pinch-to-zoom")) {
return EditorUI::ccTouchCancelled(touch, event);
}
EditorUI::ccTouchCancelled(touch, event);
m_fields->touches.erase(touch);
}
Expand Down

0 comments on commit 4756145

Please sign in to comment.