Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
morpheus.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Daria Zenkova
morpheus.js
Commits
48a2fcd1
Commit
48a2fcd1
authored
May 17, 2016
by
Joshua Gould
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resize cursor tolerance
parent
64b3343f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
230 additions
and
228 deletions
+230
-228
src/ui/vector_track_header.js
src/ui/vector_track_header.js
+230
-228
No files found.
src/ui/vector_track_header.js
View file @
48a2fcd1
morpheus
.
VectorTrackHeader
=
function
(
project
,
name
,
isColumns
,
controller
)
{
morpheus
.
VectorTrackHeader
=
function
(
project
,
name
,
isColumns
,
controller
)
{
morpheus
.
AbstractCanvas
.
call
(
this
);
this
.
project
=
project
;
this
.
name
=
name
;
...
...
@@ -16,38 +16,40 @@ morpheus.VectorTrackHeader = function(project, name, isColumns, controller) {
var
_this
=
this
;
this
.
setBounds
({
height
:
this
.
defaultFontHeight
height
:
this
.
defaultFontHeight
+
morpheus
.
VectorTrackHeader
.
FONT_OFFSET
});
function
getResizeCursor
(
pos
)
{
if
(
isColumns
)
{
if
(
pos
.
y
>=
(
_this
.
getUnscaledHeight
()
-
3
))
{
if
(
pos
.
y
<
3
||
pos
.
y
>=
(
_this
.
getUnscaledHeight
()
-
3
))
{
return
'
ns-resize
'
;
}
}
if
(
pos
.
x
>=
(
_this
.
getUnscaledWidth
()
-
3
))
{
if
(
pos
.
x
<
3
||
pos
.
x
>=
(
_this
.
getUnscaledWidth
()
-
3
))
{
return
'
ew-resize
'
;
}
}
var
mouseMove
=
function
(
event
)
{
var
mouseMove
=
function
(
event
)
{
if
(
!
morpheus
.
CanvasUtil
.
dragging
)
{
var
pos
=
morpheus
.
CanvasUtil
.
getMousePos
(
event
.
target
,
event
);
var
cursor
=
getResizeCursor
(
pos
);
canvas
.
style
.
cursor
=
!
cursor
?
'
default
'
:
cursor
;
//document.body.style.cursor = !cursor ? 'default' : cursor;
_this
.
isMouseOver
=
true
;
_this
.
repaint
();
}
};
var
mouseExit
=
function
(
e
)
{
var
mouseExit
=
function
(
e
)
{
if
(
!
morpheus
.
CanvasUtil
.
dragging
)
{
canvas
.
style
.
cursor
=
'
default
'
;
}
_this
.
isMouseOver
=
false
;
_this
.
repaint
();
};
var
showPopup
=
function
(
e
)
{
var
showPopup
=
function
(
e
)
{
controller
.
setSelectedTrack
(
_this
.
name
,
isColumns
);
var
track
=
controller
.
getTrack
(
_this
.
name
,
isColumns
);
if
(
!
track
)
{
...
...
@@ -65,7 +67,7 @@ morpheus.VectorTrackHeader = function(project, name, isColumns, controller) {
};
this
.
selectedBackgroundColor
=
'
#c8c8c8
'
;
this
.
backgroundColor
=
'
#f9f9f9
'
;
$
(
this
.
canvas
).
css
(
'
background-color
'
,
this
.
backgroundColor
).
on
(
$
(
this
.
canvas
).
css
(
{
'
background-color
'
:
this
.
backgroundColor
}
).
on
(
'
mousemove.morpheus
'
,
mouseMove
).
on
(
'
mouseout.morpheus
'
,
mouseExit
)
.
on
(
'
mouseenter.morpheus
'
,
mouseMove
);
...
...
@@ -84,8 +86,8 @@ morpheus.VectorTrackHeader = function(project, name, isColumns, controller) {
// }, 100);
// $(canvas).on('mouseout', throttled).on('mousemove', throttled);
this
.
hammer
=
morpheus
.
Util
.
hammer
(
canvas
,
[
'
pan
'
,
'
tap
'
,
'
longpress
'
])
.
on
(
'
longpress
'
,
function
(
event
)
{
.
hammer
(
canvas
,
[
'
pan
'
,
'
tap
'
,
'
longpress
'
])
.
on
(
'
longpress
'
,
function
(
event
)
{
event
.
preventDefault
();
controller
.
setSelectedTrack
(
_this
.
name
,
isColumns
);
var
track
=
controller
.
getTrack
(
_this
.
name
,
isColumns
);
...
...
@@ -93,7 +95,7 @@ morpheus.VectorTrackHeader = function(project, name, isColumns, controller) {
})
.
on
(
'
panend
'
,
function
(
event
)
{
function
(
event
)
{
_this
.
isMouseOver
=
false
;
morpheus
.
CanvasUtil
.
dragging
=
false
;
canvas
.
style
.
cursor
=
'
default
'
;
...
...
@@ -110,7 +112,7 @@ morpheus.VectorTrackHeader = function(project, name, isColumns, controller) {
})
.
on
(
'
panstart
'
,
function
(
event
)
{
function
(
event
)
{
_this
.
isMouseOver
=
false
;
if
(
morpheus
.
CanvasUtil
.
dragging
)
{
return
;
...
...
@@ -147,7 +149,7 @@ morpheus.VectorTrackHeader = function(project, name, isColumns, controller) {
})
.
on
(
'
panmove
'
,
function
(
event
)
{
function
(
event
)
{
_this
.
isMouseOver
=
false
;
if
(
resizeCursor
)
{
var
width
;
...
...
@@ -219,7 +221,7 @@ morpheus.VectorTrackHeader = function(project, name, isColumns, controller) {
})
.
on
(
'
tap
'
,
function
(
event
)
{
function
(
event
)
{
if
(
morpheus
.
Util
.
IS_MAC
&&
event
.
srcEvent
.
ctrlKey
)
{
// right-click
return
;
}
...
...
@@ -268,17 +270,17 @@ morpheus.VectorTrackHeader = function(project, name, isColumns, controller) {
};
morpheus
.
VectorTrackHeader
.
FONT_OFFSET
=
2
;
morpheus
.
VectorTrackHeader
.
prototype
=
{
selected
:
false
,
isMouseOver
:
false
,
defaultFontHeight
:
11
,
dispose
:
function
()
{
selected
:
false
,
isMouseOver
:
false
,
defaultFontHeight
:
11
,
dispose
:
function
()
{
morpheus
.
AbstractCanvas
.
prototype
.
dispose
.
call
(
this
);
$
(
this
.
canvas
)
.
off
(
'
contextmenu.morpheus mousemove.morpheus mouseout.morpheus mouseenter.morpheus
'
);
this
.
hammer
.
destroy
();
},
getPreferredSize
:
function
()
{
getPreferredSize
:
function
()
{
var
size
=
this
.
getPrintSize
();
size
.
width
+=
22
;
...
...
@@ -304,21 +306,21 @@ morpheus.VectorTrackHeader.prototype = {
// }
return
size
;
},
getPrintSize
:
function
()
{
getPrintSize
:
function
()
{
var
context
=
this
.
canvas
.
getContext
(
'
2d
'
);
context
.
font
=
this
.
defaultFontHeight
+
'
px
'
+
morpheus
.
CanvasUtil
.
FONT_NAME
;
var
width
=
4
+
context
.
measureText
(
this
.
name
).
width
;
return
{
width
:
width
,
height
:
this
.
getUnscaledHeight
()
width
:
width
,
height
:
this
.
getUnscaledHeight
()
};
},
getSortKeys
:
function
()
{
getSortKeys
:
function
()
{
return
this
.
isColumns
?
this
.
project
.
getColumnSortKeys
()
:
this
.
project
.
getRowSortKeys
();
},
setOrder
:
function
(
sortKeys
)
{
setOrder
:
function
(
sortKeys
)
{
if
(
this
.
isColumns
)
{
this
.
project
.
setColumnSortKeys
(
morpheus
.
SortKey
.
keepExistingSortKeys
(
sortKeys
,
this
.
project
...
...
@@ -328,7 +330,7 @@ morpheus.VectorTrackHeader.prototype = {
sortKeys
,
this
.
project
.
getRowSortKeys
()),
false
);
}
},
setGroupBy
:
function
(
groupBy
)
{
setGroupBy
:
function
(
groupBy
)
{
var
existingGroupBy
=
this
.
isColumns
?
this
.
project
.
groupColumns
:
this
.
project
.
groupRows
;
// see if already exists, if so remove it
...
...
@@ -339,7 +341,7 @@ morpheus.VectorTrackHeader.prototype = {
break
;
}
}
var
newGroupBy
=
[
groupBy
];
var
newGroupBy
=
[
groupBy
];
if
(
index
!==
-
1
)
{
newGroupBy
=
existingGroupBy
;
newGroupBy
.
splice
(
index
,
1
);
...
...
@@ -350,18 +352,18 @@ morpheus.VectorTrackHeader.prototype = {
this
.
project
.
setGroupRows
(
newGroupBy
,
true
);
}
},
setSelected
:
function
(
selected
)
{
setSelected
:
function
(
selected
)
{
if
(
selected
!=
this
.
selected
)
{
this
.
selected
=
selected
;
$
(
this
.
canvas
)
.
css
(
{
'
background-color
'
:
this
.
selected
?
this
.
selectedBackgroundColor
'
background-color
'
:
this
.
selected
?
this
.
selectedBackgroundColor
:
this
.
backgroundColor
});
}
},
setSortingStatus
:
function
(
sortKeys
,
sortKey
,
additionalSort
,
isGroupBy
)
{
setSortingStatus
:
function
(
sortKeys
,
sortKey
,
additionalSort
,
isGroupBy
)
{
if
(
!
isGroupBy
)
{
if
(
sortKey
.
getSortOrder
()
==
morpheus
.
SortKey
.
SortOrder
.
UNSORTED
&&
!
additionalSort
)
{
...
...
@@ -371,7 +373,7 @@ morpheus.VectorTrackHeader.prototype = {
additionalSort
=
false
;
}
if
(
!
additionalSort
)
{
sortKeys
=
[
sortKey
];
sortKeys
=
[
sortKey
];
}
else
{
var
sortKeyIndex
=
this
.
getSortKeyIndexForColumnName
(
sortKeys
,
sortKey
.
toString
());
...
...
@@ -394,7 +396,7 @@ morpheus.VectorTrackHeader.prototype = {
}
}
},
getSortKeyIndexForColumnName
:
function
(
sortKeys
,
columnName
)
{
getSortKeyIndexForColumnName
:
function
(
sortKeys
,
columnName
)
{
if
(
sortKeys
!=
null
)
{
for
(
var
i
=
0
,
size
=
sortKeys
.
length
;
i
<
size
;
i
++
)
{
if
(
columnName
===
sortKeys
[
i
].
toString
())
{
...
...
@@ -404,7 +406,7 @@ morpheus.VectorTrackHeader.prototype = {
}
return
-
1
;
},
print
:
function
(
clip
,
context
)
{
print
:
function
(
clip
,
context
)
{
if
(
clip
.
height
<=
6
)
{
return
;
}
...
...
@@ -422,7 +424,7 @@ morpheus.VectorTrackHeader.prototype = {
context
.
fillStyle
=
morpheus
.
CanvasUtil
.
FONT_COLOR
;
context
.
fillText
(
this
.
name
,
0
,
0
);
},
draw
:
function
(
clip
,
context
)
{
draw
:
function
(
clip
,
context
)
{
var
sortKeys
=
this
.
getSortKeys
();
var
name
=
this
.
name
;
var
existingSortKeyIndex
=
this
.
getSortKeyIndexForColumnName
(
sortKeys
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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