Commit Graph

235 Commits

Author SHA1 Message Date
alschmiedt
f30d79fbc8 Fixes bug with using dynamic variable in toolbox 2019-07-09 11:02:02 -07:00
Beka Westberg
b34ca2f93b Fixed review comments. 2019-06-25 15:08:01 -07:00
Beka Westberg
85c4e4129f Added procedure tests. 2019-06-25 15:08:01 -07:00
Neil Fraser
b8cbd9e7df Resolve 13 warnings
Reduce count from 632 to 619.
Eliminate copy-paste code duplication in Field.prototype.setValue
2019-06-12 10:59:33 -07:00
Neil Fraser
cf91b82bb0 Fix three new and ten existing Closure warnings.
Current count: 638
2019-06-07 10:32:57 -07:00
Beka Westberg
73ff710a4d Added getSourceBlock function to field. (#2508) 2019-05-29 12:50:00 -07:00
Beka Westberg
f16c9c0beb Refactored field validation. 2019-05-24 14:23:42 -07:00
Neil Fraser
e642a77f5d Use conventional prefix/suffix for function calls.
Previously a function call with no return value generated:

  prefix();
  suffix();
  function();

The intent was so the prefix and suffix calls in the function body wouldn’t overlap with the prefix and suffix calls of the function call.  However, this is doomed to be inconsistent with a function call with a return value:

  prefix();
  print(function());
  suffix();

Thus since overlaping must exist, both types of function calls should have consistent suffix locations.
2019-05-17 15:04:39 -07:00
Neil Fraser
c0e14c3a7c Add method to suppress prefix/suffix from blocks.
This allows generators to have more control over the placement of suffix.  Needed for ‘if’ blocks and function calls which require their suffix code to be somewhere other than the end.
Also, add loop’s prefix to ‘break’ blocks, since the loop’s suffix will be the next statement hit.
Also, reuse procedures_callreturn generator for procedures_callnoreturn.
2019-05-14 17:19:31 -07:00
Neil Fraser
25adb40e66 Prefix and suffix edge cases for flow statements.
Call suffix code on break/continue before executing the break/continue.
Call prefix code for enclosing loop before executing continue.
2019-05-14 17:19:31 -07:00
Beka Westberg
5c4c816a9b Removed setVisible from the public API (#2406) 2019-04-24 16:07:47 -07:00
Jim Jiang
1b10d134a5 Add Block.setEnabled (#2386)
* Implement Block.setEnabled()

From issue #1593. This commit:
- add setEnabled
- deprecate setDisabled

* Update setDisabled calls to setEnabled

Add setEnabled and deprecate setDisabled in
- core/block_svg

Update calls in
- blocks/loops
- blocks/procedures
- core/block_events
- core/events
- core/flyout_base
- core/xml
- tests/workplace_svg/procedure_svg_test

* Implement changes from comments from RoboErikG

- Implement isEnabled()
- Make this.disabled @private
- Make setDisabled(disabled) call setEnabled(!disabled)
- Update setEnabled to use isEnabled()

* Utilize isEnabled() and fix typos

Fix missing parentheses
Implement isEnabled() more widely
Fix lint and parentheses errors

* Change prevDisabledState to prevEnabledState
2019-04-23 08:49:07 -07:00
Neil Fraser
e9de083361 Fix @return JSDocs. 2019-03-29 15:24:37 -07:00
Andrew Au
d919b4369d Fix issue 2061 (#2326) 2019-03-12 09:50:49 -07:00
Beka Westberg
9dec2da5c5 Movement Updates (#2247)
This is a squash and merge of a large set of changes by @BeksOmega 

* Added functionality to scrolling, dragging, and zooming.

* Fixed incorrect changes to workspaceChanged function.

* Fixed comment.

* Fixed typo.

* Removed scrollbar.set calls from workspace_svg.

* Removed scrollbar.resize() call.

* Added move options to playground.

* Fixed scroll_ calls that replaced scrollbar.set calls.

* Removed this.scrollbar checks.

* Changed zoom so that it always zooms towards the coordinates. Changed isContentBounded_ to be separate from isMovable_ (b/c of the previous change zoomControls had to be added to the bounded check). Fixed scroll_() calls... again.

* Changed procedures so the Highlight definition option is only available if the workspace is moveable.

* Fixed scrollCenter so that it works with flyout toolboxes.

* Fixed zoomToFit so that it works with horizontal flyout toolboxes.

* Fixed Typo.

* Fixed bumping blocks when the workspace is not movable.

* Fixed bumping not working with left and top toolbox positions.

* Re-Added not allowing scrollCenter if the workspace is not movable. Disabled scrollCenter button for this case.

* Cleaned up formatting.

* Fixed bumping... again. Reformatted workspaceChanged a bit.

* Changed blocks to be completely bumped into the workspace.

* Reorganized metrics-getting for workspaceChanged.

* Added bumping workspace comments. Moved event checking.

* Renamed workspaceChanged to bumpObjects.

* Added a bumpObjects developer reminder.

* Added warning to zoomToFit.

* Cleaned up some text.

* Added better inline documentation.

* Fixed up inline docs.

* Cleaned up comments.

* Fixed zoomCenter not actually zooming towards the center.

* Fixed zoomControls error on unmovable bottom-toolbox workspaces

* Fixed programatically placing blocks in an unmovable workspace.

* Removed unnecessary translate call in inject.

* Reversed removal of translate. (apparently it was necessary)

* Cleaned up code in response to first round of reviews.

* Added unit comments to the zoom function.

* Removed bumpObjectsEventChecker. Added BUMP_EVENTS list to Blockly.Events.

* Changed getWorkspaceObjectMetrics call to getBoundingRectangle().

* Fixed utils.mouseToSvg (was causing problems with zoom on wheel if the page was scrolled).

* Fixed zoom when page is scrolled (actually this time). Reverted changes to utils.mouseToSvg.

* Fixed centerOnBlock.

* Added unit docs to translate. Moved setting the grid position to the translate function.

* Added TODO's.
2019-02-18 15:28:51 -08:00
Deniz Susman
eb5bf10911 Typo fix in code comment (#2269)
"independent" instead of "independant".
2019-02-06 13:00:28 -08:00
TangHu2018
6b9d98f592 Update procedures.js
When I use [Rename variable...] in procedure definition block.
The argument name for calling procedure has not changed.
2019-02-02 05:54:45 +09:00
alschmiedt
e7a120e69f Merge branch 'develop' of https://github.com/alschmiedt/blockly into blockly_colours 2019-01-08 13:36:39 -08:00
alschmiedt
4982c5c310 Changes names for block styles 2019-01-08 09:40:30 -08:00
Noah Glaser
7c619a1dba Prevent duplicate parameters in functions (#2177)
Prevents the coder from using duplicate parameters names in functions.

In the validator function check for parameter names that have been used. If it finds a block with a name that matches return null so that it will revert the change. Also change the name each time a new parameter is created to try to prevent duplicate name.
2019-01-07 12:44:01 -08:00
alschmiedt
1b3955d9d6 Fixing review comments 2018-12-21 07:52:50 -08:00
alschmiedt
d9c4608da8 Remove use of style variables in block definition 2018-12-20 10:09:47 -08:00
alschmiedt
f125065a17 Merge branch 'develop' of https://github.com/alschmiedt/blockly into blockly_colours 2018-12-19 10:39:10 -08:00
RoboErikG
a14ff64cf3 Avoid crashing when a procedure input has an empty string (#2182)
Fixes #1958

This will drop the input when it's in the empty string state. This
causes the block to remove the input and re-add it when the text
is reverted, but prevents the breakage. A followup fix should leave
the input alone instead of removing it, but this works for now.
2018-12-19 10:37:40 -08:00
alschmiedt
034bcb00bb Replace setting colour to setting style in block definitions 2018-12-18 10:01:05 -08:00
alschmiedt
3bf9337205 Fixed comment 2018-12-13 10:32:38 -08:00
alschmiedt
094418f928 Reconnects child blocks when an undo is done on an else block 2018-12-13 08:11:16 -08:00
alschmiedt
9a1d6684d0 Pulls from MakeCode fork the ability to rename and delete variables in flyout 2018-11-29 14:17:56 -08:00
Nadya Febiana Djojosantoso
633bbbc8fa Add math_atan2 block with two inputs 2018-10-11 13:12:23 -07:00
Rachel Fenichel
6092e4c517 Calls to getAllBlocks should pass a value for _ordered_ 2018-09-13 16:06:19 -07:00
duzc2dtw@gmail.com
0ea4878958 fix Missing semicolonsemi 2018-09-13 01:35:10 +08:00
duzc2dtw@gmail.com
0dfc93f72d get the variable from the field and use its type. 2018-09-12 11:19:17 +08:00
duzc2dtw@gmail.com
6e589e3491 fix bug.
when create get/set dynamic variable block from set/get ,
lost the type.
2018-09-11 00:44:27 +08:00
RoboErikG
9eacd7d3b9 Disable/enable function calls along with their definitions (#2019)
Fixes #1344

Extends the event listener on procedure caller blocks to also check
for their definition being enabled/disabled and update their own
state in response.
2018-08-23 11:18:29 -07:00
Andrew n marshall
dec9a2c743 Correcting annotations of procedure block mixin functions. 2018-08-22 12:55:16 -07:00
Gokula Krishna
eef7e8f923 Change the XML attribute key from var-id to varid 2018-07-25 10:56:22 +08:00
Gokula Krishna
2c3ef64609 Remove varId attribute while saving 2018-07-24 17:29:35 +08:00
Gokula Krishna
97d3956c43 Prioritize current key var-id 2018-07-24 13:31:04 +08:00
Gokula Krishna
6275c6eef7 Change XML attribute for procedure from varId to var-id 2018-07-24 11:12:17 +08:00
Andrew n marshall
4860e34f51 Removing goog.* uses from blocks/*.js files (#1975)
* Removing goog.arrays.equals() in blocks/procedures.js, with minor refactor.
* Replacing goog.dom.createDom() in blocks/procedures.js, blocks/variables.js,  blocks/variables_dynamic.js, and blocks/loops.js.
2018-07-16 17:01:12 -07:00
Neil Fraser
c8bfc888c8 Throw errors instead of strings. (#1974)
Blocks and generators
2018-07-16 16:33:44 -07:00
Rachel Fenichel
5b1e249adc Fix lint 2018-06-25 12:12:24 -07:00
Neil Fraser
6319cab317 Simplify RTL handling of '<' and '>'. (#1823)
Tested in Playground and RTL demo.
2018-05-10 15:34:06 -07:00
Neil Fraser
4cb4b42f8d Use named properties on Msg. 2018-04-27 11:50:51 -07:00
Andrew n marshall
ab8692652a Revert "Removing namespace declarations for deprecated and unused namespaces. (#1796)" (#1809)
This reverts commit 75459abfdd.
2018-04-20 08:08:11 -07:00
Andrew n marshall
75459abfdd Removing namespace declarations for deprecated and unused namespaces. (#1796)
These namespaces use to contain the original block hue constants,
but were deprecated (via comment, except for procedures) over a year
ago. With the removal of those constants, the declarations were
creating empty, unused objects.
2018-04-18 15:32:26 -07:00
Andrew n marshall
b2cb96b5b1 Mark Blockly.Constants.Colour and .Lists depreacted. (#1797)
Both are only used by the hue constants, which are already deprecated.
2018-04-17 13:29:50 -07:00
Rachel Fenichel
f52b75a198 Merge pull request #1778 from AnmAtAnm/shadow-pop
Rewrote LOGIC_COMPARE_ONCHANGE_MIXIN to fix #1408.
2018-04-13 17:04:12 -07:00
Andrew n marshall
ef23b0e4ef Do not reconnect a previous shadow block.
Assume unplug() will recreate a new correct shadow.
2018-04-13 16:26:20 -07:00
Andrew n marshall
c0e220214c Rewrote LOGIC_COMPARE_ONCHANGE_MIXIN to fix #1408.
* Create prevBlock_ upon first call to onchange.
 * Revert state upon an incompatible combination, bumping the new incompatible
   block, instead of the old block. Thus, the shadow is never the bumped block.

Bug:
 * The undo stack get caught in a loop, and will never undo back to a state
   equivalent to the previous action.
2018-04-12 17:27:20 -07:00