Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Openblocks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
letsgoING
ArduBlock Source
Openblocks
Commits
8e54e8a8
Commit
8e54e8a8
authored
4 years ago
by
Anian Bühler
Browse files
Options
Downloads
Patches
Plain Diff
redesigned infixBlockShape and added "Command"-connectors
parent
ce38c100
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/edu/mit/blocks/codeblocks/InfixBlockShape.java
+50
-20
50 additions, 20 deletions
src/main/java/edu/mit/blocks/codeblocks/InfixBlockShape.java
src/main/java/edu/mit/blocks/renderable/NameLabel.java
+14
-5
14 additions, 5 deletions
src/main/java/edu/mit/blocks/renderable/NameLabel.java
with
64 additions
and
25 deletions
src/main/java/edu/mit/blocks/codeblocks/InfixBlockShape.java
+
50
−
20
View file @
8e54e8a8
...
...
@@ -43,13 +43,19 @@ public class InfixBlockShape extends BlockShape {
//curve down and right
BlockShapeUtil
.
cornerTo
(
gpBottom
,
botLeftCorner
,
botRightCorner
,
blockCornerRadius
);
//added by letsgoING for new setVariableBlock test
if
(
block
.
hasAfterConnector
()
&&
!
rb
.
isCollapsed
())
{
//control connector if necessary
// Trying left-aligned ports
Point2D
p
=
BCS
.
addControlConnectorShape
(
gpBottom
,
(
float
)
COMMAND_PORT_OFFSET
+
blockCornerRadius
,
true
);
rb
.
updateSocketPoint
(
block
.
getAfterConnector
(),
p
);
}
/// BOTTOM SOCKETS
//for each socket in the iterator
int
socketCounter
=
0
;
//need to use this to determine which socket we're on
for
(
BlockConnector
curSocket
:
block
.
getSockets
())
{
//if bottom socket
if
(
curSocket
.
getPositionType
()
==
BlockConnector
.
PositionType
.
BOTTOM
)
{
...
...
@@ -58,17 +64,22 @@ public class InfixBlockShape extends BlockShape {
gpBottom
.
lineTo
(
(
float
)
gpBottom
.
getCurrentPoint
().
getX
()
+
BOTTOM_SOCKET_MIDDLE_SPACER
,
(
float
)
gpBottom
.
getCurrentPoint
().
getY
());
}
else
{
}
else
if
(
block
.
isCommandBlock
())
{
//TODO: check //added by letsgoING for new setVariableBlock test
gpBottom
.
lineTo
(
(
float
)
gpBottom
.
getCurrentPoint
().
getX
()
+
BOTTOM_SOCKET_SIDE_SPACER
,
(
float
)
gpBottom
.
getCurrentPoint
().
getY
());
}
else
{
gpBottom
.
lineTo
(
(
float
)
gpBottom
.
getCurrentPoint
().
getX
()
+
BOTTOM_SOCKET_SIDE_SPACER
,
(
float
)
gpBottom
.
getCurrentPoint
().
getY
());
}
//move down so bevel doesn't screw up from connecting infinitely sharp corner
// as occurs from a curved port
BlockShapeUtil
.
lineToRelative
(
gpBottom
,
0
,
-
0.1f
);
//////////////////////
//begin drawing socket
//////////////////////
...
...
@@ -232,27 +243,46 @@ public class InfixBlockShape extends BlockShape {
//System.out.println("determining block width");
int
width
=
super
.
determineBlockWidth
();
//if the sum of bottom sockets is greater than the calculated width, then use it
int
bottomSocketWidth
=
0
;
for
(
BlockConnector
socket
:
block
.
getSockets
())
{
if
(
socket
.
getPositionType
()
==
BlockConnector
.
PositionType
.
BOTTOM
)
{
if
(
socket
.
getBlockID
()
==
Block
.
NULL
)
{
//3 socket spacers = left of socket, between connectors, right of socket
bottomSocketWidth
+=
BOTTOM_SOCKET_SIDE_SPACER
;
}
else
{
//a block is connected to socket
//TODO get their assigned width from rb
if
(
rb
.
getSocketSpaceDimension
(
socket
)
!=
null
)
{
bottomSocketWidth
+=
rb
.
getSocketSpaceDimension
(
socket
).
width
;
}
bottomSocketWidth
-=
BlockConnectorShape
.
NORMAL_DATA_PLUG_WIDTH
;
// if it's a mirror plug, subtract for the other side, too.
if
(
rb
.
getWorkspace
().
getEnv
().
getBlock
(
socket
.
getBlockID
()).
getPlug
().
getPositionType
()
==
BlockConnector
.
PositionType
.
MIRROR
)
{
bottomSocketWidth
-=
BlockConnectorShape
.
NORMAL_DATA_PLUG_WIDTH
;
//added by letsgoING for new setVariableBlock test
if
(
block
.
isCommandBlock
())
{
for
(
BlockConnector
socket
:
block
.
getSockets
())
{
if
(
socket
.
getPositionType
()
==
BlockConnector
.
PositionType
.
BOTTOM
)
{
if
(
socket
.
getBlockID
()
==
Block
.
NULL
)
{
//3 socket spacers = left of socket, between connectors, right of socket
bottomSocketWidth
+=
BOTTOM_SOCKET_SIDE_SPACER
+
BOTTOM_SOCKET_MIDDLE_SPACER
;
}
else
{
//a block is connected to socket
//TODO get their assigned width from rb
if
(
rb
.
getSocketSpaceDimension
(
socket
)
!=
null
)
{
bottomSocketWidth
+=
rb
.
getSocketSpaceDimension
(
socket
).
width
;
}
}
}
}
}
//if the sum of bottom sockets is greater than the calculated width, then use it
else
{
for
(
BlockConnector
socket
:
block
.
getSockets
())
{
if
(
socket
.
getPositionType
()
==
BlockConnector
.
PositionType
.
BOTTOM
)
{
if
(
socket
.
getBlockID
()
==
Block
.
NULL
)
{
//3 socket spacers = left of socket, between connectors, right of socket
bottomSocketWidth
+=
BOTTOM_SOCKET_SIDE_SPACER
;
}
else
{
//a block is connected to socket
//TODO get their assigned width from rb
if
(
rb
.
getSocketSpaceDimension
(
socket
)
!=
null
)
{
bottomSocketWidth
+=
rb
.
getSocketSpaceDimension
(
socket
).
width
;
}
bottomSocketWidth
-=
BlockConnectorShape
.
NORMAL_DATA_PLUG_WIDTH
;
// if it's a mirror plug, subtract for the other side, too.
if
(
rb
.
getWorkspace
().
getEnv
().
getBlock
(
socket
.
getBlockID
()).
getPlug
().
getPositionType
()
==
BlockConnector
.
PositionType
.
MIRROR
)
{
bottomSocketWidth
-=
BlockConnectorShape
.
NORMAL_DATA_PLUG_WIDTH
;
}
}
}
}
}
bottomSocketWidth
+=
2
*
BOTTOM_SOCKET_MIDDLE_SPACER
;
//TODO need to decide for a size of the middle spacer and how to place them
...
...
This diff is collapsed.
Click to expand it.
src/main/java/edu/mit/blocks/renderable/NameLabel.java
+
14
−
5
View file @
8e54e8a8
...
...
@@ -34,11 +34,20 @@ class NameLabel extends BlockLabel {
x
+=
4
+
BlockConnectorShape
.
getConnectorDimensions
(
rb
.
getBlock
().
getPlug
()).
width
;
}
if
(
rb
.
getBlock
().
isInfix
())
{
if
(!
rb
.
getBlock
().
getSocketAt
(
0
).
hasBlock
())
{
x
+=
30
;
}
else
{
x
+=
rb
.
getSocketSpaceDimension
(
rb
.
getBlock
().
getSocketAt
(
0
)).
width
;
}
//added by letsgoING for new setVariableBlock test
if
(
rb
.
getBlock
().
isCommandBlock
())
{
if
(!
rb
.
getBlock
().
getSocketAt
(
0
).
hasBlock
())
{
x
+=
60
;
}
else
{
x
+=
rb
.
getSocketSpaceDimension
(
rb
.
getBlock
().
getSocketAt
(
0
)).
width
+
30
;
}
}
else
{
if
(!
rb
.
getBlock
().
getSocketAt
(
0
).
hasBlock
())
{
x
+=
30
;
}
else
{
x
+=
rb
.
getSocketSpaceDimension
(
rb
.
getBlock
().
getSocketAt
(
0
)).
width
;
}
}
}
if
(
rb
.
getBlockWidget
()
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment