https://linen.dev logo
Join Discord
Powered by
# haxe-ui
  • b

    bright-gpu-74537

    09/03/2022, 8:33 AM
    Sorry, for the late reply, so yeah, as nothingispossible says, haxeui builds haxe code, and
    var error-label
    isnt a valid haxe identifier... ... that said, in various places haxeui will attempt to change variable names into "safe" versions (so
    error-label
    would become
    errorLabel
    ), so i must have missed one somewhere... ill check it out
  • b

    bright-gpu-74537

    09/03/2022, 8:34 AM
    quick fix: change the label id. However, technically that code should have run just fine
  • b

    bright-gpu-74537

    09/03/2022, 9:34 AM
    are you using an old version of haxeui? (maybe haxelib version?), your code runs fine here - make sure to use the git version of haxeui-core + whatever backend you are using
  • a

    astonishing-lifeguard-55916

    09/03/2022, 9:38 AM
    oh i guess i have an outdated version then, i'll get the git vertion later then, thanks
  • b

    bright-gpu-74537

    09/03/2022, 9:39 AM
    haxelib version is woefully out of date (6+ months!), ill be releasing 1.5 next weekend, but in the meantime, yeah, better to use git versions
  • b

    blue-lock-94355

    09/03/2022, 11:10 AM
    @bright-gpu-74537 Hi, I use Heaps for my game so my question is how to pass
    h2d.Tile
    to HaxeUI to display it? The reason why I don't use images from files and specify them in xml file as string is because I have a texture atlas from which I extract sub tiles I have tried to create sub-tile and parent it to the component, but this solution does not suit for me
  • b

    bright-gpu-74537

    09/03/2022, 11:13 AM
    i guess you could create a wrapper haxeui component? One that display the tile? In haxeui-heaps type for image data is:
    typedef ImageData = hxd.BitmapData;
    so that might be an option too
  • b

    bright-gpu-74537

    09/03/2022, 11:14 AM
    although i cant see a "toBitmap" or something in h2d.Tile
  • b

    bright-gpu-74537

    09/03/2022, 11:16 AM
    i guess you could use
    tile.getTexture().capturePixels(...)
    and then turn that into a bitmap (?), but it all feels a little smelly... i think the best option would be a wrapper component, no?
  • b

    bright-gpu-74537

    09/03/2022, 11:20 AM
    (can you share a project i can run to "see" things? )
  • b

    blue-lock-94355

    09/03/2022, 11:31 AM
    oh, yes, I have already tried your solution before, but I made I mistake - I have use
    Tile
    instead of
    Bitmap
    so 1. is it possible to add
    Bitmap
    to the
    Toolkit
    and use it in
    haxe.ui.components.Image
    as
    resource
    ? 2. is it possible to directly set
    Bitmap
    to the
    haxe.ui.components.Image
    ?
  • b

    blue-lock-94355

    09/03/2022, 11:32 AM
    @bright-gpu-74537 I cant share my project because it is big and it is difficult to extract some code from it
  • b

    bright-gpu-74537

    09/03/2022, 11:38 AM
    1. you cant "add bitmap to the toolkit" really. But you could create haxeui wrapper around bitmap
  • b

    bright-gpu-74537

    09/03/2022, 11:38 AM
    2. not bitmap, no, but BitmapData
  • b

    blue-lock-94355

    09/03/2022, 11:39 AM
    how to set
    BitmapData
    to
    Image
    ?
  • b

    bright-gpu-74537

    09/03/2022, 11:40 AM
    image.resource... it accepts various types, one of which is ImageData, which on heaps is hxd.BitmapData
  • b

    bright-gpu-74537

    09/03/2022, 11:40 AM
    unless its not working... ill test it... maybe the backend needs to explicitly support it, i dont remember
  • b

    blue-lock-94355

    09/03/2022, 11:43 AM
    oh
    resource
    is
    haxe.ui.util.Variant
    , yeah thx for solution, it should work
  • b

    bright-gpu-74537

    09/03/2022, 11:43 AM
    yea, although, im not sure if it needs something in the backend... trying now
  • b

    bright-gpu-74537

    09/03/2022, 11:54 AM
    seems fine:
  • b

    bright-gpu-74537

    09/03/2022, 11:55 AM
    Copy code
    haxe
            var bmp1 = new hxd.BitmapData(100, 100);
            bmp1.fill(0, 0, 100, 100, 0xff0000ff);
            bmp1.line(0, 0, 100, 100, 0xffffff00);
            bmp1.line(100, 0, 0, 100, 0xffffff00);
    
            var bmp2 = new hxd.BitmapData(100, 100);
            bmp2.fill(0, 0, 100, 100, 0xffff0000);
            bmp2.line(0, 0, 100, 100, 0xff000000);
            bmp2.line(100, 0, 0, 100, 0xff000000);
            
            var bmp3 = new hxd.BitmapData(100, 100);
            bmp3.fill(0, 0, 100, 100, 0xff00ff00);
            bmp3.line(0, 0, 100, 100, 0xffff0000);
            bmp3.line(100, 0, 0, 100, 0xffff0000);
            
            // just so we can use it from styles too!
            StyleLookupMap.instance.set("bmp1", bmp1);
            StyleLookupMap.instance.set("bmp2", bmp2);
            StyleLookupMap.instance.set("bmp3", bmp3);
            
            myImage.resource = bmp2;
            myButton.icon = bmp1;
  • b

    bright-gpu-74537

    09/03/2022, 11:55 AM
    Copy code
    xml
        <image id="myImage" />
        
        <button id="myButton" text="Some Button" /> 
        
        <style>
            .myStyle {
                icon: lookup("bmp1");
            }
            .myStyle:hover {
                icon: lookup("bmp2");
            }
            .myStyle:down {
                icon: lookup("bmp3");
            }
        </style>
        <button styleName="myStyle" text="Another Button" iconPosition="top" />
  • b

    blue-lock-94355

    09/03/2022, 11:56 AM
    do you know how to convert
    Bitmap
    or
    Tile
    to
    BitmapData
    ?
  • b

    bright-gpu-74537

    09/03/2022, 11:57 AM
    i dont im afraid, i think you can get the texture, then capture the pixels and then create a bitmap data... ... maybe
  • b

    bright-gpu-74537

    09/03/2022, 11:57 AM
    Copy code
    capturePixels(face:Int = 0, mipLevel:Int = 0, ?region:IBounds):Pixels
    Downloads the current texture data from the GPU. Beware, this is a very slow operation that shouldn't be done during rendering.
  • b

    bright-gpu-74537

    09/03/2022, 11:58 AM
    there may be better ways though (im certainly no heaps expert)
  • f

    full-journalist-82607

    09/04/2022, 3:43 PM
    Hi, I want to change the parent component of a component to the screen for example, byt it doesnt' seem to work. Is it normal ? or is it a bug ?
    Copy code
    <hbox id="hbox" style="padding: 5px;">
        <button id="button" text="Click Me!" onclick="var screen = button.screen; button.parentComponent.removeComponent(button);screen.addComponent(button);" style="font-size: 24px;" />
    </hbox>
    It doesn't work even after a timer or callLater
  • b

    bright-gpu-74537

    09/04/2022, 3:48 PM
    i think replace "var screen" with "var parentComponent" and you should be fine
  • b

    bright-gpu-74537

    09/04/2022, 3:48 PM
    ie, remove the child from the parent, then add it again
  • b

    bright-gpu-74537

    09/04/2022, 3:49 PM
    oh, hang on, i read that all wrong
1...124212431244...1687Latest