Skip to content

Commit f5fa45a

Browse files
committed
Merge branch 'dev' of https://github.com/HaxeFlixel/flixel-ui into dev
2 parents 822c55f + b94d693 commit f5fa45a

File tree

3 files changed

+62
-21
lines changed

3 files changed

+62
-21
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ A Check Box is a FlxUIGroup which contains three objects: a "box" image, a "chec
606606

607607
Attributes:
608608
* ```x```/```y```, ```use_def```, ```group```
609-
* ```check_src``` - source image for box (not 9-sliceable, not scaleable)
610-
* ```box_src``` - source image for check mark (not 9-sliceable, not scaleable)
609+
* ```check_src``` - source image for check mark (not 9-sliceable, not scaleable)
610+
* ```box_src``` - source image for box (not 9-sliceable, not scaleable)
611611
* ```text_x``` / ```text_y``` - label offsets
612612
* ```label``` - text to show
613613
* ```context``` - FireTongue context (see Button)
@@ -624,8 +624,8 @@ Child tags:
624624
*If you supply ```<check>``` or ```<box>``` child tags instead of their attribute equivalents, FlxUI will treat them as full-fledged ```<sprite>``` or ```<chrome>``` 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.
625625

626626
Event:
627-
* name - "click_checkbox"
628-
* params - as defined by user, but with this one automatically added to the list at the end: "checked:true" or "checked:false"
627+
* name - "click_check_box"
628+
* 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}```
629629

630630
## 7. Text (FlxUIText) ```<text>```
631631

flixel/addons/ui/FlxInputText.hx

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -272,22 +272,49 @@ class FlxInputText extends FlxText
272272
}
273273

274274
/**
275-
* Draw the caret in addition to the text.
275+
* Draw the background, border and caret in addition to the text.
276276
*/
277277
override public function draw():Void
278278
{
279+
regenGraphic();
280+
checkEmptyFrame();
281+
282+
if (alpha == 0 || _frame.type == EMPTY)
283+
return;
284+
285+
if (dirty) // rarely
286+
calcFrame(useFramePixels);
287+
279288
drawSprite(fieldBorderSprite);
280289
drawSprite(backgroundSprite);
281-
282-
super.draw();
283-
290+
291+
for (camera in getCamerasLegacy())
292+
{
293+
if (!camera.visible || !camera.exists || !isOnScreen(camera))
294+
continue;
295+
296+
if (isSimpleRender(camera))
297+
drawSimple(camera);
298+
else
299+
drawComplex(camera);
300+
301+
#if FLX_DEBUG
302+
FlxBasic.visibleCount++;
303+
#end
304+
}
305+
284306
// In case caretColor was changed
285307
if (caretColor != caret.color || caret.height != size + 2)
286308
{
287309
caret.color = caretColor;
288310
}
289311

290312
drawSprite(caret);
313+
314+
#if FLX_DEBUG
315+
if (FlxG.debugger.drawDebug)
316+
drawDebug();
317+
#end
291318
}
292319

293320
/**
@@ -690,8 +717,9 @@ class FlxInputText extends FlxText
690717
// Generate the properly sized caret and also draw a border that matches that of the textfield (if a border style is set)
691718
// borderQuality can be safely ignored since the caret is always a rectangle
692719

720+
final caretHeight = Std.int(size + 2);
693721
var cw:Int = caretWidth; // Basic size of the caret
694-
var ch:Int = Std.int(size + 2);
722+
var ch:Int = caretHeight;
695723

696724
// Make sure alpha channels are correctly set
697725
var borderC:Int = (0xff000000 | (borderColor & 0x00ffffff));
@@ -705,29 +733,42 @@ class FlxInputText extends FlxText
705733
// No border, just make the caret
706734
caret.makeGraphic(cw, ch, caretC, false, caretKey);
707735
caret.offset.x = caret.offset.y = 0;
708-
736+
709737
case SHADOW:
710738
// Shadow offset to the lower-right
711-
cw += Std.int(borderSize);
712-
ch += Std.int(borderSize); // expand canvas on one side for shadow
739+
final absSize = Math.abs(borderSize);
740+
cw += Std.int(absSize);
741+
ch += Std.int(absSize); // expand canvas on one side for shadow
713742
caret.makeGraphic(cw, ch, FlxColor.TRANSPARENT, false, caretKey); // start with transparent canvas
714-
var r:Rectangle = new Rectangle(borderSize, borderSize, caretWidth, Std.int(size + 2));
743+
final r:Rectangle = new Rectangle(absSize, absSize, caretWidth, caretHeight);
715744
caret.pixels.fillRect(r, borderC); // draw shadow
716745
r.x = r.y = 0;
717746
caret.pixels.fillRect(r, caretC); // draw caret
718747
caret.offset.x = caret.offset.y = 0;
719-
748+
749+
case SHADOW_XY(shadowX, shadowY):
750+
// Shadow offset to the lower-right
751+
cw += Std.int(Math.abs(shadowX));
752+
ch += Std.int(Math.abs(shadowY)); // expand canvas on one side for shadow
753+
caret.makeGraphic(cw, ch, FlxColor.TRANSPARENT, false, caretKey); // start with transparent canvas
754+
final r:Rectangle = new Rectangle(Math.max(0, shadowX), Math.max(0, shadowY), caretWidth, caretHeight);
755+
caret.pixels.fillRect(r, borderC); // draw shadow
756+
r.x -= shadowX;
757+
r.y -= shadowY;
758+
caret.pixels.fillRect(r, caretC); // draw caret
759+
caret.offset.x = shadowX < 0 ? -shadowX : 0;
760+
caret.offset.y = shadowY < 0 ? -shadowY : 0;
761+
720762
case OUTLINE_FAST, OUTLINE:
721763
// Border all around it
722-
cw += Std.int(borderSize * 2);
723-
ch += Std.int(borderSize * 2); // expand canvas on both sides
764+
final absSize = Math.abs(borderSize);
765+
cw += Std.int(absSize * 2);
766+
ch += Std.int(absSize * 2); // expand canvas on both sides
724767
caret.makeGraphic(cw, ch, borderC, false, caretKey); // start with borderColor canvas
725-
var r = new Rectangle(borderSize, borderSize, caretWidth, Std.int(size + 2));
768+
final r = new Rectangle(absSize, absSize, caretWidth, caretHeight);
726769
caret.pixels.fillRect(r, caretC); // draw caret
727770
// we need to offset caret's drawing position since the caret is now larger than normal
728-
caret.offset.x = caret.offset.y = borderSize;
729-
730-
case _: //temp fix for 5.9.0
771+
caret.offset.x = caret.offset.y = absSize;
731772
}
732773
// Update width/height so caret's dimensions match its pixels
733774
caret.width = cw;

flixel/addons/ui/FlxUICheckBox.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class FlxUICheckBox extends FlxUIGroup implements ILabeled implements IFlxUIClic
5454
{
5555
params = [];
5656
}
57-
var nb:NamedBool = {name: "checked", value: false};
57+
var nb:NamedBool = {name: "checked", value: checked};
5858
params.push(nb);
5959
return params;
6060
}

0 commit comments

Comments
 (0)