Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
nerrons
purr-data
Commits
996843f0
Commit
996843f0
authored
Mar 06, 2017
by
Jonathan Wilkes
Browse files
fix
#94
: ctrl-mousewheel doesn't zoom
parent
f8e34469
Changes
2
Show whitespace changes
Inline
Side-by-side
pd/nw/index.js
View file @
996843f0
...
@@ -87,6 +87,16 @@ function nw_window_focus_callback() {
...
@@ -87,6 +87,16 @@ function nw_window_focus_callback() {
}
}
}
}
// This should be merged with the same function name in pd_canvas.js,
// except that we're not saving the Pd Window zoomlevel anywhere
function
nw_window_zoom
(
delta
)
{
var
z
=
gui
.
Window
.
get
().
zoomLevel
;
z
+=
delta
;
if
(
z
<
8
&&
z
>
-
8
)
{
gui
.
Window
.
get
().
zoomLevel
=
z
;
}
}
function
connect
()
{
function
connect
()
{
var
gui_path
,
file_path
;
var
gui_path
,
file_path
;
if
(
have_args
()
&&
gui
.
App
.
argv
.
length
>
1
)
{
if
(
have_args
()
&&
gui
.
App
.
argv
.
length
>
1
)
{
...
@@ -323,6 +333,16 @@ function add_events() {
...
@@ -323,6 +333,16 @@ function add_events() {
gui
.
Window
.
get
().
on
(
"
focus
"
,
function
()
{
gui
.
Window
.
get
().
on
(
"
focus
"
,
function
()
{
nw_window_focus_callback
();
nw_window_focus_callback
();
});
});
// Pd Window zooming with mousewheel
document
.
addEventListener
(
"
wheel
"
,
function
(
evt
)
{
if
(
pdgui
.
cmd_or_ctrl_key
(
evt
))
{
if
(
evt
.
deltaY
<
0
)
{
nw_window_zoom
(
+
1
);
}
else
if
(
evt
.
deltaY
>
0
)
{
nw_window_zoom
(
-
1
);
}
}
},
false
);
// Open dialog
// Open dialog
document
.
getElementById
(
"
fileDialog
"
).
setAttribute
(
"
nwworkingdir
"
,
pwd
);
document
.
getElementById
(
"
fileDialog
"
).
setAttribute
(
"
nwworkingdir
"
,
pwd
);
document
.
getElementById
(
"
fileDialog
"
).
setAttribute
(
"
accept
"
,
document
.
getElementById
(
"
fileDialog
"
).
setAttribute
(
"
accept
"
,
...
@@ -593,16 +613,12 @@ function nw_create_pd_window_menus(gui, w) {
...
@@ -593,16 +613,12 @@ function nw_create_pd_window_menus(gui, w) {
// View menu
// View menu
minit
(
m
.
view
.
zoomin
,
{
minit
(
m
.
view
.
zoomin
,
{
click
:
function
()
{
click
:
function
()
{
var
z
=
gui
.
Window
.
get
().
zoomLevel
;
nw_window_zoom
(
+
1
);
if
(
z
<
8
)
{
z
++
;
}
gui
.
Window
.
get
().
zoomLevel
=
z
;
}
}
});
});
minit
(
m
.
view
.
zoomout
,
{
minit
(
m
.
view
.
zoomout
,
{
click
:
function
()
{
click
:
function
()
{
var
z
=
gui
.
Window
.
get
().
zoomLevel
;
nw_window_zoom
(
-
1
);
if
(
z
>
-
7
)
{
z
--
;
}
gui
.
Window
.
get
().
zoomLevel
=
z
;
}
}
});
});
minit
(
m
.
view
.
zoomreset
,
{
minit
(
m
.
view
.
zoomreset
,
{
...
...
pd/nw/pd_canvas.js
View file @
996843f0
...
@@ -122,6 +122,16 @@ function nw_window_blur_callback(name) {
...
@@ -122,6 +122,16 @@ function nw_window_blur_callback(name) {
}
}
}
}
function
nw_window_zoom
(
name
,
delta
)
{
var
z
=
gui
.
Window
.
get
().
zoomLevel
;
z
+=
delta
;
if
(
z
<
8
&&
z
>
-
8
)
{
gui
.
Window
.
get
().
zoomLevel
=
z
;
pdgui
.
pdsend
(
name
,
"
zoom
"
,
z
);
pdgui
.
gui_canvas_get_scroll
(
name
);
}
}
// These three functions need to be inside canvas_events closure
// These three functions need to be inside canvas_events closure
function
canvas_find_whole_word
(
elem
)
{
function
canvas_find_whole_word
(
elem
)
{
canvas_events
.
match_words
(
elem
.
checked
);
canvas_events
.
match_words
(
elem
.
checked
);
...
@@ -580,6 +590,15 @@ var canvas_events = (function() {
...
@@ -580,6 +590,15 @@ var canvas_events = (function() {
pdgui
.
pdsend
(
name
,
"
paste
"
);
pdgui
.
pdsend
(
name
,
"
paste
"
);
});
});
// MouseWheel event for zooming
document
.
addEventListener
(
"
wheel
"
,
function
(
evt
)
{
if
(
evt
.
deltaY
<
0
)
{
nw_window_zoom
(
name
,
+
1
);
}
else
if
(
evt
.
deltaY
>
0
)
{
nw_window_zoom
(
name
,
-
1
);
}
});
// The following is commented out because we have to set the
// The following is commented out because we have to set the
// event listener inside nw_create_pd_window_menus due to a
// event listener inside nw_create_pd_window_menus due to a
// bug with nwworkingdir
// bug with nwworkingdir
...
@@ -1265,21 +1284,13 @@ function nw_create_patch_window_menus(gui, w, name) {
...
@@ -1265,21 +1284,13 @@ function nw_create_patch_window_menus(gui, w, name) {
minit
(
m
.
view
.
zoomin
,
{
minit
(
m
.
view
.
zoomin
,
{
enabled
:
true
,
enabled
:
true
,
click
:
function
()
{
click
:
function
()
{
var
z
=
gui
.
Window
.
get
().
zoomLevel
;
nw_window_zoom
(
name
,
+
1
);
if
(
z
<
8
)
{
z
++
;
}
gui
.
Window
.
get
().
zoomLevel
=
z
;
pdgui
.
pdsend
(
name
,
"
zoom
"
,
z
);
pdgui
.
gui_canvas_get_scroll
(
name
);
}
}
});
});
minit
(
m
.
view
.
zoomout
,
{
minit
(
m
.
view
.
zoomout
,
{
enabled
:
true
,
enabled
:
true
,
click
:
function
()
{
click
:
function
()
{
var
z
=
gui
.
Window
.
get
().
zoomLevel
;
nw_window_zoom
(
name
,
-
1
);
if
(
z
>
-
7
)
{
z
--
;
}
gui
.
Window
.
get
().
zoomLevel
=
z
;
pdgui
.
pdsend
(
name
,
"
zoom
"
,
z
);
pdgui
.
gui_canvas_get_scroll
(
name
);
}
}
});
});
minit
(
m
.
view
.
optimalzoom
,
{
minit
(
m
.
view
.
optimalzoom
,
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment