Commit Graph

245 Commits

Author SHA1 Message Date
Adam Barth
529fa95f87 Give the CustomPaint and SizeObserver callbacks better names
The style we use for callbacks in widgets is "onFoo". These classes were using
an order naming convention and just called their callbacks "callback".
2015-10-19 17:27:40 -07:00
Hixie
4f96083e66 Fix warning in test. Arguments must be typed. 2015-10-19 16:07:01 -07:00
Hixie
ed195cfa19 requestPostFrameCallback()
Provide a way to schedule a callback for immediately after the current
frame has been sent to the GPU thread. This is useful for times where
you want to immediately schedule yourself for another build or layout
because, for instance, you just displayed frame zero of an animation and
you want to use the metrics from that layout to set up the actual
animation to begin immediately, such that the very next frame is frame 1.
2015-10-19 16:05:01 -07:00
Adam Barth
8402b54858 Merge pull request #1676 from abarth/align_uses_fractional_offset
Convert Align to use FractionalOffset instead of two doubles
2015-10-19 13:10:34 -07:00
Hixie
552f26d713 Stop AnimatedContainer from animating every build
It turns out that an AnimatedContainer with a BoxDecoration would
start animating every single time it was built, whether or not the
container's decoration had changed.
2015-10-19 13:06:59 -07:00
Adam Barth
715b304ea2 Convert Align to use FractionalOffset instead of two doubles
It was confusing as to whether these were fractions or pixels.

Fixes #1622
2015-10-19 12:56:38 -07:00
Hixie
fb8fe97a9b Enable Positioned to be animated.
Add a AnimatedRelativeRectValue class for animating RelativeRects.

Add a PositionedTransition class for animating Positioned using
AnimatedRelativeRectValues.

Add a test for PositionedTransition.

Fix a math bug a RelativeRect found by the test.

Fix a logic bug in the two ParentDataWidget classes found by the test.
Specifically, they were marking the child dirty, rather than the parent.
The parentData is for the parent's layout, not the child's, so they have
to mark the parent dirty. (I didn't hoist this up to the superclass
because ParentData could be used for painting, hit testing,
accessibility, or any number of other things, and I didn't want to bake
in the assumption that it needed markNeedsLayout.)
2015-10-17 19:06:42 -07:00
Hixie
d0d84e1666 Sundry debugging aids and fixes
(These are all the debugging-related fixes and trivial typo fixes that I
extracted out of my heroes branch.)

Fix rendering.dart import order.

Introduce a debugLabel for Performances so that when you create a
performance, you can tag it so that if later you print it out, you can
figure out which performance it is.

Allow the progress of a PerformanceView to be determined (but not set).

Allow subclasses of PerformanceView that are constants to be created by
defining a constant constructor for PerformanceView.

Introduce a debugPrint() method that throttles its output. This is a
test to see if it resolves the problems people have been having with
debugDumpRenderTree() et al having their output corrupted on Android. It
turns out (according to some things I read On The Internets) that
Android only has a 64KB kernel buffer for its logs and and if you output
to it too fast, it'll drop data on the floor. If this does in fact
reliably resolve this problem, we should probably move the fix over to
C++ land (where "print" is implemented) so that any use of print is
handled (avoiding the interleaving problem we have now if you use both
debugPrint() and print()).

Fix a bug with the debugging code for "size". In the specific case of a
RenderBox having a parent that doesn't set parentUsesSize, then later
the parent setting parentUsesSize but the child having its layout
short-circuited (e.g. because the constraints didn't change), we didn't
update the _DebugSize object to know that now it's ok that the size be
used by the parent, and we'd assert.

Also, allow a _DebugSize to be used to set the size of yourself.
Previously you could only set your size from a regular Size or from your
child's _DebugSize.

Add more debugging information to various Widgets where it might be
helpful.

Make GlobalKey's toString() include the runtimeType so that when
subclassing it the new class doesn't claim to be a GlobalKey instance.

Include the Widget's key in the Element's description since we don't
include it in the detailed description normally (it's in the name part).

Fix a test that was returning null from a route.
2015-10-16 16:41:56 -07:00
Hans Muller
09ac8de2d6 Fix scollable tabs, add basic unit test 2015-10-16 15:10:26 -07:00
krisgiesing
d923a8c35f Merge pull request #1617 from krisgiesing/arena_sweep
Arena sweep
2015-10-15 13:08:34 -07:00
Jason Simmons
5b72a2fdaf Fix warnings seen when running skyanalyzer in strong mode 2015-10-15 10:56:03 -07:00
Jason Simmons
6bdd288379 Merge pull request #1615 from jason-simmons/edit_text_action_button_2
Implement better synchronization between the state of the input widget and the keyboard IME
2015-10-14 17:36:33 -07:00
Kris Giesing
e8a0ea3593 Add release semantics, add test 2015-10-14 17:03:26 -07:00
Hixie
3c95ce621c Transform alignment
For those times where you want to spin something around a point relative
to the size of your box, but you don't know the size of your box.
2015-10-14 15:30:56 -07:00
Jason Simmons
98b83e0cf5 Implement better synchronization between the state of the input widget and the keyboard IME
Also add an input widget API for the keyboard submit button
2015-10-14 15:19:46 -07:00
Kris Giesing
0284321483 Address more comments 2015-10-13 17:32:04 -07:00
Kris Giesing
9f74a178fd Address comments 2015-10-13 16:57:40 -07:00
Kris Giesing
ec205ac5c5 Add dart-layer input event abstraction 2015-10-13 15:16:04 -07:00
Hixie
f2cc43a483 Lots of trivial warning fixes
Add type annotations in many places.
Fix some identifiers to have more lint-satisfying names.
Make all operator==s consistent in style.
Reorder some functions for consistency.
Make ParentData no longer dynamic, and fix all the code around that.
2015-10-12 16:31:20 -07:00
Adam Barth
ecce1eb389 Import dart:ui as ui (instead of as sky) 2015-10-09 20:55:54 -07:00
Adam Barth
65eba90843 Rename package:sky to package:flutter 2015-10-09 20:44:52 -07:00
Adam Barth
5b37f8750d Rename dart:sky to dart:ui 2015-10-09 19:27:13 -07:00
Adam Barth
db3b9e8052 Rename App to MaterialApp
MaterialApp assumes that you're using material design.

Also move radial reaction and fix imports for stats box.
2015-10-09 10:27:22 -07:00
Adam Barth
cc809491ba Split material design widgets out of widgets.dart
These are now part of material.dart.
2015-10-09 10:07:06 -07:00
Hixie
4254f5fba8 Drawer test. 2015-10-08 12:17:53 -07:00
Hans Muller
3cfc9c4d95 Allow Stacks with no children or only poisitioned children 2015-10-08 11:09:41 -07:00
Adam Barth
67367974ef Merge pull request #1538 from abarth/fix_snackbar
SnackBar throws exception on creation
2015-10-08 10:27:58 -07:00
Hans Muller
09d26302cb IndexedStack
Added horizontal and vertical alignment properties to Stack so that the origin of non-positioned children can be specified. Currently all of the non-positioned children just end up with their top-left at 0,0. Now, for example, you can center the children by specifying verticalAlignment: 0.5, horizontalAlignment: 0.5.

Added IndexedStack which only paints the stack child specified by the index property. Since it's a Stack, it's as big as the biggest non-positioned child. This component will be essential for building mobile drop down menus.

Added a (likely temporary) example that demonstrates IndexedStack.
2015-10-08 10:21:24 -07:00
Adam Barth
6b1c85a8b0 SnackBar throws exception on creation
It was trying to grab the route's performance before it was created. Now we
create the performance eagerly again.
2015-10-08 10:17:19 -07:00
Adam Barth
d234ed932e Re-enable passing tests 2015-10-07 20:12:39 -07:00
Hixie
fbf8174c87 Fix Focus
Focus.at() and company should be on Focus, not FocusState.

_notifyDescendants() was using the wrong runtimeType.

Let InheritedWidget update the descendants during build.

When you setState() during build, assert that you're not
markNeedsBuild()ing someone who isn't a descendant.

Typo in Widget.toString().
2015-10-05 16:41:50 -07:00
Hixie
90a0f6300f Simplify the usage of Navigator's routes argument
(These are changes cherry-picked from in-flight branches since they are
more independent and could be helpful even without those changes.)

- Change RouteBuilder's signature to take a single argument in which the
  other fields are placed, so that we can keep iterating on those
  arguments without having to break compatibility each time. Also, this
  makes defining route builders much simpler (only one argument to
  ignore rather than a variable number).

- Expose the next performance to RouteBuilders, since sometimes the
  route itself might not be where it's used.

- Allow BuildContext to be used to walk children, just like it can for
  ancestors

- Allow BuildContext to be used to get the Widget of the current
  BuildContext

- Allow StatefulComponentElement to be referenced with a type
  specialisation so that you don't have to cast when you know what the
  type you're dealing with actually is.
2015-10-05 13:59:30 -07:00
Adam Barth
db191e96bd Switch scheduler over to Duration
This patch prepares us to switch to using integers when handing off the
animation time from the engine to the framework.
2015-10-03 13:48:57 -07:00
Adam Barth
7271698496 Merge pull request #1458 from Hixie/dismiss-1215
Regression test for #1215
2015-10-02 23:05:57 -07:00
Hans Muller
4de0a99b3f ShaderMask
The ShaderMask widget enables rendering its child with an alpha channel defined by a Shader. For example if the Shader was a linear gradient in alpha then the component behind the ShaderMask's child would appear wherever the gradient's alpha value was not fully opaque.

The card_collection.dart example demonstrates this. Select the "Let the sun shine" checkbox in the app's drawer.
2015-10-02 17:08:00 -07:00
Adam Barth
274d2986fe Merge pull request #1463 from abarth/animated_container
Add AnimatedContainer
2015-10-02 16:34:32 -07:00
Adam Barth
c88ca5dbdc Add AnimatedContainer
This widget is used in Material and Drawer. We don't currently support
animating towards null, but we can add that in a future patch.
2015-10-02 15:53:12 -07:00
Adam Barth
56c8e60b04 Detecting just Pan events causes an exception in GestureDetector
Fixes #1320
2015-10-02 15:36:41 -07:00
Hixie
846a073ab9 Regression test for #1215
I'm not sure this specific incarnation of the test ever crashed, since
the original test depended on user interaction and now works fine, but
just in case, here's a regression test for it so I can close that issue.

This also slightly changes the Widget.toString() output to include the
key since that will make debugging easier.
2015-10-02 11:22:16 -07:00
Hixie
6baf162a1d Default RenderBox.size to null. 2015-10-02 10:31:14 -07:00
Adam Barth
97eaee3484 Merge pull request #1447 from abarth/reactivate
GlobalKeys should preserve state across tree mutations
2015-10-01 17:13:16 -07:00
Adam Barth
f31f067eef GlobalKeys should preserve state across tree mutations
This patch causes widgets with global keys to drag their state (including their
children) with them as they travel through the element tree.
2015-10-01 17:08:05 -07:00
Hixie
c07cd697ed FractionallySizedBox 2015-10-01 15:41:14 -07:00
Adam Barth
f2b28e55b8 Merge pull request #1444 from abarth/float64
Moves from vector_math to vector_math_64
2015-10-01 15:37:20 -07:00
Hixie
ce2c56b35c EdgeDims changes and other fixes to core classes.
- Rename EdgeDims constructor to EdgeDims.TRBL().

- Add operator== to Size and Offset so that you can compare Size to
  DebugSize in checked mode.

- Add Size.lerp().

- Add various operators to EdgeDims. (*, /, ~/, %)

- Add EdgeDims.lerp().

- Update style guide. I went there to fix an EdgeDims constructor
  example, and stayed because some recent things came up and I wanted to
  add them before I forgot.
2015-10-01 15:34:04 -07:00
Adam Barth
7662a30f85 Moves from vector_math to vector_math_64
* Moves from vector_math to vector_math_64
* Adds support for Float64List in Dart bindings
2015-10-01 14:46:13 -07:00
Adam Barth
fbd5460b04 Integrate WidgetTester with FakeAsync
Fixes #1084
2015-10-01 10:56:58 -07:00
Adam Barth
45c906d2ad Make fn3 the default widget framework 2015-10-01 09:48:35 -07:00
Adam Barth
4525159831 Consolidate widget tests
Now that we've ported all the widget tests to fn3, we don't need a separate fn3
directory.
2015-09-30 18:58:17 -07:00
Hans Muller
c06995a379 Clamp the snapped scroll simulation; Scrollable settle() and fling() return a Future 2015-09-30 16:52:17 -07:00
Adam Barth
946da1015a Merge pull request #1411 from abarth/port_input_test
Port input_test to fn3
2015-09-30 16:00:52 -07:00
Adam Barth
f4afd0d9d2 Merge pull request #1418 from abarth/dimissable_test
Port dimissable_test.dart to fn3
2015-09-30 15:18:19 -07:00
Adam Barth
d4b1519cef Port dimissable_test.dart to fn3 2015-09-30 15:03:32 -07:00
Hans Muller
4ac052357f Snap scrolling: additional tests, cleanup 2015-09-30 14:13:11 -07:00
Adam Barth
11e7dfbe79 Port input_test to fn3 2015-09-30 13:25:46 -07:00
Adam Barth
347bd25cb4 Remove BuildContext argument to initState
This argument isn't needed anymore now that State has a getter for context.
2015-09-30 13:15:46 -07:00
Adam Barth
84f2b5a5b0 Merge pull request #1397 from jason-simmons/editable_text_unused_import_sky
Fix a couple of analyzer warnings
2015-09-29 19:42:43 -07:00
Hixie
a91dd07cb3 Draggable
Introduce a Draggable class that wraps all the logic of dragging
something and dropping it on a DragTarget.

Update examples/widgets/drag_and_drop.dart accordingly.

Make the performance/transition part of routes optional.
2015-09-29 18:00:40 -07:00
Hixie
f103d397d6 Make hit testing work in horizontal scrolling list
Previously, hitTestChildren in RenderBlockViewport just didn't support
horizontal scrolling, due to an oversight.
2015-09-29 16:30:18 -07:00
Hans Muller
9b6590890a Land snap_scrolling_test.dart 2015-09-29 15:28:42 -07:00
Jason Simmons
571c7dd9ff Fix a couple of analyzer warnings
* Unused import in editable_text.dart
* Type mismatch in append_child_test.dart
2015-09-29 14:04:47 -07:00
Hans Muller
7385641f6d SnapOffsets for fling Scrolling
Initial snap offset support for ScrollableWidgetList (and ScrollableList<T>) and ScrollableMixedWidgetList. If a ```toSnapOffset(scrollOffset)``` function is provided, fling Scrolls will coast to the returned value. If ```alignmentOffset``` is specified then fling scrolls conclude when toSnapOffset's value lines up with the Scrollable widget's origin + alignmentOffset. For example if the Scrollable widget's height was 200.0, and alignmentOffset:100.0 was specified, then fling scrolls would end with the value returned by toSnapOffset() lined up with the center of the Scrollable.

This approach to Scrollable snapping assumes that the layout of whatever the Scrollable contains is known at the outset. This is often true however a ScrollableMixedWidgetList may not know its items' sizes until they've been reached by scrolling.

This is a first cut at snapping support. Among the things that remain to be done:
- Scrolling limits trump snapping. Snapping should probably trump scrolling limits.
- Drag scrolls aren't snapped. This may be desirable so perhaps the feature should be controlled with a flag.
- Specifying alignmentOffset as a percentage would probably be more convenient.
- It would be nice if one could wrap items in a SnapOffset value like: ```new SnapOffset(0.5, child: myItem)``` to snap to the center of the item.

Updated the CardCollection example: snapping and fixed size items can be turned on/off with Drawer checkboxes.
2015-09-29 11:09:59 -07:00
Adam Barth
64dfb8496c Actually notify GlobalKey listeners in fn3
This patch makes a number of changes:

1) buildDirtyComponents now prevents all calls to setState, not just those
   higher in the tree. This change is necessary for consistency with
   MixedViewport and HomogeneousViewport because those widgets already build
   subwidgets with that restriction. If the "normal" build didn't enforce that
   rule, then some widgets would break when put inside a mixed or homogeneous
   viewport.

2) We now notify global key listeners in a microtask after beginFrame. That
   means setState is legal in these callbacks and that we'll produce another
   frame if someone calls setState in such a callback.
2015-09-27 17:22:48 -07:00
Adam Barth
a74d02dadf Rename Sky to Flutter in a few more places 2015-09-26 12:46:03 -07:00
Hixie
0a0a92eb45 Port stocks to fn3 and introduce an App component. 2015-09-25 17:52:33 -07:00
Adam Barth
4ad83fa059 Port some more tests to fn3 2015-09-25 11:27:48 -07:00
Adam Barth
7d02880cf4 Port some more tests to fn3 2015-09-25 10:51:56 -07:00
Adam Barth
06ffa75919 Convert some tests to fn3 2015-09-25 09:29:04 -07:00
Hixie
c3b3b71bed Rename ComponentState and use initState().
ComponentState becomes State, for brevity.
Instead of overriding its constructor, override initState().
This makes writing States much simpler.
2015-09-24 16:00:51 -07:00
Hixie
b948967855 fn3: MixedViewport
Also:
- Expose the slot of each Element.
- Minor improvements to HomogeneousViewport.
- Replace TestComponent with FlipComponent in tests.
2015-09-24 14:52:13 -07:00
Adam Barth
0d63d6b775 Port most of scrollable.dart to fn3 2015-09-24 10:26:27 -07:00
James Robinson
e854d7457d Update to Mojo 4e4d51ce28a8edcb32b9c7f555e38e2ae84a825e, update deps
This updates to mojo 4e4d51ce28a and mojo sdk 711a0bcfb141b4 and updates the sky
package's pubspec.yaml dependency to '>=0.1.0 <0.2.0' to be compatible with
the current mojo package. This includes an update to the Mojo Dart generator to
produce real classes for enums and the corresponding updates for users of the
KeyboardType enum in Sky as well as one scoped_ptr->std::unique_ptr in shell
corresponding to a change in the Mojo EDK.

When a new version of the sky and sky_services package are pushed this will fix
domokit/mojo#440.
2015-09-23 17:26:46 -07:00
Hixie
ea45169083 fn3: Port HomogeneousViewport 2015-09-23 16:21:13 -07:00
Hixie
6ea86b6a2f fn3: Listener
In this new world, Listener is just a wrapper around a node in the
render tree that hooks directly into the event handling logic.
2015-09-23 11:22:51 -07:00
Hixie
b3ebd4406b Expose _descendantRenderObject as 'renderer'
This allows people to use localToGlobal and company.
2015-09-23 11:13:45 -07:00
Adam Barth
fa119c38b9 Add tests for ParentData 2015-09-23 10:59:49 -07:00
Hixie
2a5fad937b fn3: Minor cleanup
- Remove the unique objects used as slots since we decided 'null' was
  fine after all
- Rename 'slot' to 'newSlot' when it's used as an argument to change the
  _slot field, to clarify which variable has the newer value
- Remove the RenderObject registry since we'll do listeners a different
  way. This also removes handleEvent for the same reason.
- Remove the TODOs for mount/unmount becoming didMount/didUnmount since
  the methods do in fact do the mounting/unmounting.
2015-09-23 09:24:13 -07:00
Hixie
555138e60e fn3: Binding to RenderView
In the old world, we had two ways to bind a Widget tree to a
RenderObject node, one way for RenderView and one mostly untested way
for other cases (it's only tested by the spinning_mixed.dart demo). For
fn3, I made these the same code path.

This patch also introduces GlobalKey, though the GlobalKey logic isn't
hooked in yet.

This is Hello World in the new world:

```dart
import 'package:sky/src/fn3.dart';

void main() {
  runApp(new Text('Hello World!'));
}
```
2015-09-23 09:12:01 -07:00
Adam Barth
8b162b5950 Add tests for MultiChildRenderWidget 2015-09-23 08:52:15 -07:00
Adam Barth
fb4a87ad68 Add ParentDataWidget and InheritedWidget to fn3 2015-09-22 16:07:27 -07:00
Hixie
b73b06e4ad fn3: Add a binding for fn3 and sky.
- I extracted the BuildScheduler into a separate binding.dart file.
- Various changes to expose private members that are needed by
  binding.dart.
- Registering the render objects for event dispatch.
- Convert the tests to use the new binding mechanism.

This doesn't yet have a RenderView or event handling.
2015-09-22 12:30:37 -07:00
Hixie
59f7e7f08e Fix scrolling of Block.
Since our build function depends on scrollBehavior.isScrollable, any
time we update scrollBehavior we are implicitly updating our state. As
such, we must do so during a setState() call, or else we won't rebuild
and might not bother to listen to the scroll gestures.

This probably broke when we made Block not listen to gestures if it
wasn't overflowing.
2015-09-22 10:36:34 -07:00
Jason Simmons
963fb41334 Merge pull request #1245 from jason-simmons/editable_text_initial_blink
Ensure that EditableText always shows a cursor
2015-09-22 09:29:52 -07:00
Jason Simmons
9b84e6b8e9 Merge pull request #1255 from jason-simmons/skyanalyzer_pub_cache
Some cleanup of the Sky analyzer script
2015-09-22 09:29:27 -07:00
Hixie
ba41fd3538 More dartdoc for fn3, and sundry changes.
- move _uniqueChild earlier since a comment now mentions it earlier.
- reorder methods in Element to more closely reflect call order.
- change mount to be the place that sets the parent pointer, for consistency.
- make the lifecycleState a purely debug-time thing for consistency.
- make BuildableElement.unmount set dirty to false so that we won't
  build unmounted objects.
- rename "updated" to "newWidget" for clarity.
- change how we unmount things so that the slot is reset up to a
  RenderObjectElement, but not further, and don't reset the depth.
2015-09-21 17:44:15 -07:00
Adam Barth
12097bdde0 Remove uses of sky.GestureEvent 2015-09-21 17:05:45 -07:00
Adam Barth
051354ae1d Remove EventDisposition
All the use cases for EventDisposition are now addressed by the gesture
detection system.
2015-09-21 16:45:09 -07:00
Hixie
205335f0f0 Fix fn3 build errors
Add a LeafRenderObjectElement, fix a test to use the new contract.
2015-09-21 15:45:49 -07:00
Hixie
547c324d4b fn3 review
- adds dartdocs
- replaces config setter with didUpdateConfig() so that you can't replace
the config outside of the system
- renames didUnmount() with destroy().
- rename Component to StatelessComponent, ComponentConfiguration to
StatefulComponent
- move debug dump to end of file
- renamed _holder to _element
2015-09-21 15:42:18 -07:00
Adam Barth
d27f3d5251 Merge pull request #1259 from abarth/fn3_rebuild
fn3 shouldn't rebuild components that don't change identity
2015-09-21 15:05:14 -07:00
Collin Jackson
746134a3c9 Merge pull request #1214 from collinjackson/scale_tests
add a test for scale gestures
2015-09-21 14:47:50 -07:00
Jason Simmons
64f75399ef Some cleanup of the Sky analyzer script
* If no source path is provided, then run the analyzer on the Sky unit tests
* Fix the filter for errors found in pub cache packages
* Generalize the filter for the analyzer's "xx errors/warnings/hints found" status message

Also fix a test that caused a warning in the analyzer.
2015-09-21 14:14:30 -07:00
Jason Simmons
58b421aaf4 Ensure that EditableText always shows a cursor
Previously EditableText would render a text widget with no cursor if the text
value was empty.

Also adjust the height of the cursor widget to reflect the style's line
height, and update the cursor painting to match.
2015-09-21 14:12:55 -07:00
Adam Barth
b361a3b4a8 fn3 shouldn't rebuild components that don't change identity 2015-09-21 14:00:26 -07:00
Adam Barth
b9c06c0ade Make stateful components work in fn3 2015-09-21 11:02:36 -07:00
Ian Hickson
6a88ec6d71 Merge pull request #1248 from abarth/fn3
Prototype of fn3
2015-09-21 10:26:25 -07:00
Adam Barth
130a5cb6dc Fix analyzer warnings
We were just missing a few type casts in tests to make the analyzer happy.
2015-09-19 19:21:11 -07:00
Adam Barth
b4ff5ca6ae Prototype of fn3
This patch contains a prototype of a new widget framework. In this framework,
Components can be reused in the tree as many times as the author desires. Also,
StatefulComponent is split into two pieces, a ComponentConfiguration and a
ComponentState. The ComponentConfiguration is created by the author and can be
reused as many times as desired. When mounted into the tree, the
ComponentConfiguration creates a ComponentState to hold the state for the
component. The state remains in the tree and cannot be reused.
2015-09-18 23:17:52 -07:00
krisgiesing
93ebc9e417 Merge pull request #1242 from krisgiesing/master
Fix Rect intersection; add test
2015-09-18 15:28:35 -07:00
Kris Giesing
c52b6fb9e8 Fix Rect intersection; add test 2015-09-18 15:22:59 -07:00