Permalink
Browse files

smash merge from postbooks work

- added global log of storeKey changes, plus the ability to capture .get()s on records during a given interval
- added Init, Enter, and Exit events
- added SC.renderToDataUrl() function
- added tooltip support to SC.Responder
- behaviors are now Hierarchical State Machines
- bug fix for row layer tree layout: force width/height
- clean up SC.Responder
- commented out a log statement
- elide() strings that are too long for the text field
- field editors
- first pass at shared canvas contexts
- first stab at SC.TableView
- fixed text editing bug on mouseDown (would not clear selection)
- get layer in lists working
- got mouse events working correctly with incremental rendering
- got render functions on list items working again
- got text fields working in editable rows
- implement dividers in SC.SelectWidget
- implemented behavior system
- implemented SC.PListItem handling
- improved field editor protocol
- make SC.Responder a mixin
- more shift-tab/tab handling
- more styling improvements
- moved constraints framework outside application to work around error in xtuple buildtools
- removed old-style behaviors
- some scrollbar fixes
- styled checkbox
- styled combobox and text field widgets
- styled radio button
- styled select widget
- tab/shift-tab handling
- various tweaks
- verify that context menus work on layer-backed list item rows
- WIP incremental list view
  • Loading branch information...
erichocean committed May 14, 2012
1 parent 0fa8fbe commit 42d23f462cd8fc571a6c1d4bc98e5659049a3ff0
Showing with 4,019 additions and 1,631 deletions.
  1. +23 −20 application/behaviors/behavior.js
  2. +0 −109 application/behaviors/generic_button.js
  3. +0 −74 application/behaviors/mouse_button.js
  4. +0 −65 application/behaviors/touch_button.js
  5. +1 −1 application/core.js
  6. +1 −12 application/ext/browser.js
  7. +10 −0 application/ext/run_loop.js
  8. +4 −7 application/layers/label.js
  9. +57 −22 application/layers/layer.js
  10. +11 −11 application/layers/text.js
  11. +23 −0 application/mixins/string.js
  12. +1 −1 application/node/buildfile.js
  13. +974 −0 application/surfaces/ilist_view.js
  14. +10 −2 application/surfaces/list_view.js
  15. +14 −9 application/surfaces/private/psurface.js
  16. +19 −2 application/surfaces/scroll_view.js
  17. +1 −2 application/surfaces/split.js
  18. +5 −1 application/surfaces/surface.js
  19. +381 −0 application/surfaces/table_view.js
  20. +64 −25 application/surfaces/view.js
  21. +136 −36 application/system/application.js
  22. +40 −0 application/system/data_url.js
  23. +23 −0 application/system/event.js
  24. +634 −31 application/system/responder.js
  25. +125 −73 application/text/field_editor.js
  26. +12 −43 application/widgets/button.js
  27. +42 −35 application/widgets/checkbox.js
  28. +23 −58 application/widgets/combobox.js
  29. +42 −38 application/widgets/radio.js
  30. +19 −22 application/widgets/segmented.js
  31. +118 −103 application/widgets/select.js
  32. +134 −109 application/widgets/text_field.js
  33. +55 −92 application/widgets/widget.js
  34. +8 −1 buildtools/buildtools.js
  35. 0 {application → }/constraints/README.md
  36. 0 {application → }/constraints/constraint.js
  37. 0 {application → }/constraints/core.js
  38. 0 {application → }/constraints/edit_info.js
  39. 0 {application → }/constraints/error.js
  40. 0 {application → }/constraints/hash_set.js
  41. 0 {application → }/constraints/hash_table.js
  42. 0 {application → }/constraints/linear_constraint.js
  43. 0 {application → }/constraints/linear_expression.js
  44. 0 {application → }/constraints/node/buildfile.js
  45. 0 {application → }/constraints/package.json
  46. 0 {application → }/constraints/point.js
  47. 0 {application → }/constraints/simplex_solver.js
  48. 0 {application → }/constraints/strength.js
  49. 0 {application → }/constraints/symbolic_weight.js
  50. 0 {application → }/constraints/tableau.js
  51. 0 {application → }/constraints/timer.js
  52. 0 {application → }/constraints/variable.js
  53. +52 −2 datastore/models/record.js
  54. +3 −0 datastore/system/store.js
  55. +0 −133 examples/behavior_test/behavior.js
  56. +189 −1 examples/behavior_test/core.js
  57. +36 −4 examples/behavior_test/main.js
  58. +2 −2 examples/form_demo/upper.js
  59. +28 −0 examples/list_demo/core.js
  60. +169 −0 examples/list_demo/main.js
  61. +13 −0 examples/list_demo/node/buildfile.js
  62. +13 −0 examples/list_demo/package.json
  63. +301 −301 examples/view_demo/button_renderer.js
  64. +6 −3 examples/view_demo/main.js
  65. +172 −172 examples/view_demo/sprite_layer.js
  66. +5 −2 examples/widget_demo/buttons.js
  67. +10 −4 examples/widget_demo/controls.js
  68. +6 −0 foundation/system/object.js
  69. +2 −1 projectfile.js
  70. +2 −2 tests/application/qunit/foundation/mixins/responder_context.js
@@ -4,12 +4,10 @@
// License: Licensed under the GPLv3 license (see BLOSSOM-LICENSE).
// ==========================================================================
-sc_require('system/responder') ;
-
/** @class
Base class for layer behavior. Behaviors provide two functions:
- 1. They translate state and events into actions on their view and layer
+ 1. They translate state and events into actions on their view and layer
tree updates and redraws, using the statechart approach.
2. They act as first responders for incoming keyboard, mouse, and
@@ -18,31 +16,36 @@ sc_require('system/responder') ;
Behavior Initialization
-----------------------
- There are several methods you can override on SC.Behavior that will be
- called at different times depending on how your behavior is created. Here
+ There are several methods you can override on SC.Behavior that will be
+ called at different times depending on how your behavior is created. Here
is a guide to the main methods you may want to override and when:
- *init:* override this method for any general object setup (such as
observers) that you need to happen whenever the behavior is created.
- - *updateLayer:* override this method to do more complex management of your
- layer tree to reflect the current state of your behavior. This method is
- called whenever displayDidChange() is called, or one of the keys in
- `displayProperties` is changed. By default, it calls render(), passing
- `layer`'s `context` property. If you just need to draw, override
+ - *updateLayer:* override this method to do more complex management of your
+ layer tree to reflect the current state of your behavior. This method is
+ called whenever displayDidChange() is called, or one of the keys in
+ `displayProperties` is changed. By default, it calls render(), passing
+ `layer`'s `context` property. If you just need to draw, override
`render()` instead.
- @extends SC.Responder
+ @extends Function
@since Blossom 1.0
*/
-SC.Behavior = SC.Responder.extend({
-
- isBehavior: true, // Walk like a duck.
-
- dispatch: function(evt) {
-
- },
-
- state: null // a String, maps to a hash
+SC.mixin(Function.prototype,
+/** @scope Function.prototype */ {
+
+ /**
+ Indicates that the function should be treated as a hierarchical behavior.
+
+ @param {String} superbehaviorKey optional property key for superbehavior
+ @returns {Function} the declared function instance
+ */
+ behavior: function(superbehaviorKey) {
+ this.__superbehaviorKey__ = superbehaviorKey;
+ this.isBehavior = true;
+ return this;
+ }
});
@@ -1,109 +0,0 @@
-// ==========================================================================
-// Project: Blossom - Modern, Cross-Platform Application Framework
-// Copyright: ©2012 Fohr Motion Picture Studios. All rights reserved.
-// License: Licensed under the GPLv3 license (see BLOSSOM-LICENSE).
-// ==========================================================================
-/*globals sc_assert */
-
-sc_require('behaviors/behavior') ;
-
-SC.GenericButtonBehavior = SC.Behavior.extend({
-
- // Required
- startState: 'Enable immediately?',
-
- // Optional, used to configure a layer's initial properties.
- defaultState: 'Enabled',
-
- // Required. All named states MUST be unique within the hierarchy.
- states: {
-
- // This is an internal, transient state. It MUST transition to another
- // state, and it will NEVER be visible externally as a state.
- 'Enable immediately?': function() {
- if (!this.get('isEnabled')) this.transition('Disabled');
- else this.transition('Activate immediately?');
- },
-
- // This is also a transient state (same rules as above apply).
- 'Activate immediately?': function() {
- // No special behavior here (hook for subclasses)
- this.transition('Enabled');
- },
-
- 'Inactive': {
-
- 'Enabled': {
- $disable: 'Disabled',
- $activate: 'Ready'
- },
-
- 'Disabled': {
- $enable: 'Activate immediately?'
- }
-
- },
-
- 'Active': {
- '$enter dialogue': 'Dialogue',
-
- 'Ready': {
- $disable: 'Disabled',
- $deactivate: 'Enabled'
- },
-
- 'Invoked': {
- $activate: 'Ready'
- }
- },
-
- 'Dialogue': {
- defaultSubstate: 'Choose Default',
-
- $disable: function() {
- this.triggerAction('cancel');
- this.transition('Disabled');
- },
-
- 'Choose Default': function() {
- switch (this.get('defaultChoice')) {
- case 'cancel':
- this.transition('Choose Cancel');
- break;
- case 'confirm':
- this.transition('Choose Confirm');
- break;
- default:
- console.log("SC.ButtonBehavior: Invalid 'defaultChoice':", this.get('defaultChoice'), "Disabling behavior.");
- this.triggerAction('cancel');
- this.transition('Disabled');
- }
- },
-
- 'Choose Cancel': {
- '$choose confirm': 'Choose Confirm',
- '$exit dialogue': function() {
- this.triggerAction('cancel');
- this.transition('Enabled');
- }
- },
-
- 'Choose Confirm': {
- '$choose cancel': 'Choose Cancel',
- '$exit dialogue': function() {
- this.triggerAction('confirm');
- this.transition('Executed');
- }
- }
- }
-
- },
-
- variables: {
- defaultChoice: 'cancel',
- enable: true
- },
-
- actions: ['cancel', 'confirm']
-
-});
@@ -1,74 +0,0 @@
-// ==========================================================================
-// Project: Blossom - Modern, Cross-Platform Application Framework
-// Copyright: ©2012 Fohr Motion Picture Studios. All rights reserved.
-// License: Licensed under the GPLv3 license (see BLOSSOM-LICENSE).
-// ==========================================================================
-/*globals sc_assert */
-
-sc_require('behaviors/generic_button');
-
-SC.MouseButtonBehavior = SC.GenericButtonBehavior.extend({
-
- // Required. All named states MUST be unique within the hierarchy. State
- // heirarchy must be consistent with parent behavior everywhere; however,
- // it is acceptable to omit states and state trees that are unchanged from
- // the parent.
- states: {
-
- // Override the generic implementation
- 'Activate immediately?': function(original) {
- var mouse = SC.app.__lastMouseCoordinates__,
- frame = this.__layer__.get('frameInViewport');
-
- if (SC.IsPointInRect(mouse, frame)) {
- this.transition('Ready');
- } else {
- this.transition('Enabled');
- }
- },
-
- 'Inactive': {
-
- 'Enabled': {
- mouseEntered: '$activate' // Maps 'mouseEntered' to the '$activate' author event.
- }
- },
-
- 'Active': {
- mouseDown: '$enter dialogue', // Maps 'mouseDown' to the '$enter dialogue' author event.
-
- 'Ready': {
- mouseExited: '$deactivate' // Maps 'mouseExited' to the '$deactivate' author event.
- },
-
- 'Invoked': {
- enter: function() {
- this.triggerTimeout(300); // In milliseconds. Timeout cleared automatically.
- },
-
- timeout: '$activate', // Maps 'timeout' to the '$activate' author event.
- mouseMoved: '$activate' // Maps 'mouseMoved' to the '$activate' author event.
- }
- },
-
- 'Dialogue': {
-
- 'Choose Cancel': {
- mouseEntered: '$choose confirm', // Maps 'mouseEntered' to the '$choose confirm' author event.
- mouseUp: '$exit dialogue' // Maps 'mouseUp' to the '$exit dialogue' author event.
- },
-
- 'Choose Confirm': {
- mouseExited: '$choose cancel', // Maps 'mouseExited' to the '$choose cancel' author event.
- mouseUp: '$exit dialogue' // Maps 'mouseUp' to the '$exit dialogue' author event.
- }
- }
-
- },
-
- // Overrides our superclass' defaults.
- variables: {
- defaultChoice: 'confirm'
- }
-
-});
@@ -1,65 +0,0 @@
-// ==========================================================================
-// Project: Blossom - Modern, Cross-Platform Application Framework
-// Copyright: ©2012 Fohr Motion Picture Studios. All rights reserved.
-// License: Licensed under the GPLv3 license (see BLOSSOM-LICENSE).
-// ==========================================================================
-/*globals sc_assert */
-
-sc_require('behaviors/generic_button');
-
-SC.TouchButtonBehavior = SC.GenericButtonBehavior.extend({
-
- // Required. All named states MUST be unique within the hierarchy. State
- // heirarchy must be consistent with parent behavior everywhere; however,
- // it is acceptable to omit states and state trees that are unchanged from
- // the parent.
- states: {
-
- // Override the generic implementation
- 'Enable immediately?': function(original) {
- if (!this.get('isEnabled')) this.transition('Disabled');
- else this.transition('Enabled');
- },
-
- // Disable this state and its substates as possible transition targets.
- 'Activate immediately?': null,
-
- 'Inactive': {
-
- 'Enabled': {
- $activate: null, // Disables this author event.
- touchStarted: 'Dialogue'
- }
- },
-
- // Disable this state and its substates as possible transition targets.
- 'Active': null,
-
- 'Dialogue': {
-
- 'Choose Cancel': {
- touchEntered: '$choose confirm', // Maps 'touchEntered' to the '$choose confirm' author event.
-
- touchEnded: '$exit dialogue' // Maps 'touchEnded' to the '$exit dialogue' author event.
- },
-
- 'Choose Confirm': {
- '$exit dialogue': null, // Disables this author event.
-
- touchExited: '$choose cancel', // Maps 'touchExited' to the '$choose cancel' author event.
-
- touchEnded: function(evt) {
- this.triggerAction('confirm');
- this.transition('Enabled');
- }
- }
- }
-
- },
-
- // Overrides our superclass' defaults.
- variables: {
- defaultChoice: 'confirm'
- }
-
-});
View
@@ -121,7 +121,7 @@ SC.AugmentBaseClassWithDisplayProperties = function(K) {
if (displayPropertiesHash[key] !== undefined) throw "A displayProperty collides with a predefined name on Object: "+key+". Please use a different name.";
displayPropertiesHash[key] = true;
}
- console.log(displayPropertiesHash);
+ // console.log(displayPropertiesHash);
ret.displayPropertiesHash = displayPropertiesHash;
}
View
@@ -3,8 +3,7 @@
// Copyright: ©2012 Fohr Motion Picture Studios. All rights reserved.
// License: Licensed under the GPLv3 license (see BLOSSOM-LICENSE).
// ==========================================================================
-/*globals sc_assert CanvasRenderingContext2D HTMLCanvasElement
- ENFORCE_BLOSSOM_2DCONTEXT_API */
+/*globals sc_assert CanvasRenderingContext2D HTMLCanvasElement */
var ENFORCE_BLOSSOM_2DCONTEXT_API = false; // removes context.canvas and context.drawImage()
@@ -31,16 +30,6 @@ CanvasRenderingContext2D.prototype.__defineGetter__('h', function() {
CanvasRenderingContext2D.prototype._sc_drawImage = CanvasRenderingContext2D.prototype.drawImage;
CanvasRenderingContext2D.prototype._sc_createPattern = CanvasRenderingContext2D.prototype.createPattern;
-if (ENFORCE_BLOSSOM_2DCONTEXT_API) {
- console.log("*** ENFORCE_BLOSSOM_2DCONTEXT_API is ON ***");
- CanvasRenderingContext2D.prototype.drawImage = function() {
- throw "CanvasRenderingContext2D#drawImage() is not available in Blossom. Use #drawLayer() instead.";
- };
- CanvasRenderingContext2D.prototype.createPattern = function() {
- throw "CanvasRenderingContext2D#createPattern() is not available in Blossom. Use SC.Layer#patternForContext(context, repetition) instead.";
- };
-}
-
CanvasRenderingContext2D.prototype.drawLayer = function(layer, sx, sy, sw, sh, dx, dy, dw, dh) {
if (!layer.isLayer) throw TypeError;
var el = layer.__sc_element__;
@@ -10,6 +10,10 @@
// view queues and Timers.
var runLoopBenchKey = 'SC.RunLoop#loop()';
+var BREAK = false;
+
+SC.changedStoreKeys = {};
+SC.didChangeStoreKeys = false;
SC.RunLoop = SC.RunLoop.extend(
/** @scope SC.RunLoop.prototype */ {
@@ -18,11 +22,15 @@ SC.RunLoop = SC.RunLoop.extend(
Override so we can benchmark it.
*/
beginRunLoop: function() {
+ // console.log('SC.RunLoop#beginRunLoop()');
SC.Benchmark.start(runLoopBenchKey);
var ret = arguments.callee.base.apply(this, arguments); // do everything else
// sc_assert(SC.animationTransactions.length === 0); // Not true on tested run loops.
SC.AnimationTransaction.begin();
SC.STORE_NEEDS_FINAL_FLUSH = true;
+ // if (SC.didChangeStoreKeys) console.log(SC.changedStoreKeys);
+ SC.changedStoreKeys = {}; // reset
+ SC.didChangeStoreKeys = false;
return ret;
},
@@ -202,6 +210,7 @@ SC.ScheduleLayoutAndRendering = function closure() {
SC.Benchmark.start(benchKey);
didRequestAnimationFrame = false;
SC.isAnimating = true;
+ SC.requestAnimationFrame = false;
SC.app.performLayoutAndRendering(timestamp);
SC.isAnimating = false;
SC.Benchmark.end(benchKey);
@@ -214,6 +223,7 @@ SC.ScheduleLayoutAndRendering = function closure() {
// Viewport size changes occur much less often, so we test second.
if (SC.requestAnimationFrame || force) {
didRequestAnimationFrame = true;
+ console.log('requesting a new animation frame', SC.requestAnimationFrame, force);
SC.RequestAnimationFrame(callback);
}
};
Oops, something went wrong.

0 comments on commit 42d23f4

Please sign in to comment.