diff --git a/README.md b/README.md index b34316f..98b569c 100644 --- a/README.md +++ b/README.md @@ -606,8 +606,8 @@ A Check Box is a FlxUIGroup which contains three objects: a "box" image, a "chec Attributes: * ```x```/```y```, ```use_def```, ```group``` -* ```check_src``` - source image for box (not 9-sliceable, not scaleable) -* ```box_src``` - source image for check mark (not 9-sliceable, not scaleable) +* ```check_src``` - source image for check mark (not 9-sliceable, not scaleable) +* ```box_src``` - source image for box (not 9-sliceable, not scaleable) * ```text_x``` / ```text_y``` - label offsets * ```label``` - text to show * ```context``` - FireTongue context (see Button) @@ -624,8 +624,8 @@ Child tags: *If you supply `````` or `````` child tags instead of their attribute equivalents, FlxUI will treat them as full-fledged `````` or `````` tags to load for the checkmark and box assets. You'll want to use this method if you want to do something complicated, like load a scaled sprite, or a 9-slice-scaled sprite, that you can't normally accomplish with the src attributes, which just load a static image as-is. Event: -* name - "click_checkbox" -* params - as defined by user, but with this one automatically added to the list at the end: "checked:true" or "checked:false" +* name - "click_check_box" +* params - as defined by user, but with this one automatically added to the list at the end: ```{name:"checked", value:false}``` or ```{name:"checked", value:true}``` ## 7. Text (FlxUIText) `````` diff --git a/flixel/addons/ui/FlxInputText.hx b/flixel/addons/ui/FlxInputText.hx index b58d975..2bdbea8 100644 --- a/flixel/addons/ui/FlxInputText.hx +++ b/flixel/addons/ui/FlxInputText.hx @@ -272,15 +272,37 @@ class FlxInputText extends FlxText } /** - * Draw the caret in addition to the text. + * Draw the background, border and caret in addition to the text. */ override public function draw():Void { + regenGraphic(); + checkEmptyFrame(); + + if (alpha == 0 || _frame.type == EMPTY) + return; + + if (dirty) // rarely + calcFrame(useFramePixels); + drawSprite(fieldBorderSprite); drawSprite(backgroundSprite); - - super.draw(); - + + for (camera in getCamerasLegacy()) + { + if (!camera.visible || !camera.exists || !isOnScreen(camera)) + continue; + + if (isSimpleRender(camera)) + drawSimple(camera); + else + drawComplex(camera); + + #if FLX_DEBUG + FlxBasic.visibleCount++; + #end + } + // In case caretColor was changed if (caretColor != caret.color || caret.height != size + 2) { @@ -288,6 +310,11 @@ class FlxInputText extends FlxText } drawSprite(caret); + + #if FLX_DEBUG + if (FlxG.debugger.drawDebug) + drawDebug(); + #end } /** @@ -690,8 +717,9 @@ class FlxInputText extends FlxText // Generate the properly sized caret and also draw a border that matches that of the textfield (if a border style is set) // borderQuality can be safely ignored since the caret is always a rectangle + final caretHeight = Std.int(size + 2); var cw:Int = caretWidth; // Basic size of the caret - var ch:Int = Std.int(size + 2); + var ch:Int = caretHeight; // Make sure alpha channels are correctly set var borderC:Int = (0xff000000 | (borderColor & 0x00ffffff)); @@ -705,29 +733,42 @@ class FlxInputText extends FlxText // No border, just make the caret caret.makeGraphic(cw, ch, caretC, false, caretKey); caret.offset.x = caret.offset.y = 0; - + case SHADOW: // Shadow offset to the lower-right - cw += Std.int(borderSize); - ch += Std.int(borderSize); // expand canvas on one side for shadow + final absSize = Math.abs(borderSize); + cw += Std.int(absSize); + ch += Std.int(absSize); // expand canvas on one side for shadow caret.makeGraphic(cw, ch, FlxColor.TRANSPARENT, false, caretKey); // start with transparent canvas - var r:Rectangle = new Rectangle(borderSize, borderSize, caretWidth, Std.int(size + 2)); + final r:Rectangle = new Rectangle(absSize, absSize, caretWidth, caretHeight); caret.pixels.fillRect(r, borderC); // draw shadow r.x = r.y = 0; caret.pixels.fillRect(r, caretC); // draw caret caret.offset.x = caret.offset.y = 0; - + + case SHADOW_XY(shadowX, shadowY): + // Shadow offset to the lower-right + cw += Std.int(Math.abs(shadowX)); + ch += Std.int(Math.abs(shadowY)); // expand canvas on one side for shadow + caret.makeGraphic(cw, ch, FlxColor.TRANSPARENT, false, caretKey); // start with transparent canvas + final r:Rectangle = new Rectangle(Math.max(0, shadowX), Math.max(0, shadowY), caretWidth, caretHeight); + caret.pixels.fillRect(r, borderC); // draw shadow + r.x -= shadowX; + r.y -= shadowY; + caret.pixels.fillRect(r, caretC); // draw caret + caret.offset.x = shadowX < 0 ? -shadowX : 0; + caret.offset.y = shadowY < 0 ? -shadowY : 0; + case OUTLINE_FAST, OUTLINE: // Border all around it - cw += Std.int(borderSize * 2); - ch += Std.int(borderSize * 2); // expand canvas on both sides + final absSize = Math.abs(borderSize); + cw += Std.int(absSize * 2); + ch += Std.int(absSize * 2); // expand canvas on both sides caret.makeGraphic(cw, ch, borderC, false, caretKey); // start with borderColor canvas - var r = new Rectangle(borderSize, borderSize, caretWidth, Std.int(size + 2)); + final r = new Rectangle(absSize, absSize, caretWidth, caretHeight); caret.pixels.fillRect(r, caretC); // draw caret // we need to offset caret's drawing position since the caret is now larger than normal - caret.offset.x = caret.offset.y = borderSize; - - case _: //temp fix for 5.9.0 + caret.offset.x = caret.offset.y = absSize; } // Update width/height so caret's dimensions match its pixels caret.width = cw; diff --git a/flixel/addons/ui/FlxUICheckBox.hx b/flixel/addons/ui/FlxUICheckBox.hx index 92a2322..be00587 100644 --- a/flixel/addons/ui/FlxUICheckBox.hx +++ b/flixel/addons/ui/FlxUICheckBox.hx @@ -54,7 +54,7 @@ class FlxUICheckBox extends FlxUIGroup implements ILabeled implements IFlxUIClic { params = []; } - var nb:NamedBool = {name: "checked", value: false}; + var nb:NamedBool = {name: "checked", value: checked}; params.push(nb); return params; }