stagexl_main_menu 1.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new50

StageXL Main Menu #

Main Menu is a package for StageXL which allows developers to easily add a main menu to their project

alt text

Example #

MainMenu mainMenu = MainMenu();
stage.addChild(mainMenu);

Adding items #

MenuButton file = mainMenu.addMenuItem("File");

file.addMenuItem("New").onMouseClick.listen((Event e) {
  print("New was clicked");
});

file.addMenuItem("Open");

file.addSeperator();

Adding sub items #

file.addMenuItem("Open Recent")..addMenuItem("File 1")..addMenuItem("File 2");

Adding checkbox items #

CheckboxMenuItem cb = file.addCheckboxMenuItem("cool", true);
cb.onIsCheckedChanged.listen((Event e) {
  print(cb.isChecked);
});

Adding another menu button #

mainMenu.addMenuItem("Edit")..addMenuItem("Cut")..addMenuItem("Copy");

Adding styling #

mainMenu
  ..fileMenuBackColor = 0xff303030
  ..menuButtonBackColor = 0xff303030
  ..menuButtonHighlightColor = 0xff505050
  ..menuButtonTextColor = 0xffCCCCCC
  ..menuButtonTextSize = 15
  ..menuItemBackColor = 0xff262626
  ..menuItemHighlightColor = 0xff505050
  ..menuItemTextColor = 0xffffffff
  ..menuItemTextSize = 15
  ..seperatorColor = 0xffCCCCCC;

sizing and positioning #

stage.onResize.listen(onResize);

void onResize(Event e) {
  mainMenu.x = 0;
  mainMenu.y = 0;
  mainMenu.width = stage.stageWidth;
}

1.0.1 #

  • Formatting and minor performance enhancements

1.0.0 - 06/02/2018. #

  • Initial version

example/main.dart

import 'dart:async';
import 'dart:html' as html;
import 'package:stagexl/stagexl.dart';

import 'package:stagexl_main_menu/stagexl_main_menu.dart';

MainMenu mainMenu;
Stage stage;

Future<Null> main() async {
  StageOptions options = StageOptions()
    ..backgroundColor = Color.White
    ..renderEngine = RenderEngine.WebGL;

  var canvas = html.querySelector('#stage');
  stage = Stage(canvas, width: 1280, height: 800, options: options);

  var renderLoop = RenderLoop();
  renderLoop.addStage(stage);

  MainMenu mainMenu = MainMenu();
  stage.addChild(mainMenu);

  //add a menu item
  MenuItem file = mainMenu.addMenuItem("File");
  
  file.addMenuItem("New").onMouseClick.listen((Event e) {
    print("New was clicked");
  });

  file.addMenuItem("Open");

  //add a seperator
  file.addSeperator();

  //add sub menu items
  file.addMenuItem("Open Recent")..addMenuItem("File 1")..addMenuItem("File 2");

  //add a checkbox and listen for clicks
  CheckboxMenuItem cb = file.addCheckboxMenuItem("cool", true);
  cb.onIsCheckedChanged.listen((Event e) {
    print(cb.isChecked);
  });

  //add another menu item
  mainMenu.addMenuItem("Edit")..addMenuItem("Cut")..addMenuItem("Copy");

  //set some styles
  mainMenu
    ..fileMenuBackColor = 0xff303030
    ..menuButtonBackColor = 0xff303030
    ..menuButtonHighlightColor = 0xff505050
    ..menuButtonTextColor = 0xffCCCCCC
    ..menuButtonTextSize = 15
    ..menuItemBackColor = 0xff262626
    ..menuItemHighlightColor = 0xff505050
    ..menuItemTextColor = 0xffffffff
    ..menuItemTextSize = 15
    ..seperatorColor = 0xffCCCCCC;

  stage.onResize.listen(onResize);
  onResize(null);
}

void onResize(Event e) {
  mainMenu.x = 0;
  mainMenu.y = 0;
  mainMenu.width = stage.stageWidth;
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  stagexl_main_menu: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:stagexl_main_menu/stagexl_main_menu.dart';
  
Version Uploaded Documentation Archive
1.0.1 Feb 6, 2019 Go to the documentation of stagexl_main_menu 1.0.1 Download stagexl_main_menu 1.0.1 archive
1.0.0 Feb 5, 2019 Go to the documentation of stagexl_main_menu 1.0.0 Download stagexl_main_menu 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1

Platforms

Detected platforms: web

Primary library: package:stagexl_main_menu/stagexl_main_menu.dart with components: html.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
stagexl ^1.1.0 1.4.0+2
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.1.1
petitparser 2.1.1
typed_data 1.1.6
xml 3.3.1