27 Commits

Author SHA1 Message Date
Adam Barth
8f0efd54ff Add the ability to draw a foreground box decoration
This feature lets you create effects similar to the "outline" property in CSS.
2015-08-19 09:36:40 -07:00
Adam Barth
dea3a0922c Add package:sky/rendering.dart
Similar to widgets.dart, rendering.dart exports the entire rendering layer.
Also, update the examples to use rendering.dart and widgets.dart. Also clean up
some exports so that the examples have more sensible imports.
2015-08-18 21:39:51 -07:00
Adam Barth
50bfdedbf4 Split box.dart into many files
Sadly, box.dart has grown much longer than 1000 lines. This patch splits it up
into several files based on the class hierarchy. Fortunately, many of these
classes are loosely coupled to each other.
2015-08-18 20:55:32 -07:00
Adam Barth
5b40e03129 RenderImage should handle the case of a null image
When given a null image, RenderImage should be as small as possible (isntead of
being NaNxNaN).

Also, plumb ImageFit and ImageRepeat through the various image widgets.
2015-08-18 20:05:52 -07:00
Adam Barth
6cc103cf07 Borders on Containers shouldn't overlap the content
This CL inflates the padding of Container to account for the borders so that
the borders are allocated space in the layout and don't draw behind the
Container's child.
2015-08-18 16:10:40 -07:00
Adam Barth
516616aaf6 Container should expand in dimensions without constraints
... as long as it doesn't have a child. If it has a child, it should size
according to that child. Essentially, if Container doesn't have a child, it
pretends like it has a child that expands to fill its constraints.
2015-08-18 10:06:49 -07:00
Adam Barth
91a783bf62 Rename Widget.root to Widget.renderObject
The name `root` is confusing because this value isn't the root of anything.
It's just the associated `RenderObject` instance.
2015-08-17 14:15:26 -07:00
Collin Jackson
779f5743e5 Refactor of text rendering into painting layer 2015-08-14 13:30:56 -07:00
Adam Barth
2701b469cf Merge pull request #545 from abarth/image_resource
Use ImageResource instead of Future<sky.Image>
2015-08-11 08:35:49 -07:00
Hans Muller
d2d9ae134d The IgnorePointer class enables one to cut a widget subtree off from pointer events. This is useful when a sibling should not shield pointer events from overlapping siblings below it.
Added a ScrollListener listener to Scrollable. The ScrollListener runs each time the Scrollable's scrollOffset changes. This can be used to keep overlay widgets in sync with a Scrollable below them.

Removed the Scrollable ScrollClient API. It was no longer used and was clumsy to use as a ScrollListener.

Added global function findScrollableAncestor() to scrollable.dart.

Added examples/widgets/overlay_geometry.dart. The app's Scaffold is contained by a Stack. The Stack is used to display green overlay "Markers" at the corners of the most recently selected list item and where the corresponding tap occurred. The app uses widget.localToGlobal() to compute the global overlay positions of the markers. The ScrollListener is used to keep the markers' positions up to date.
2015-08-11 08:29:30 -07:00
Adam Barth
9f228349e9 Use ImageResource instead of Future<sky.Image>
Using ImageResource solves two problems:

1) Listeners can be notified synchronously when the sky.Image is already
   available. This change removes flash of 0x0 layout when moving an
   already-cached image around in the render tree.

2) In the future, when we support animated images, we can notify listeners
   multiple times whenever a new image is available.
2015-08-10 20:43:32 -07:00
Adam Barth
2f3af49b0a Improve error messages for StyledText
Now they give you a hint as to what went wrong. Also, in checked mode, they now
throw during construction instead of during building.

Fixes #418
2015-08-06 22:42:13 -07:00
Adam Barth
4a70cfed5f Rename various text-related classes
- Inline -> Pargraph. This class is actually a box, not an inline. It's really
   a wrapper for RenderParagraph, so Paragraph is the normal name.

 - InlineBase -> RenderInline. The name we used in C++ for the base class of
   all inlines was RenderInline, which removes the ugly "Base" suffix.

 - InlineText -> RenderText. Aligns this name with C++.

 - InlineStyle -> RenderStyled. Matches the foregoing pattern.
2015-08-06 22:26:02 -07:00
Adam Barth
870376dab1 Teach ScrollableBlock how to scroll horizontally
Now ScrollableBlock can combine a horizontally scrolling viewport with a
horizontal block.

Also rename ViewportScrollDirection to just ScrollDirection for less verbosity.
2015-08-05 18:10:03 -07:00
Adam Barth
2a4209553f Support horizontal scrolling in ScrollableViewport 2015-08-05 16:18:15 -07:00
Adam Barth
07afda506a Add a basic radial reaction to the switch
We still need to tune the various parameters, but this patch is a start.
2015-08-05 09:50:33 -07:00
Hans Muller
bce1660988 complete 2015-08-04 15:31:56 -07:00
Adam Barth
054ebbf3cf Rename widgets/widget.dart to widgets/framework.dart
It was confusing to have both widget.dart and widgets.dart
2015-08-04 11:13:33 -07:00
James Robinson
56a4a8ad81 Add RenderToggleable base and use in Switch and Checkbox
This refactors Checkbox to own a RenderObject similar to how Switch was
refactored in https://github.com/domokit/sky_engine/pull/376 and
extracts common functionality for toggleable renderers into a base
class.  Switch and Checkbox's render objects derive from this base
class to add their own custom painting and theming logic.
2015-08-04 10:45:30 -07:00
James Robinson
53163f8b99 Teach event system about disposition and make 'consumed' disposition terminal
This introduces the notion of event disposition and allows event
targets (widgets and render objects) to consume events that should not
be processed further. This is needed by the Switch component in the
Drawer in the stocks example. The Switch is embedded in a DrawerItem.
The Switch handles the gesture tap event to toggle its state and should
handle pointer events to allow swiping and draw its own radial
reaction. The DrawerItem also handles gesture taps to allow toggling
the switch value when tapping anywhere on the drawer and to draw its
own ink splash. When tapping on the switch, both the switch's render
object and the DrawerItem's listener are in the event dispatch path.
The Switch needs to signal in some fashion that it consumed the event
so the DrawerItem does not also try to toggle the switch's state.
2015-08-03 17:31:30 -07:00
James Robinson
445f4ee8cd Make Switch a standalone class with a custom RenderObject
This changes Switch from being a subclass of the Toggleable widget to
being a standalone Component with a custom RenderObject. This is to
enable adding Switch-specific radial reaction animations in a
subsequent patch. The CustomPaint logic that Toggleable was using does
not provide a nice way for a class and its subclass to both participate
in deciding to repaint.
2015-07-30 14:53:28 -07:00
Hixie
eb90899aab Track global keys globally.
Assert that there are no duplicates.
Export GlobalKey from basic.dart, so that people don't have to import widgets.dart just for that.
Fix the "initialFocus" feature which actually didn't work.
2015-07-23 11:10:04 -07:00
Hixie
4dacd69b41 Don't set keys on images, etc, pre-emptively.
In theory, before, if you had the same image twice in a scrolling container, you'd get an assertion with no way around it.
This makes those nodes not bother making keys by default, which is cheaper and more correct.
2015-07-22 10:05:19 -07:00
Hixie
74575775bd Introduce an explicit Key type.
This fixes some theoretical bugs whereby we were using hashCode to try
to get unique keys for objects, but really we wanted object identity.
It also lays the groundwork for a new GlobalKey concept.

I tried to keep the impact on the code minimal, which is why the "Key"
constructor is actually a factory that returns a StringKey. The code
has this class hierarchy:

```
   KeyBase
    |
   Key--------------+---------------+
    |               |               |
   StringKey    ObjectKey       UniqueKey
```

...where the constructors are Key and Key.stringify (StringKey),
Key.fromObjectIdentity (ObjectKey), and Key.unique (UniqueKey).

We could instead of factory methods use regular constructors with the
following hierarchy:

```
   KeyBase
    |
   LocalKey---------+---------------+
    |               |               |
   Key      ObjectIdentityKey   UniqueKey
```

...with constructors Key, Key.stringify, ObjectIdentityKey, and
UniqueKey, but I felt that that was maybe a more confusing hierarchy.
I don't have a strong opinion on this.
2015-07-22 09:14:06 -07:00
Adam Barth
012b915704 Separate width and height parameters for Image widgets
This change makes it easier to defined only the width or the height of an image
and let the other value be filled in from the image's intrinsic aspect ratio.

Fixes #175
2015-07-21 13:46:10 -07:00
Collin Jackson
4604021dd3 Support for non-alphabetic baselines 2015-07-17 17:06:08 -07:00
Collin Jackson
633b65010c After running filter-branch, move root directory into sky/ 2015-07-16 11:54:25 -07:00