Skip to content

Commit

Permalink
NOTE; add unique id to default control names, fix #16, see issue for …
Browse files Browse the repository at this point in the history
…discussion
  • Loading branch information
ruby0x1 committed Sep 6, 2016
1 parent 28dbfa8 commit 1f6a58e
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion mint/Button.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Button extends Control {

options = _options;

def(options.name, 'button');
def(options.name, 'button.${Helper.uniqueid()}');
def(options.mouse_input, true);

super(options);
Expand Down
2 changes: 1 addition & 1 deletion mint/Checkbox.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Checkbox extends Control {

options = _options;

def(options.name, 'checkbox');
def(options.name, 'checkbox.${Helper.uniqueid()}');
def(options.mouse_input, true);

super(_options);
Expand Down
2 changes: 1 addition & 1 deletion mint/Control.hx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class Control {

children = [];

name = def(_options_.name, 'control');
name = def(_options_.name, 'control.${Helper.uniqueid()}');
user = _options_.user;
depth_offset = def(_options_.depth, 0);

Expand Down
2 changes: 1 addition & 1 deletion mint/Dropdown.hx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Dropdown extends Control {

options = _options;

def(options.name, 'dropdown');
def(options.name, 'dropdown.${Helper.uniqueid()}');
def(options.mouse_input, true);

//create the base control
Expand Down
2 changes: 1 addition & 1 deletion mint/Image.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Image extends Control {

options = _options;

def(options.name, 'image');
def(options.name, 'image.${Helper.uniqueid()}');

super(_options);

Expand Down
2 changes: 1 addition & 1 deletion mint/Label.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Label extends Control {

options = _options;

def(options.name, 'label');
def(options.name, 'label.${Helper.uniqueid()}');

super(options);

Expand Down
2 changes: 1 addition & 1 deletion mint/List.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class List extends Control {
items = [];
options = _options;

def(options.name, 'list');
def(options.name, 'list.${Helper.uniqueid()}');
def(options.mouse_input, true);

super(options);
Expand Down
2 changes: 1 addition & 1 deletion mint/Panel.hx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Panel extends Control {

options = _options;

def(options.name, 'panel');
def(options.name, 'panel.${Helper.uniqueid()}');

super(options);

Expand Down
2 changes: 1 addition & 1 deletion mint/Progress.hx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Progress extends Control {

options = _options;

def(options.name, 'progress');
def(options.name, 'progress.${Helper.uniqueid()}');

super(options);

Expand Down
2 changes: 1 addition & 1 deletion mint/Scroll.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Scroll extends Control {

options = _options;

def(options.name, 'scroll');
def(options.name, 'scroll.${Helper.uniqueid()}');
def(options.mouse_input, true);

units_to_scroll_h = def(options.units_to_scroll_h, 16);
Expand Down
2 changes: 1 addition & 1 deletion mint/Slider.hx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Slider extends Control {

options = _options;

def(options.name, 'slider');
def(options.name, 'slider.${Helper.uniqueid()}');
def(options.mouse_input, true);

max = def(options.max, 1);
Expand Down
2 changes: 1 addition & 1 deletion mint/TextEdit.hx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class TextEdit extends Control {

options = _options;

def(options.name, 'textedit');
def(options.name, 'textedit.${Helper.uniqueid()}');
def(options.mouse_input, true);
def(options.key_input, true);

Expand Down
2 changes: 1 addition & 1 deletion mint/Window.hx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Window extends Control {
onclose = new Signal();
oncollapse = new Signal();

def(options.name, 'window');
def(options.name, 'window.${Helper.uniqueid()}');
def(options.mouse_input, true);

super(options);
Expand Down
19 changes: 19 additions & 0 deletions mint/types/Types.hx
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,23 @@ class Helper {

} //in_rect

static public function uniqueid(?val:Null<Int>) : String {

if(val == null) val = Std.random(0x7fffffff);

function to_char(value:Int) : String {
if (value > 9) {
var ascii = (65 + (value - 10));
if (ascii > 90) { ascii += 6; }
return String.fromCharCode(ascii);
} else return Std.string(value).charAt(0);
} //to_char

var r = Std.int(val % 62);
var q = Std.int(val / 62);
if (q > 0) return uniqueid(q) + to_char(r);
else return Std.string(to_char(r));

} //uniqueid

} //Helper
1 change: 0 additions & 1 deletion tests/test_luxe/src/tests/KitchenSink.hx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ class KitchenSink extends State {

new mint.Button({
parent: canvas,
name: 'button2',
x: 76, y: 52, w: 32, h: 32,
text: 'O',
options: { color_hover: new Color().rgb(0xf6007b) },
Expand Down

0 comments on commit 1f6a58e

Please sign in to comment.