Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
ede63636
Commit
ede63636
authored
Apr 28, 2015
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify workspace resizing.
parent
89d1aafd
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
39 deletions
+48
-39
blockly_compressed.js
blockly_compressed.js
+13
-12
core/blockly.js
core/blockly.js
+1
-4
core/flyout.js
core/flyout.js
+2
-7
core/inject.js
core/inject.js
+4
-2
core/toolbox.js
core/toolbox.js
+8
-9
core/trashcan.js
core/trashcan.js
+2
-5
core/workspace_svg.js
core/workspace_svg.js
+18
-0
No files found.
blockly_compressed.js
View file @
ede63636
This diff is collapsed.
Click to expand it.
core/blockly.js
View file @
ede63636
...
@@ -264,10 +264,7 @@ Blockly.svgResize = function(workspace) {
...
@@ -264,10 +264,7 @@ Blockly.svgResize = function(workspace) {
svg
.
setAttribute
(
'
height
'
,
height
+
'
px
'
);
svg
.
setAttribute
(
'
height
'
,
height
+
'
px
'
);
svg
.
cachedHeight_
=
height
;
svg
.
cachedHeight_
=
height
;
}
}
// Update the scrollbars (if they exist).
mainWorkspace
.
resize
();
if
(
mainWorkspace
.
scrollbar
)
{
mainWorkspace
.
scrollbar
.
resize
();
}
};
};
/**
/**
...
...
core/flyout.js
View file @
ede63636
...
@@ -138,10 +138,6 @@ Blockly.Flyout.prototype.init = function(workspace) {
...
@@ -138,10 +138,6 @@ Blockly.Flyout.prototype.init = function(workspace) {
this
.
hide
();
this
.
hide
();
// If the document resizes, reposition the flyout.
this
.
eventWrappers_
.
concat
(
Blockly
.
bindEvent_
(
window
,
goog
.
events
.
EventType
.
RESIZE
,
this
,
this
.
position_
));
this
.
position_
();
this
.
eventWrappers_
.
concat
(
Blockly
.
bindEvent_
(
this
.
svgGroup_
,
this
.
eventWrappers_
.
concat
(
Blockly
.
bindEvent_
(
this
.
svgGroup_
,
'
wheel
'
,
this
,
this
.
wheel_
));
'
wheel
'
,
this
,
this
.
wheel_
));
// Safari needs mousewheel.
// Safari needs mousewheel.
...
@@ -234,9 +230,8 @@ Blockly.Flyout.prototype.setMetrics_ = function(yRatio) {
...
@@ -234,9 +230,8 @@ Blockly.Flyout.prototype.setMetrics_ = function(yRatio) {
/**
/**
* Move the toolbox to the edge of the workspace.
* Move the toolbox to the edge of the workspace.
* @private
*/
*/
Blockly
.
Flyout
.
prototype
.
position
_
=
function
()
{
Blockly
.
Flyout
.
prototype
.
position
=
function
()
{
if
(
!
this
.
isVisible
())
{
if
(
!
this
.
isVisible
())
{
return
;
return
;
}
}
...
@@ -489,7 +484,7 @@ Blockly.Flyout.prototype.reflow = function() {
...
@@ -489,7 +484,7 @@ Blockly.Flyout.prototype.reflow = function() {
block
.
flyoutRect_
.
setAttribute
(
'
y
'
,
blockXY
.
y
);
block
.
flyoutRect_
.
setAttribute
(
'
y
'
,
blockXY
.
y
);
}
}
}
}
// Record the width for .getMetrics_ and .position
_
.
// Record the width for .getMetrics_ and .position.
this
.
width_
=
flyoutWidth
;
this
.
width_
=
flyoutWidth
;
// Fire a resize event to update the flyout's scrollbar.
// Fire a resize event to update the flyout's scrollbar.
Blockly
.
fireUiEvent
(
window
,
'
resize
'
);
Blockly
.
fireUiEvent
(
window
,
'
resize
'
);
...
...
core/inject.js
View file @
ede63636
...
@@ -285,11 +285,13 @@ Blockly.createDom_ = function(container, options) {
...
@@ -285,11 +285,13 @@ Blockly.createDom_ = function(container, options) {
<rect width="1" height="1" stroke="#888" />
<rect width="1" height="1" stroke="#888" />
</pattern>
</pattern>
*/
*/
// MSIE freaks if it sees a 0x0 pattern, so set empty patterns to 100x100.
var
safeSpacing
=
options
.
gridOptions
[
'
spacing
'
]
||
100
;
var
gridPattern
=
Blockly
.
createSvgElement
(
'
pattern
'
,
var
gridPattern
=
Blockly
.
createSvgElement
(
'
pattern
'
,
{
'
id
'
:
'
blocklyGridPattern
'
+
String
(
Math
.
random
()).
substring
(
2
),
{
'
id
'
:
'
blocklyGridPattern
'
+
String
(
Math
.
random
()).
substring
(
2
),
'
patternUnits
'
:
'
userSpaceOnUse
'
,
'
patternUnits
'
:
'
userSpaceOnUse
'
,
'
width
'
:
options
.
gridOptions
[
'
spacing
'
]
||
100
,
'
width
'
:
safeSpacing
,
'
height
'
:
options
.
gridOptions
[
'
spacing
'
]
||
100
},
defs
);
'
height
'
:
safeSpacing
},
defs
);
if
(
options
.
gridOptions
[
'
length
'
]
>
0
&&
options
.
gridOptions
[
'
spacing
'
]
>
0
)
{
if
(
options
.
gridOptions
[
'
length
'
]
>
0
&&
options
.
gridOptions
[
'
spacing
'
]
>
0
)
{
var
half
=
Math
.
floor
(
options
.
gridOptions
[
'
spacing
'
]
/
2
)
+
.
5
;
var
half
=
Math
.
floor
(
options
.
gridOptions
[
'
spacing
'
]
/
2
)
+
.
5
;
var
start
=
half
-
options
.
gridOptions
[
'
length
'
]
/
2
;
var
start
=
half
-
options
.
gridOptions
[
'
length
'
]
/
2
;
...
...
core/toolbox.js
View file @
ede63636
...
@@ -138,21 +138,19 @@ Blockly.Toolbox.prototype.init = function() {
...
@@ -138,21 +138,19 @@ Blockly.Toolbox.prototype.init = function() {
this
.
HtmlDiv
.
style
.
display
=
'
block
'
;
this
.
HtmlDiv
.
style
.
display
=
'
block
'
;
this
.
populate_
(
workspace
.
options
.
languageTree
);
this
.
populate_
(
workspace
.
options
.
languageTree
);
tree
.
render
(
this
.
HtmlDiv
);
tree
.
render
(
this
.
HtmlDiv
);
this
.
position
();
// If the document resizes, reposition the toolbox.
var
thisToolbox
=
this
;
goog
.
events
.
listen
(
window
,
goog
.
events
.
EventType
.
RESIZE
,
function
()
{
thisToolbox
.
position_
();});
this
.
position_
();
};
};
/**
/**
* Move the toolbox to the edge.
* Move the toolbox to the edge.
* @private
*/
*/
Blockly
.
Toolbox
.
prototype
.
position_
=
function
()
{
Blockly
.
Toolbox
.
prototype
.
position
=
function
()
{
var
svg
=
this
.
workspace_
.
options
.
svg
;
var
treeDiv
=
this
.
HtmlDiv
;
var
treeDiv
=
this
.
HtmlDiv
;
if
(
!
treeDiv
)
{
// Not initialized yet.
return
;
}
var
svg
=
this
.
workspace_
.
options
.
svg
;
var
svgBox
=
goog
.
style
.
getBorderBox
(
svg
);
var
svgBox
=
goog
.
style
.
getBorderBox
(
svg
);
var
svgSize
=
Blockly
.
svgSize
(
svg
);
var
svgSize
=
Blockly
.
svgSize
(
svg
);
if
(
this
.
workspace_
.
RTL
)
{
if
(
this
.
workspace_
.
RTL
)
{
...
@@ -167,6 +165,7 @@ Blockly.Toolbox.prototype.position_ = function() {
...
@@ -167,6 +165,7 @@ Blockly.Toolbox.prototype.position_ = function() {
// For some reason the LTR toolbox now reports as 1px too wide.
// For some reason the LTR toolbox now reports as 1px too wide.
this
.
width
-=
1
;
this
.
width
-=
1
;
}
}
this
.
flyout_
.
position
();
};
};
/**
/**
...
...
core/trashcan.js
View file @
ede63636
...
@@ -201,8 +201,6 @@ Blockly.Trashcan.prototype.createDom = function() {
...
@@ -201,8 +201,6 @@ Blockly.Trashcan.prototype.createDom = function() {
*/
*/
Blockly
.
Trashcan
.
prototype
.
init
=
function
()
{
Blockly
.
Trashcan
.
prototype
.
init
=
function
()
{
this
.
setOpen_
(
false
);
this
.
setOpen_
(
false
);
// If the document resizes, reposition the trash can.
Blockly
.
bindEvent_
(
window
,
'
resize
'
,
this
,
this
.
position_
);
};
};
/**
/**
...
@@ -221,9 +219,8 @@ Blockly.Trashcan.prototype.dispose = function() {
...
@@ -221,9 +219,8 @@ Blockly.Trashcan.prototype.dispose = function() {
/**
/**
* Move the trash can to the bottom-right corner.
* Move the trash can to the bottom-right corner.
* @private
*/
*/
Blockly
.
Trashcan
.
prototype
.
position
_
=
function
()
{
Blockly
.
Trashcan
.
prototype
.
position
=
function
()
{
var
metrics
=
this
.
workspace_
.
getMetrics
();
var
metrics
=
this
.
workspace_
.
getMetrics
();
if
(
!
metrics
)
{
if
(
!
metrics
)
{
// There are no metrics available (workspace is probably not visible).
// There are no metrics available (workspace is probably not visible).
...
@@ -242,7 +239,7 @@ Blockly.Trashcan.prototype.position_ = function() {
...
@@ -242,7 +239,7 @@ Blockly.Trashcan.prototype.position_ = function() {
};
};
/**
/**
* Return the deletion rectangle for this trashcan.
* Return the deletion rectangle for this trash
can.
* @return {goog.math.Rect} Rectangle in which to delete.
* @return {goog.math.Rect} Rectangle in which to delete.
*/
*/
Blockly
.
Trashcan
.
prototype
.
getRect
=
function
()
{
Blockly
.
Trashcan
.
prototype
.
getRect
=
function
()
{
...
...
core/workspace_svg.js
View file @
ede63636
...
@@ -198,6 +198,24 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function() {
...
@@ -198,6 +198,24 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function() {
this
.
svgGroup_
.
insertBefore
(
svgFlyout
,
this
.
svgBlockCanvas_
);
this
.
svgGroup_
.
insertBefore
(
svgFlyout
,
this
.
svgBlockCanvas_
);
};
};
/**
* Resize this workspace and its containing objects.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
resize
=
function
()
{
if
(
this
.
toolbox_
)
{
this
.
toolbox_
.
position
();
}
if
(
this
.
flyout_
)
{
this
.
flyout_
.
position
();
}
if
(
this
.
trashcan
)
{
this
.
trashcan
.
position
();
}
if
(
this
.
scrollbar
)
{
this
.
scrollbar
.
resize
();
}
};
/**
/**
* Get the SVG element that forms the drawing surface.
* Get the SVG element that forms the drawing surface.
* @return {!Element} SVG element.
* @return {!Element} SVG element.
...
...
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