Skip to content

Single auto-scrolling flyout containing all of the blocks #1059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ericrosenbaum
Copy link
Contributor

@ericrosenbaum ericrosenbaum commented Aug 28, 2017

Resolves

Resolves part of #1040

Proposed Changes

Concatenate all the blocks into a single flyout, with category labels, so that you can scroll continuously through them. When you select a category in the category menu, auto-scroll to that category.

@ericrosenbaum ericrosenbaum force-pushed the feature/all-the-blocks-flyout branch from 4293316 to e3123af Compare August 28, 2017 19:12
// Handle dynamic categories, represented by a name instead of a list of XML.
// Look up the correct category generation function and call that to get a
// valid XML list.
if (typeof xmlList[i] === 'string') {

This comment was marked as abuse.

};

/**
* Store an array of with category names and scrollbar positions.

This comment was marked as abuse.

Blockly.Flyout.prototype.recordCategoryScrollPositions_ = function() {
this.categoryScrollPositions = [];
for (var i = 0; i < this.buttons_.length; i++) {
if (this.buttons_[i].isCategoryLabel_) {

This comment was marked as abuse.


/**
* Select a category using the scroll position.
* @param {number} pos The scroll position.

This comment was marked as abuse.

@@ -155,13 +155,14 @@ Blockly.FlyoutButton.prototype.createDom = function() {
this.svgGroup_);
svgText.textContent = this.text_;

this.width = svgText.getComputedTextLength() +
2 * Blockly.FlyoutButton.MARGIN;
this.width = svgText.getComputedTextLength();

This comment was marked as abuse.

var metrics = this.workspace_.getMetrics();
var contentWidth = metrics.contentWidth;
var viewWidth = metrics.viewWidth;
this.scrollTarget = Math.min(this.scrollTarget, contentWidth - viewWidth);

This comment was marked as abuse.

@@ -245,16 +245,46 @@ Blockly.HorizontalFlyout.prototype.scrollToStart = function() {
};

/**
* Scroll the flyout to a position.
* @param {number} pos The targeted scroll position.
*/

This comment was marked as abuse.

@@ -37,6 +37,7 @@ goog.require('goog.dom');
goog.require('goog.events');
goog.require('goog.math.Rect');
goog.require('goog.userAgent');
goog.require('goog.dom.animationFrame.polyfill');

This comment was marked as abuse.

core/toolbox.js Outdated
@@ -273,7 +296,10 @@ Blockly.Toolbox.prototype.getClientRect = function() {
var x = toolboxRect.left;
var y = toolboxRect.top;
var width = this.getWidth();
var height = toolboxRect.height;
// The height here is the combined height of the category menu and flyout.

This comment was marked as abuse.

core/toolbox.js Outdated
@@ -286,7 +312,7 @@ Blockly.Toolbox.prototype.getClientRect = function() {
return new goog.math.Rect(-BIG_NUM, -BIG_NUM, 2 * BIG_NUM,
BIG_NUM + y + height);
} else { // Bottom
return new goog.math.Rect(0, y, 2 * BIG_NUM, BIG_NUM + width);
return new goog.math.Rect(0, y - height, 2 * BIG_NUM, BIG_NUM);

This comment was marked as abuse.

@paulkaplan paulkaplan removed their assignment Sep 21, 2017
@ericrosenbaum ericrosenbaum modified the milestones: Sept 20, Oct 18 Sep 25, 2017
Copy link
Collaborator

@rachel-fenichel rachel-fenichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three nits and you're good to go. I don't need to do another review--it's just a few missing annotations.

@@ -223,6 +223,31 @@ Blockly.FlyoutButton.prototype.getTargetWorkspace = function() {
};

/**
* Get whether this button is a label at the top of a category.
* @return {boolean} True if it is a category label.

This comment was marked as abuse.

* Get the text of this button.
* @return {string} The text on the button.
*/
Blockly.FlyoutButton.prototype.getText = function() {

This comment was marked as abuse.


/**
* Get the position of this button.
* @return {!goog.math.Coordinate} The button position.

This comment was marked as abuse.

@ericrosenbaum ericrosenbaum merged commit b4f1aa4 into scratchfoundation:develop Sep 26, 2017
@ericrosenbaum ericrosenbaum deleted the feature/all-the-blocks-flyout branch September 26, 2017 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants