frappe icon indicating copy to clipboard operation
frappe copied to clipboard

Ideas around additional libraries

Open danschultz opened this issue 9 years ago • 4 comments

Some ideas around additional libraries.

frappe/mouse.dart

A library that defines mouse input properties and events. Can be imported with import 'package:frappe/mouse.dart'.

final Property<Point> position

A property of the current mouse position.

final Property<bool> isPressed

A property indicating if the primary mouse button is pressed.

frappe/window.dart

A library that defines window properties and events. Can be imported with import 'package:frappe/window.dart'.

final Property<Rectangle> outerBounds

A property that contains the bounds of the current window, including browser chrome, UI controls, etc.

final Property<Rectangle> innerBounds

A property that contains the bounds of the current window, excluding browser chrome, UI controls, etc.

frappe/time.dart

A library that defines events for time. Can be imported with import 'package:frappe/time.dart'.

Stream<DateTime> every(Duration period)

Emits an event with a DateTime after each period.

Stream<Duration> fps(int frameRate)

Emits a duration at the desired frame rate, where duration is the time between the last frame and current frame.

danschultz avatar Mar 01 '15 11:03 danschultz

Some cool ideas. One thing to be aware of is that frappe is currently usable outside the browser. Should not be an issue as long as you're careful what goes where

Andersmholmgren avatar Mar 01 '15 23:03 Andersmholmgren

One thing to be aware of is that frappe is currently usable outside the browser. Should not be an issue as long as you're careful what goes where

Yup, mouse.dart and window.dart would depend on dart:html, time.dart would not. Hopefully this'd be obvious when using them, unless you can build UI's in Dart outside the browser one day.

The other option is to have html.dart, which would include window and mouse properties. But, you'd probably end up having to prefix the properties with window or mouse. For instance:

import 'package:frappe/html.dart';

mousePosition.listen(print);
windowInnerBounds.listen(print);

// as opposed to:

import 'package:frappe/mouse.dart' as mouse;
import 'package:frappe/window.dart' as window;

mouse.position.listen(print);
window.innerBounds.listen(print);

I like for syntax for the later case a bit more.

danschultz avatar Mar 03 '15 04:03 danschultz

Or you could prefix window and mouse using classes inside html.dart...

// html.dart
library frappe.html;

class WindowProperties {
  final Property<Rectangle> innerBounds = new Property(...);
}

final window = new WindowProperties()

// main.dart
import 'package:frappe/html.dart';

window.innerBounds.listen(print);

danschultz avatar Mar 03 '15 04:03 danschultz

I think mouse.dart and window.dart are fine. I'm just paranoid of any browser dependencies sneaking into frappe.dart

Even though I'm using frappe in the browser, I've gone to great pains to keep code that depends on dart:html to an absolute minimum. All my unit tests that test all the frappe related code runs outside the browser. On Tue, 3 Mar 2015 at 3:18 pm, Dan Schultz [email protected] wrote:

Or you could prefix window and mouse using classes inside html.dart...

class WindowProperties { final Property<Rectangle> innerBounds = new Property(...); } final window = new WindowProperties() // main.dartimport 'package:frappe/html.dart';

window.innerBounds.listen(print);

— Reply to this email directly or view it on GitHub https://github.com/danschultz/frappe/issues/33#issuecomment-76884641.

Andersmholmgren avatar Mar 03 '15 19:03 Andersmholmgren