cellular-automata/lib/components/controls_component.dart

46 lines
1,013 B
Dart
Raw Normal View History

import 'package:angular/angular.dart';
import 'package:angular_components/angular_components.dart';
import 'package:rules_of_living/service/configuration_service.dart';
import 'package:rules_of_living/service/engine_service.dart';
import 'package:rules_of_living/src/Engine.dart';
@Component(
selector: 'sim-controls',
templateUrl: "controls_component.html",
2018-08-23 10:38:34 +00:00
directives: [
coreDirectives,
MaterialButtonComponent,
MaterialIconComponent,
MaterialTooltipDirective
],
providers: [],
styleUrls: const ["controls_component.css"],
)
class ControlsComponent {
final EngineService engineService;
Engine get engine => engineService.engine;
ControlsComponent(this.engineService);
void onStartClicked() {
engine.running = !engine.running;
}
void onStepClicked() {
engine.step();
}
void onResetClicked() {
engine.reset();
}
void onRandomClicked() {
engine.running = false;
engine.addPattern();
}
void onClearClicked() {
engine.clear();
}
}