Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
BlocksCAD
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
BlocksCAD
Commits
0de301dc
Commit
0de301dc
authored
Sep 18, 2015
by
Jennie Yoder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
incremental commit, non-functional
parent
4f3de14e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
14 deletions
+50
-14
blockly/blocks/primitives.js
blockly/blocks/primitives.js
+8
-2
blockly/core/field_checkbox.js
blockly/core/field_checkbox.js
+38
-7
blockly/core/xml.js
blockly/core/xml.js
+4
-5
No files found.
blockly/blocks/primitives.js
View file @
0de301dc
...
@@ -47,13 +47,19 @@ Blockly.Blocks['cylinder'] = {
...
@@ -47,13 +47,19 @@ Blockly.Blocks['cylinder'] = {
this
.
appendDummyInput
()
this
.
appendDummyInput
()
.
setAlign
(
Blockly
.
ALIGN_RIGHT
)
.
setAlign
(
Blockly
.
ALIGN_RIGHT
)
.
appendField
(
new
Blockly
.
FieldImage
(
"
lock_icon.png
"
,
15
,
15
,
"
*
"
))
.
appendField
(
new
Blockly
.
FieldImage
(
"
lock_icon.png
"
,
15
,
15
,
"
*
"
))
.
appendField
(
new
Blockly
.
FieldCheckbox
(
"
FALSE
"
),
"
LOCKED
"
);
.
appendField
(
new
Blockly
.
FieldCheckbox
(
"
FALSE
"
,
function
(
newState
)
{
if
(
newState
)
console
.
log
(
"
I'm checked
"
);
else
console
.
log
(
"
I'm not checked
"
);
}),
"
LOCKED
"
);
}
}
else
{
else
{
this
.
appendDummyInput
()
this
.
appendDummyInput
()
.
setAlign
(
Blockly
.
ALIGN_RIGHT
)
.
setAlign
(
Blockly
.
ALIGN_RIGHT
)
.
appendField
(
new
Blockly
.
FieldImage
(
"
lock_icon.png
"
,
15
,
15
,
"
*
"
))
.
appendField
(
new
Blockly
.
FieldImage
(
"
lock_icon.png
"
,
15
,
15
,
"
*
"
))
.
appendField
(
new
Blockly
.
FieldCheckbox
(
"
TRUE
"
),
"
LOCKED
"
);
.
appendField
(
new
Blockly
.
FieldCheckbox
(
"
TRUE
"
,
function
(
newState
)
{
if
(
newState
)
console
.
log
(
"
I'm checked
"
);
else
console
.
log
(
"
I'm not checked
"
);
}),
"
LOCKED
"
);
}
}
this
.
appendValueInput
(
'
RAD2
'
)
this
.
appendValueInput
(
'
RAD2
'
)
.
setCheck
(
'
Number
'
)
.
setCheck
(
'
Number
'
)
...
...
blockly/core/field_checkbox.js
View file @
0de301dc
...
@@ -39,9 +39,13 @@ goog.require('Blockly.Field');
...
@@ -39,9 +39,13 @@ goog.require('Blockly.Field');
* @extends {Blockly.Field}
* @extends {Blockly.Field}
* @constructor
* @constructor
*/
*/
Blockly
.
FieldCheckbox
=
function
(
state
,
opt_changeHandler
)
{
Blockly
.
FieldCheckbox
=
function
(
state
,
opt_changeHandler
,
img1
,
img2
)
{
Blockly
.
FieldCheckbox
.
superClass_
.
constructor
.
call
(
this
,
''
);
Blockly
.
FieldCheckbox
.
superClass_
.
constructor
.
call
(
this
,
''
);
// do I have two images?
if
(
img1
&&
img2
)
{
this
.
img1
=
img1
;
this
.
img2
=
img2
;
}
this
.
setChangeHandler
(
opt_changeHandler
);
this
.
setChangeHandler
(
opt_changeHandler
);
// Set the initial state.
// Set the initial state.
this
.
setValue
(
state
);
this
.
setValue
(
state
);
...
@@ -65,11 +69,33 @@ Blockly.FieldCheckbox.prototype.init = function(block) {
...
@@ -65,11 +69,33 @@ Blockly.FieldCheckbox.prototype.init = function(block) {
Blockly
.
FieldCheckbox
.
superClass_
.
init
.
call
(
this
,
block
);
Blockly
.
FieldCheckbox
.
superClass_
.
init
.
call
(
this
,
block
);
// The checkbox doesn't use the inherited text element.
// The checkbox doesn't use the inherited text element.
// Instead it uses a custom checkmark element that is either visible or not.
// Instead it uses a custom checkmark element that is either visible or not.
this
.
checkElement_
=
Blockly
.
createSvgElement
(
'
text
'
,
if
(
this
.
img1
&&
this
.
img2
)
{
{
'
class
'
:
'
blocklyText
'
,
'
x
'
:
-
3
},
this
.
fieldGroup_
);
this
.
checkElement_
=
Blockly
.
createSvgElement
(
'
text
'
,
var
textNode
=
document
.
createTextNode
(
'
\
u2713
'
);
{
'
class
'
:
'
blocklyText
'
,
'
x
'
:
-
3
},
this
.
fieldGroup_
);
this
.
checkElement_
.
appendChild
(
textNode
);
var
textNode
=
document
.
createTextNode
(
'
\
u2713
'
);
this
.
checkElement_
.
style
.
display
=
this
.
state_
?
'
block
'
:
'
none
'
;
this
.
checkElement_
.
appendChild
(
textNode
);
this
.
checkElement_
.
style
.
display
=
this
.
state_
?
'
block
'
:
'
none
'
;
}
else
{
// code from field_image
var
offsetY
=
6
-
Blockly
.
BlockSvg
.
FIELD_HEIGHT
;
this
.
fieldGroup_
=
Blockly
.
createSvgElement
(
'
g
'
,
{},
null
);
this
.
imageElement_
=
Blockly
.
createSvgElement
(
'
image
'
,
{
'
height
'
:
15
+
'
px
'
,
'
width
'
:
15
+
'
px
'
,
'
y
'
:
offsetY
},
this
.
fieldGroup_
);
this
.
setValue
(
this
.
img1
);
if
(
goog
.
userAgent
.
GECKO
)
{
// Due to a Firefox bug which eats mouse events on image elements,
// a transparent rectangle needs to be placed on top of the image.
this
.
rectElement_
=
Blockly
.
createSvgElement
(
'
rect
'
,
{
'
height
'
:
15
+
'
px
'
,
'
width
'
:
15
+
'
px
'
,
'
y
'
:
offsetY
,
'
fill-opacity
'
:
0
},
this
.
fieldGroup_
);
}
block
.
getSvgRoot
().
appendChild
(
this
.
fieldGroup_
);
}
};
};
/**
/**
...
@@ -82,6 +108,7 @@ Blockly.FieldCheckbox.prototype.getValue = function() {
...
@@ -82,6 +108,7 @@ Blockly.FieldCheckbox.prototype.getValue = function() {
/**
/**
* Set the checkbox to be checked if strBool is 'TRUE', unchecks otherwise.
* Set the checkbox to be checked if strBool is 'TRUE', unchecks otherwise.
* Can also toggle between two images if they exist.
* @param {string} strBool New state.
* @param {string} strBool New state.
*/
*/
Blockly
.
FieldCheckbox
.
prototype
.
setValue
=
function
(
strBool
)
{
Blockly
.
FieldCheckbox
.
prototype
.
setValue
=
function
(
strBool
)
{
...
@@ -91,6 +118,10 @@ Blockly.FieldCheckbox.prototype.setValue = function(strBool) {
...
@@ -91,6 +118,10 @@ Blockly.FieldCheckbox.prototype.setValue = function(strBool) {
if
(
this
.
checkElement_
)
{
if
(
this
.
checkElement_
)
{
this
.
checkElement_
.
style
.
display
=
newState
?
'
block
'
:
'
none
'
;
this
.
checkElement_
.
style
.
display
=
newState
?
'
block
'
:
'
none
'
;
}
}
else
if
(
this
.
imageElement_
)
{
this
.
imageElement_
.
setAttributeNS
(
'
http://www.w3.org/1999/xlink
'
,
'
xlink:href
'
,
newState
?
this
.
img1
:
this
.
img2
);
}
if
(
this
.
sourceBlock_
&&
this
.
sourceBlock_
.
rendered
)
{
if
(
this
.
sourceBlock_
&&
this
.
sourceBlock_
.
rendered
)
{
this
.
sourceBlock_
.
workspace
.
fireChangeEvent
();
this
.
sourceBlock_
.
workspace
.
fireChangeEvent
();
}
}
...
...
blockly/core/xml.js
View file @
0de301dc
...
@@ -79,7 +79,7 @@ Blockly.Xml.blockToDom_ = function(block) {
...
@@ -79,7 +79,7 @@ Blockly.Xml.blockToDom_ = function(block) {
}
}
}
}
function
fieldToDom
(
field
)
{
function
fieldToDom
(
field
)
{
// for BlocksCAD, I want to save un-editable fields in the xml for stl import.
// for BlocksCAD
STL import
, I want to save un-editable fields in the xml for stl import.
if
(
field
.
name
&&
(
field
.
EDITABLE
||
field
.
name
==
'
STL_FILENAME
'
||
field
.
name
==
'
STL_CONTENTS
'
))
{
if
(
field
.
name
&&
(
field
.
EDITABLE
||
field
.
name
==
'
STL_FILENAME
'
||
field
.
name
==
'
STL_CONTENTS
'
))
{
var
container
=
goog
.
dom
.
createDom
(
'
field
'
,
null
,
field
.
getValue
());
var
container
=
goog
.
dom
.
createDom
(
'
field
'
,
null
,
field
.
getValue
());
container
.
setAttribute
(
'
name
'
,
field
.
name
);
container
.
setAttribute
(
'
name
'
,
field
.
name
);
...
@@ -233,7 +233,7 @@ Blockly.Xml.domToWorkspace = function(workspace, xml) {
...
@@ -233,7 +233,7 @@ Blockly.Xml.domToWorkspace = function(workspace, xml) {
if
(
workspace
.
RTL
)
{
if
(
workspace
.
RTL
)
{
width
=
workspace
.
getWidth
();
width
=
workspace
.
getWidth
();
}
}
// FOR BLOCKSCAD: set version of input file to null
// FOR BLOCKSCAD: set version of input file to null
so we can read the input xml version.
Blockscad
.
inputVersion
=
null
;
Blockscad
.
inputVersion
=
null
;
// Safari 7.1.3 is known to provide node lists with extra references to
// Safari 7.1.3 is known to provide node lists with extra references to
// children beyond the lists' length. Trust the length, do not use the
// children beyond the lists' length. Trust the length, do not use the
...
@@ -241,9 +241,8 @@ Blockly.Xml.domToWorkspace = function(workspace, xml) {
...
@@ -241,9 +241,8 @@ Blockly.Xml.domToWorkspace = function(workspace, xml) {
var
childCount
=
xml
.
childNodes
.
length
;
var
childCount
=
xml
.
childNodes
.
length
;
for
(
var
i
=
0
;
i
<
childCount
;
i
++
)
{
for
(
var
i
=
0
;
i
<
childCount
;
i
++
)
{
var
xmlChild
=
xml
.
childNodes
[
i
];
var
xmlChild
=
xml
.
childNodes
[
i
];
// Read in Blockscad
file
version information.
// Read in Blockscad
input xml
version information.
if
(
xmlChild
.
nodeName
.
toLowerCase
()
==
'
version
'
)
{
if
(
xmlChild
.
nodeName
.
toLowerCase
()
==
'
version
'
)
{
// console.log("xmlChild read was: ", xmlChild.getAttribute('num'));
Blockscad
.
inputVersion
=
xmlChild
.
getAttribute
(
'
num
'
);
Blockscad
.
inputVersion
=
xmlChild
.
getAttribute
(
'
num
'
);
// console.log("inputVersion is:",Blockscad.inputVersion);
// console.log("inputVersion is:",Blockscad.inputVersion);
}
}
...
@@ -256,7 +255,7 @@ Blockly.Xml.domToWorkspace = function(workspace, xml) {
...
@@ -256,7 +255,7 @@ Blockly.Xml.domToWorkspace = function(workspace, xml) {
}
}
}
}
}
}
// Set blockscad version back to current tool version
// Set blockscad version back to current tool version
now that the input file is done
Blockscad
.
inputVersion
=
Blockscad
.
version
;
Blockscad
.
inputVersion
=
Blockscad
.
version
;
// console.log("resetting inputversion to current: ",Blockscad.inputVersion);
// console.log("resetting inputversion to current: ",Blockscad.inputVersion);
};
};
...
...
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