haxeui / haxeui-theme-kenney

10 stars 2 forks source link

Kha color "leaks" into theme #3

Open anissen opened 3 years ago

anissen commented 3 years ago

Changing the color of the kha.graphics2.Graphics-object affects the colors in this theme.

For instance:

g2.color = kha.Color.White;
screen.renderTo(g2);

image

And:

g2.color = kha.Color.Green;
screen.renderTo(g2);

image

ianharrigan commented 3 years ago

Huh, thats interesting - do you have full test app to play with? (just we are on the exact same page)

anissen commented 3 years ago

Sure, I'll make a minimal project that reproduces this issue!

anissen commented 3 years ago

Here's a minimal project setup to reproduce this issue:

Main.hx

package;

import kha.Assets;
import kha.Framebuffer;
import kha.System;

class Main {
    public static function main() {
        System.start({title: "HaxeUI issue", width: 800, height: 600}, function (_) {
            Assets.loadEverything(function () {
                haxe.ui.Toolkit.theme = "kenney";
                haxe.ui.Toolkit.init({ showFPS: true });

                final screen = haxe.ui.core.Screen.instance;
                final ui = haxe.ui.macros.ComponentMacros.buildComponent("ui.xml");
                screen.addComponent(ui);

                function render(frames: Array<Framebuffer>) {
                    var g2 = frames[0].g2;
                    g2.begin(true, kha.Color.White);

                    g2.color = kha.Color.Yellow;
                    screen.renderTo(g2);

                    g2.end();
                }

                System.notifyOnFrames(function (frames) { render(frames); });
            });
        });
    }
}

ui.xml

<vbox width="100%" height="500">
    <frame text="Code" width="100%" height="100%">
        <vbox width="100%" height="100%">
            <textarea id="script" width="100%" height="100%" text="I am a text area 1" style="font-size: 16px; font-name: 'BrassMono';" />
            <button width="100%" text="Reload" />
        </vbox>
    </frame>
</vbox>

image

And here's the zipped files (with Kha/ and libs/{haxeui-theme-kenney,haxeui-kha,haxeui-core}/):

haxeui-issue.zip

By the way, I'm using...

ianharrigan commented 3 years ago

OK, that should be fixed now in latest haxeui-kha (git version).

If thats working can you close this?

Cheers, Ian