haxeui / haxeui-kha Goto Github PK
View Code? Open in Web Editor NEWThe Kha backend of the HaxeUI framework -
Home Page: http://haxeui.org
License: MIT License
The Kha backend of the HaxeUI framework -
Home Page: http://haxeui.org
License: MIT License
If you have a component with width or height set to a percentage and you adjust the window's size, the top-most component does not reflect the changes. This works on the standard html5 target. Haven't been able to test krom.
The component extends to fit to the size of the window.
Only the size of the window at the very start of the program is respected and then it never changes.
I tried looking for any code dealing with resizing in the kha-backend, or events, and I couldn't find any traces.
<?xml version="1.0" encoding="utf-8"?>
<hbox id="main" width="100%" height="100%">
<!-- <style source="../css/main.css" /> -->
<style>
#main {
background-color: green;
}
</style>
</hbox>
Must be displayed list of dropdown's items.
Does not nothing after mouse click.
Sample available here.
haxe 3.4.2
kha from git
haxeui-kha from git
haxeui-core form git
Thanks.
It would be nice to allow haxeui-kha
(and possibly all other backends) to inject code to handle event mapping. This would be advantageous as it allows, for example, for a HaxeUI application to be put into a 3D scene and co-ord translation logic to be applied for mouse events (instead of the default processing)
The ability to side step haxeui-kha
event mapping
At the moment, when haxeui-core
adds an event, a mapEvent
function is called in the backend, this functions holds onto the event listener and the event in question in a map, it then links up an actual event using Khas Mouse.get().notify
What may be a better system is to have a class defined in module.xml
, this would default to something sensible, this could then be called instead meaning that 3rd part code could be injected into the system. This class could also have an easy way to then dispatch these events via the ComponentBase
eg:
switch (type) {
case MouseEvent.MOUSE_OVER:
if (_eventMap.exists(MouseEvent.MOUSE_OVER) == false) {
_mapper.map(MouseEvent.MOUSE_OVER, listener);
_eventMap.set(MouseEvent.MOUSE_OVER, listener);
}
}
it would be nice to get some input from @luboslenco if this makes sense and is the right way to be doing things.
A simple window with one image (jpg).
Blank screen.
Sample available here.
Haxe 3.4.2
Kha from git
haxeui-core from git
haxeui-kha from git
Thanks.
Get image files
The bytes are loaded from haxe.Resources but when trying to get the Image object from kha we get crapped data. This seems to be caused by the Js engine that recycles the data before we get it back. Hence, we get data that is null.
Here is the output:
Trace: TypeError: Cannot read property 'width' of null
at $hxClasses.kha.Image.get_realWidth (<anonymous>:50598:30)
at <anonymous>:8490:36
at Function.kha_Image.fromEncodedBytes (<anonymous>:50448:2)
at $hxClasses.haxe.ui.ToolkitAssets.imageFromBytes (<anonymous>:8489:13)
at $hxClasses.haxe.ui.ToolkitAssets.getImageFromHaxeResource (<anonymous>:8484:8)
at <anonymous>:8634:14
at $hxClasses.haxe.ui.ToolkitAssets.getImageInternal (<anonymous>:8479:4)
at $hxClasses.haxe.ui.ToolkitAssets.getImage (<anonymous>:8628:10)
at $hxClasses.haxe.ui.util.ImageLoader.load (<anonymous>:31113:33)
at $hxClasses.haxe.ui.components._Image.ResourceBehaviour.validateData (<anonymous>:14510:15)
Trace: TypeError: Cannot read property 'width' of null
at $hxClasses.kha.Image.get_realWidth (<anonymous>:50598:30)
at <anonymous>:8490:36
at Function.kha_Image.fromEncodedBytes (<anonymous>:50448:2)
at $hxClasses.haxe.ui.ToolkitAssets.imageFromBytes (<anonymous>:8489:13)
at $hxClasses.haxe.ui.ToolkitAssets.getImageFromHaxeResource (<anonymous>:8484:8)
at <anonymous>:8634:14
at $hxClasses.haxe.ui.ToolkitAssets.getImageInternal (<anonymous>:8479:4)
at $hxClasses.haxe.ui.ToolkitAssets.getImage (<anonymous>:8628:10)
at $hxClasses.haxe.ui.util.ImageLoader.load (<anonymous>:31113:33)
at $hxClasses.haxe.ui.components._Image.ResourceBehaviour.validateData (<anonymous>:14510:15)
This pull request removes the issue in the short-term. In the long-term this issue needs to be investigated in Krom.
Have a dialog open
This issue happens only in
something that has just popped up trying out haxeui-kha.
this error pops up right away
/usr/local/lib/haxe/lib/haxeui-kha/git/haxe/ui/backend/TextDisplayBase.hx:16: characters 16-34 : kha._Assets.FontList has no field arial
this is only from having things imported & not in actual use.
import haxe.ui.Toolkit;
import haxe.ui.core.Screen;
import haxe.ui.containers.HBox;
import haxe.ui.components.HSlider;
cant seem to see what the problem is to fix it on my end. just following what i have & have seen before with getting haxeui working
cheers
Control + arrow keys
should move cursor word by wordControl + a
should select all textControl + c
should copy to the clip boardControl + v
should paste from the clip boardControl + arrow keys
move cursor by single characterControl + a
does nothingControl + c
does nothing on HTML5 and segfaults on linux (though I believe the segfault is Kha and not HaxeUI)Control + v
does nothingKha HaxeUI skeleton with <textfield placeholder="Test" width="100%">
should be sufficient.
Search box for searching assets in application does not behave as expected.
When editing textfields of numbersteppers with float values if we press repeatedly the arrows to select a section and then try to use backspace to remove text we create an error in how the fonts are rendered.
No bug should occur when editing the textfield of a numberstepper. I.e. the issue could be coming from the numberstepper adding to the pos value when using the arrow keys.
When trying to edit textfields of numbersteppers it's bug out and jams the UI. The error message in the debug console outputs this:
TypeError: Cannot read property 'xadvance' of undefined
at kha_KravurImage.getCharWidth (/home/jsnadeau/Kha/Sources/kha/Kravur.hx:99:28)
at kha_KravurImage.charactersWidth (/home/jsnadeau/Kha/Sources/kha/Kravur.hx:117:13)
at kha_Kravur.widthOfCharacters (/home/jsnadeau/Kha/Sources/kha/Kravur.hx:207:15)
at haxe_ui_backend_kha_TextField.render (/home/jsnadeau/foundsdk/haxeui-kha/haxe/ui/backend/kha/TextField.hx:866:44)
at haxe_ui_core_TextInput.renderTo (/home/jsnadeau/foundsdk/haxeui-kha/haxe/ui/backend/TextInputImpl.hx:101:9)
at haxe_ui_components_TextField.renderTo (/home/jsnadeau/foundsdk/haxeui-kha/haxe/ui/backend/ComponentImpl.hx:163:13)
at haxe_ui_components_NumberStepper.renderTo (/home/jsnadeau/foundsdk/haxeui-kha/haxe/ui/backend/ComponentImpl.hx:169:13)
If the issue is coming from the numberstepper incrementing/decrementing to the pos value when using the arrow keys removing this feature when editing the text could be a solution.
Trying to have editable numbersteppers
See the sample code here: https://github.com/sh-dave/haxeui-kha-testsuite/blob/master/src/kenneyButtonFlicker/Main.hx
// suite.addParameter('--main kenneyButtonFlicker.Main');
to pull in the proper Main function, comment out any other that might be active.Version used:
Environment name and version (e.g. Chrome 39, node.js 5.4):
Operating System and version (desktop or mobile):
Link to your project:
Icons included in the default styles (which end up as haxe resources) are not showing. This is because currently there isnt a method to extract them and turn them into kha.Image
. See: https://github.com/haxeui/haxeui-kha/blob/master/haxe/ui/backend/AssetsBase.hx#L36
That it should be possible to turn haxe resources (bytes) into usable and valid kha images
Either dig into kha and see how it does it or ask Rob (as usual!), he mentioned some time ago about possibly exposing functions to handle this, may or may not have already happened. Need to investigate
Add a scrollbar, no up/down images as there are in html5.
Latest kha (git)
Latest HaxeUI (git)
Haxe 3.2.1
When using Toolkit.scale greater than 1.0 (trying to get a decent sized ui for an android test build), the image component gets smaller for some reason. I expected the image to stay the same size, only the button should get bigger?
(What i originally wanted to use is actually the styles background-image: xxx.png
property. But this one doesn't allow to specify the scaleMode
(fit, fill, fitinside, ...) for when the component size doesn't match the image dimensions, so i tried with an image component as a quick "fix". Should i add another issue/feature request for this?)
Toolkit.scale = 1.0
Toolkit.scale = 2.0
Toolkit.scale = 3.0
@:xml('
<box styleNames="my-view">
<style>
.my-view {
width: 100%;
height: 100%;
}
.logo {
width: 100%;
height: 100%;
}
</style>
<image resource="big_kha_Logo.png" styleNames="logo" />
<button text="CLICK" styleNames="click-me" />
</box>'
)
private class View extends Box {
public function new() {
super();
}
}
class Main {
public static function main() {
kha.System.start({ width: Std.int(632 / 2), height: Std.int(612 / 2) }, function( _ ) {
kha.Assets.loadEverything(function() {
haxe.ui.Toolkit.theme = 'dark';
haxe.ui.Toolkit.init({});
haxe.ui.core.Screen.instance.addComponent(new View());
haxe.ui.core.Screen.instance.options.noBatch = true;
haxe.ui.Toolkit.scale = 3.0;
kha.System.notifyOnFrames(function( fbs ) {
final fb = fbs[0];
final g2 = fb.g2;
g2.begin(true, 0xff004040);
haxe.ui.core.Screen.instance.renderTo(g2);
g2.end();
});
});
});
}
}
latest git everything
Must be entered text from keyboard and displayed in textfield/textarea.
Does not nothing after keyboard key pressed.
Samples available here (TextArea) and here (TextField).
Haxe 3.4.2
Kha from git
haxeui-core from git
haxeui-kha from git
Thanks.
This essentially effects button icons, images, anything like that. I have set up a test project where it initially creates a render target and sets the haxeui data to it. It appears to render. It sets the icon of a button to the image and it sets the resource of an image to the render target. However, if you press the button it basically repeats the exact same thing but any subsequent presses of the button will render the graphics as nothing.
Updating the icon/image-resource should not cause the graphics to null.
Pressing the button after the initial load causes the graphics to become null.
Code included.
This may be causing problems elsewhere with Kha as I'm seeing other graphical glitches in my main app that seem somewhat similar in concept but not directly related HaxeUI. But for HaxeUI we should expect to be able to change the graphics of images or icons without them clearing.
After pressing "delete" and "end" a few times the application crashes.
End should move the caret to the end, and then delete should do nothing (as usual)
Text starts moving around like crazy.. Do it a few times and it fatally crashes on web.
Neglect the existance of the kha textbox.
http://haxeui.org/shared/kha-textarea/
It has affected me very deeply mentally... It crashed.... :(
Specifically web, I have not tried on DX, GL, Metal or any of the 9999 other backends Kha supports (it's crazy)
See the sample code here: https://github.com/sh-dave/haxeui-kha-testsuite/blob/master/src/delayedAdd/Main.hx
The component should be visible initially, without resizing the window.
When you start the sample, nothing is shown. Only when you then resize the window, the button suddenly appears.
The outer View
component contains some css styling to center the nested button. If you comment out the style
tag, the button will correctly be shown initially in the top/left corner.
If you add the main View
to the screen during startup, and only add the nested button after some delay, it will also show correctly (verifiable with the removed code in the #if 0
sections).
// suite.addParameter('--main delayedAdd.Main');
to pull in the proper Main function, comment out any other that might be active.Version used:
Environment name and version (e.g. Chrome 39, node.js 5.4):
Operating System and version (desktop or mobile):
Link to your project:
You can update / change the image resource to update the current image any number of times without encountering bugs.
Sometimes creating an image with a RenderTarget based kha.Image
you get graphical anomalies.
Not necessarily a possible solution, but I made sure the Image provided to the image resource was not showing graphical issues by drawing it manually and it wasn't broken like the HaxeUI Image was.
Will create if the above information doesn't reveal the issue.
Trying to have a section of the GUI display a small version of the map.
Not sure if this is a bug or a enhancement. I have a table view on screen and I'm able to render on iOS but scrolling only works with the scroll bar.
Expected behavior would be that all scrolling can be done by touch and scrolling the list itself.
package;
import kha.Framebuffer;
import kha.System;
import kha.Assets;
import haxe.ui.core.Screen;
import haxe.ui.Toolkit;
import haxe.ui.components.Button;
import haxe.ui.containers.VBox;
import haxe.ui.containers.ListView;
class Project {
private var _main:VBox;
public function new() {
Assets.loadEverything(loadedEverything);
}
public function loadedEverything() {
Toolkit.init();
_main = new VBox();
_main.percentWidth = 100;
_main.percentHeight = 100;
var button:Button = new Button();
button.text = "Hello";
button.width = 100;
button.height = 50;
_main.addComponent(button);
var tableView:ListView = new ListView();
tableView.percentHeight = 100;
tableView.percentWidth = 100;
for (a in 0...500) {
tableView.dataSource.add({label: "Item " + (a + 1)});
}
_main.addComponent(tableView);
Screen.instance.addComponent(_main);
System.notifyOnRender(render);
}
function render(framebuffer: Framebuffer): Void {
var g = framebuffer.g2;
g.begin(true, 0xffffff);
Screen.instance.renderTo(g);
g.end();
}
}
Whenever the app window is resized, the components within it are not rendered correctly and they appear differently based on the size of the window.
It is enough to resize the window vertically, the horizontal size doesn't seem to affect the UI.
They components should be always rendered in the same way
The components are rendered in a few different ways during the window resize, one of them seems to be the "correct" one.
N/A
I've tried using Toolkit.autoScale=false before Toolkit.init(), but it didn't help
From the gist below
From a more complex test (animated)
main.xml
<?xml version="1.0" encoding="utf-8"?>
<hbox id="main" width="100%" height="100%" style="background-color: white;padding:10px">
<button id="testButton1" text="Click Me!"/>
<button id="testButton2" text="Click Me!" />
</hbox>
Main.hx
package;
import kha.Assets;
import kha.System;
import kha.Framebuffer;
import haxe.ui.Toolkit;
import haxe.ui.components.Button;
import haxe.ui.core.Component;
import haxe.ui.core.Screen;
import haxe.ui.macros.ComponentMacros;
class Main {
public static function main() {
System.start({title: "HaxeUIApp", width: 400, height: 300}, function(Window) {
new App();
});
}
}
class App {
private var _main:Component;
public function new() {
Assets.loadEverything(onAssetsLoaded);
}
function onAssetsLoaded() {
Toolkit.init();
Screen.instance.addComponent(ComponentMacros.buildComponent("../assets/main.xml"));
System.notifyOnFrames(render);
}
function render(framebuffers:Array<Framebuffer>):Void {
for (framebuffer in framebuffers) {
var g = framebuffer.g2;
g.begin(true, 0x000000);
Screen.instance.renderTo(g);
g.end();
}
}
}
When affected by the bug, the UI is unusable for any non-test application
Kha now compiles successfully to windows, however, when using a scrollview the content isnt clipped as is should be. This happens on html5 also.
The contents of the ScrollView should be successfully clipped to the parents size (this used to work)
Ask Rob. :)
var scrollview:ScrollView = new ScrollView();
scrollview.width = 100;
scrollview.height = 100;
for (a in 0...20) {
var button = new Button();
button.text = "Button " + a;
scrollview.addComponent(button);
}
Screen.instance.addComponent(scrollview);
Latest Kha (git)
Latest HaxeUI (git)
Haxe 3.2.1
I tried to use a own font for a button using css and xml and there is no text.
Create a style and add the tag: font:"Fontname";
Use the style within the button in the xml. The button should show the text with the font.
There is no text. But it's working in HTML5
Sorry no idea right now.
Use skeleton Template
Cannot use any font on windows target. This is bad for games if i can only use the "standard" font.
I have created a test app. Basically it comes in 2 parts login and create account. They're very similar. I have also attached a GIF of what happens. Currently, textfields may lag on input (as demonstrated twice in the gif on the password fields - but I've gotten regular textfields doing the same thing before). Then if you notice, I'm typing on the login page but the textfields from the create account page are the ones receiving the text.
The third problem is most obvious. If you click the login button I removed the whole component from the screen. If you start typing any letters or left/right arrows the textfields are apparently still hooked and throw an exception - you must be debugging and catching uncaught exceptions to see this error.
The fourth problem, not displayed, is that if you keep pressing backspace in an empty textfield you essentially break its positional information. Once you've pressed backspace enough times, try entering in some text - it will all be entered at the front of the character list instead of the back like normal. Using the arrows to correct it does not work.
So that's 4 problems
1: text field lag (slightly inconsistent).
2: selecting text fields in other tab view pages (fairly consistent).
3: text field events remain registered when their parents are removed from the tree. (consistent)
4: Pressing backspace repeatedly breaks typing in the text fields. (consistent)
Attached is a similar test app to my last issue but with more haxeui components.
testapp.zip
Unresponsive/broken text fields make for an unpleasant user experience.
When doing background-image-repeat: repeat;
or background-image-repeat: 'repeat';
in the css style, the background image should repeat.
Is not implemented and just hides the image
Say we have a grid.png in our project Assets folder.
<grid id="grid1" columns="2" style="background-image: 'grid'; background-image-repeat: repeat;">
<grid/>
Have a visual representation of the rows/columns of my grid
haxeui-core and haxui-kha git new-component-method
Setting scrollmode to “drag” or “inertial” seems to have no effect on a scrollview or list if you press and drag on the actual content, say for instance a label in a list. Dragging in a list outside of an actual content element and it will work like its supposed to.
simple application with one button
KhaApplication.hx
import kha.System;
import kha.Assets;
import kha.Framebuffer;
import haxe.ui.Toolkit;
import haxe.ui.core.Screen;
import haxe.ui.components.Button;
import haxe.ui.macros.ComponentMacros;
class KhaApplication {
public function new () {
Toolkit.init();
Assets.loadEverything(function() {
var button:Button = new Button();
button.top = 10;
button.left = 10;
button.text = "Click Me";
Screen.instance.addComponent(button);
});
System.notifyOnRender(render);
}
function render (framebuffer:Framebuffer) : Void {
framebuffer.g2.begin(true, 0xFFFFFF);
Screen.instance.renderTo(framebuffer.g2);
framebuffer.g2.end();
}
}
TestKhaHaxeuiProject_Button.zip
Linux Mint 18.1 x64
haxe 3.4.0
haxeui-core from git
haxeui-kha from git
Kha from git
Thanks.
Hi. Why I can't see text of the button (with default styling)?
if the flag "Breakpoint on All Exceptions" is checked (KodeStudio), then my application will be stopped:
SampleProject.zip
Source of KhaApplication.hx:
package;
import kha.System;
import kha.Framebuffer;
import haxe.ui.Toolkit;
import haxe.ui.core.Screen;
import haxe.ui.components.Button;
import haxe.ui.macros.ComponentMacros;
class KhaApplication {
public function new () {
Toolkit.init();
var button:Button = new Button();
button.top = 10;
button.left = 10;
button.text = "Click Me";
Screen.instance.addComponent(button);
System.notifyOnRender(render);
}
function render (framebuffer:Framebuffer) : Void {
framebuffer.g2.begin(true, 0xFFFFFF);
Screen.instance.renderTo(framebuffer.g2);
framebuffer.g2.end();
}
}
Thanks.
DropDowns mostly ignore clicks on the list of values. Sometimes it works but very rarely, couldn't figure out the exact circumstances. Tried to figure out what's going on but UI code is just way too complicated for me. Happens in a project I can not share but if you can't reproduce I'll try to condense it down into a proper sample project.
If we put a percentage value in css prop height/width in the style="" the height/width should be set to the percentage value and not just null out
When putting a height/width with a percentage(100%) value in the css style="" it creates a width or height of zero(or null)
In the meantime users can use width="100%"
In main.xml
<vbox width="100%" style="height: 100%;" >
<box id="I will not appear because vbox height is ill defined">
<box/>
<vbox/>
haxeui-core and haxui-kha git new-component-method
(This question just for a discussion)
Hi. I noticed how much the increased RAM consumption when I try to render some text.
For example, this application will consume ~30 mb RAM:
package;
import kha.System;
import kha.Assets;
import kha.Framebuffer;
import haxe.ui.Toolkit;
import haxe.ui.core.Screen;
import haxe.ui.components.Button;
import haxe.ui.macros.ComponentMacros;
class KhaApplication {
public function new () {
Toolkit.init();
Assets.loadEverything(function() {
var button:Button = new Button();
button.top = 10;
button.left = 10;
//button.text = "Click Me";
Screen.instance.addComponent(button);
});
System.notifyOnRender(render);
}
function render (framebuffer:Framebuffer) : Void {
framebuffer.g2.begin(true, 0xFFFFFF);
Screen.instance.renderTo(framebuffer.g2);
framebuffer.g2.end();
}
}
but if uncomment line //button.text = "Click Me";
, then the result application with consume ~60mb RAM (and increases with the complication of UI). Operation to display title for button "Click Me" will give additionally +30mb RAM.
TestKhaHaxeuiProject_Button.zip
What do you think, is this normal count of RAM for a text rendering?
Thanks.
Was caught by Class<kha.Image> has no field fromEncodedBytes
But since fromEncodedBytes
does exist in Kore, I think Krom should also expose the method
Can't compile Kha-Sample for Linux. It's failed with error:
/home/username/.haxelib_repo/haxeui-kha/git/haxe/ui/backend/ComponentBase.hx:13: characters 7-20 : You cannot access the js package while targeting cpp (for js.html.Image)
I'm tried to compile this sample with KodeStudio (F5 -> Compile Kha Project -> Linux).
Thanks.
Negative values should behave as positive values do.
Create a slider and set it's min
to -100
and max
to 100
- move the slider.
slider.min = -200;
slider.max = 200;
Trying to build sliders that move with the coordinates of a cartesian point.
HTML5 build on a linux system.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.