Giter VIP home page Giter VIP logo

ui's Introduction

ui

Build Status

This extension wraps the very excellent libui to provide PHP 7 with an API for the creation of cross platform native look-and-feel interfaces.

TODO

  • queue for pthreads

Requirements

  • PHP 7
  • libui (use current master)
  • Windows/MacOSX/Linux (GTK-3)
  • patience

Documentation

The documentation for UI can be found in the PHP manual

Contributions

Pull requests are welcome, and should target the develop branch.

Captures

There are screenshots in the libui repository for normal form controls, here are captures of examples you can find in this repository:

Snake Starfield
snake starfield

ui's People

Contributors

daverandom avatar krakjoe avatar stricted avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ui's Issues

fps cannot refresh

fps is 1 ............. on win10 64
I download 64 version but it runs failed, while 86 version cannot refresh FPS but success(if it is called success)
image

segfault on getParent call

class ExtensionCombo extends Combo {

	protected function onSelected() {
		var_dump($this->getParent());
        }
}

I'm trying to get a backtrace... but no luck for now... (no display when run in gdb)

disabling box causes crash

in gallery example when i set $numbersHbox->disable(); then it crashen when i go to the Numbers and Lists tab

wen i set $numbersHbox->destroy(); then php crashes instantly

maybe its a great idea to add to UI\Controls\Tab a method to get the current tabs/boxes to modify them later?

Repeatable: causes crash with ToDoist on macOS Sierra

In initial testing with php-ui, there's a repeatable issue observable when any php-ui window is first brought into focus - it causes ToDoist application to generate an "Internal Error - An uncaught exception was raised" with a stack trace, ToDoist can "Continue", however, I'm never sure that's a wise move. This issue presents whether ToDoist was running before the php process or not, they just both have to be running and the php-ui window gain focus (click or alt-tab display the problem, e.g. simply gaining focus).

The source of this could be upstream in libui itself of course or ToDoist (a usually stable app v6.3.16 (Build 10640)), however, I would have thought things shouldn't be crossing over like this.

Example ToDoist stack trace at https://gist.github.com/phpcodemonkey/c645758b0296860fef0daed2db010f32

progressbar

Fatal error: Uncaught UI\Exception\InvalidArgumentException: progress bars have a range of 0-100 inclusive in D:\git\github\ui\examples\gallery.php:131
Stack trace:
#0 D:\git\github\ui\examples\gallery.php(131): UI\Controls\Progress->setValue(-1)
#1 {main}
thrown in D:\git\github\ui\examples\gallery.php on line 131

UI\MenuItem constructor not called

class MenuItemFoo extends UI\MenuItem
{
	public function __construct()
	{
		file_put_contents('debug.log', 'construct MenuItemFoo');
	}
}
$menu = new Menu('File');
// Class created but `__construct` method not called
$menuItem = $menu->append('Foo', MenuItemFoo::class);

[idea] UI\Controls\Form::getChild(string $label)

For now, I'm using something like:

class ExtenfionForm extends Form {
	private $childIndex;
	private $childControl;

	public function addChild(string $name, string $label, UI\Control $control, boolean $stretchy=NULL) {

		$this->childIndex[$name] = $this->append($label, $control, $stretchy ?? false);
		$this->childControl[$name] = $control;
	}

	public function getChild(string $name) {

		return ($this->childControl[$name] ?? NULL);
	}
}

Perhaps we need something simpler.

UI Git PHP 7.3.0-dev Not compiling

PHP : Latest Git
PHP-UI : Latest Git

Exits giving Error:
..\pecl\ui\ui.c(94): error C2039: 'initialized': is not a member of '_zend_fcall_info_cache'

Is this project dead?

I was stoked to learn about this project. I had problems getting it to work, but once I managed, I started using it. I built a library around it. Found weird things, created issues.

Then I discovered that the latest working build is almost 2 years old, and only 3 commits after that. Is there any chance this project will be picked up again?

Libui still sees active development, with the latest commits being only 3 weeks old.

Arrangement Control Functionality

Those controls that have children now store a list of their child controls, we may be able to use this to provide functionality on top of libui.

It would be nice to be able to delete any control from any arrangement, natively only Form supports deleting.

nginx error

php version : 7.1.19
ui ext version 2.0.0

when I add UI extension for php , then ,my website show 502 error . and the nginx error.log shows:

2019/03/29 10:34:13 [error] 10940#10692: *101 FastCGI sent in stderr: "PHP Fatal error: Cannot initialize libui: error initializing libui: registering utility window class; code 1410 (0x00000582) 类已存在。

is this a bug ? but the ui examples run correct .

can not find the declaration on my IDE

I am build the extension success, but in my IDE(PHPStrom), it can not find the declaration to go.
How to let my IDE to find the declaration for this extension? like use UI\Window;

[bug] Trying to getText from Entry with invalid type causes segfault

What you do:
Create an Entry with invalid type, call its getText()

What do you expect:
UI\Exception\InvalidArgumentException from constructor

What happens:
Segmentation fault, as shown below

dmvdbrugge@macbook:~/dynamic-components (master) $ php -a
Interactive shell

php > $e = new UI\Controls\Entry();
php > var_dump($e->getText());
string(0) ""
php > $e = new UI\Controls\Entry(1);
php > var_dump($e->getText());
string(0) ""
php > $e = new UI\Controls\Entry(2);
php > var_dump($e->getText());
string(0) ""
php > $e = new UI\Controls\Entry(3);
php > var_dump($e->getText());
string(0) ""
php > $e = new UI\Controls\Entry(4);
php > var_dump($e->getText());
Segmentation fault: 11

dmvdbrugge@macbook:~/dynamic-components (master) $ php -a
Interactive shell

php > $e = new UI\Controls\Entry(0);
php > var_dump($e->getText());
Segmentation fault: 11

UI\Control::destroy() segfault

When trying to destroy a used control:

[libui] /dev/shm/BUILD/libui-f56411fde197481c00ad950e1a545452d47efa55/common/control.c:76:uiFreeControl() You have a bug: You cannot destroy a uiControl while it still has a parent. (control: 0x55e1a8db1e20)
Trace/breakpoint trap (core dumped)

does not compile with PHP 7.3.2 on Win64 PHPsdk 2.2-dev, complains about Syntax errors-update syntax errors disappear using libui-3.5-alpha compiled with VS2017, Still does not compile

here the compiling output:
$ nmake

Microsoft (R) Program Maintenance Utility Version 14.16.27027.1
Copyright (C) Microsoft Corporation. All rights reserved.

    type ext\pcre\php_pcre.def > D:\php-sdk2\phpmaster\vc15\x64\php-7.3.2-src\x64\Release_TS\php7ts.dll.def
    "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\mc.exe" -h win32\ -r D:\php-sdk2\phpmaster\vc15\x64\php-7.3.2-src\x64\Release_TS\ -x D:\php-sdk2\phpmaster\vc15\x64\php-7.3.2-src\x64\Release_TS\ win32\build\wsyslog.mc

MC: Compiling win32\build\wsyslog.mc
ui.c
pecl\ui\classes/descriptor.h(27): error C2061: syntax error: identifier 'uiDrawTextFontDescriptor'
pecl\ui\classes/descriptor.h(29): error C2059: syntax error: '}'
pecl\ui\classes/font.h(24): error C2061: syntax error: identifier 'uiDrawTextFont'
pecl\ui\classes/font.h(25): error C2061: syntax error: identifier 'm'
pecl\ui\classes/font.h(25): error C2059: syntax error: ';'
pecl\ui\classes/font.h(28): error C2059: syntax error: '}'
pecl\ui\ui.c(385): error C2065: 'uiDrawFontFamilies': undeclared identifier
pecl\ui\ui.c(385): error C2065: 'families': undeclared identifier
pecl\ui\ui.c(385): warning C4552: '*': result of expression not used
pecl\ui\ui.c(394): error C2065: 'families': undeclared identifier
pecl\ui\ui.c(394): warning C4013: 'uiDrawListFontFamilies' undefined; assuming extern returning int
pecl\ui\ui.c(395): warning C4013: 'uiDrawFontFamiliesNumFamilies' undefined; assuming extern returning int
pecl\ui\ui.c(395): error C2065: 'families': undeclared identifier
pecl\ui\ui.c(396): warning C4013: 'uiDrawFontFamiliesFamily' undefined; assuming extern returning int
pecl\ui\ui.c(396): error C2065: 'families': undeclared identifier
pecl\ui\ui.c(396): warning C4047: 'function': 'const char *' differs in levels of indirection from 'int'
pecl\ui\ui.c(396): warning C4024: 'add_next_index_string': different types for formal and actual parameter 2
pecl\ui\ui.c(399): warning C4013: 'uiDrawFreeFontFamilies' undefined; assuming extern returning int
pecl\ui\ui.c(399): error C2065: 'families': undeclared identifier
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe"' : return code '0x2'
Stop.

Looked at the 2 *.h files and did not located the mistake

[bug] Combo setSelected < 0 causes SIGABRT

What you do:

$combo = new Combo(); $combo->setSelected(-5);

What you expect
Either InvalidArgumentException, or selected becomes -1 (same as $combo->setSelected(5)).

What happens
On OSX, libui throws NSException, causing SIGABRT

dmvdbrugge@macbook:~/dynamic-components (master) $ php -a
Interactive shell

php > $combo = new UI\Controls\Combo();
php > $combo->setSelected(5);
php > var_dump($combo->getSelected());
int(-1)
php > $combo->setSelected(-5);
2018-06-19 10:11:00.038 php[72092:3074400] *** Assertion failure in -[NSMenu itemAtIndex:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.40.112/Menus.subproj/NSMenu.m:967
2018-06-19 10:11:00.041 php[72092:3074400] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: index >= 0'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff471c032b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x00007fff6e32ec76 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff471c60c2 +[NSException raise:format:arguments:] + 98
        3   Foundation                          0x00007fff492ef340 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
        4   AppKit                              0x00007fff446c50a4 -[NSMenu itemAtIndex:] + 216
        5   AppKit                              0x00007fff44762ef6 -[NSPopUpButtonCell _selectItemAtIndex:alteringState:] + 270
        6   libui.A.dylib                       0x000000010570c02a uiComboboxSetSelected + 42
        7   ui.so                               0x00000001056d2227 zim_Combo_setSelected + 55
        8   php                                 0x0000000102b06105 ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER + 607
        9   php                                 0x0000000102af0e06 execute_ex + 98
        10  php                                 0x0000000102af1058 zend_execute + 532
        11  php                                 0x0000000102aa7387 zend_eval_stringl + 444
        12  php                                 0x000000010294d1f9 readline_shell_run + 2480
        13  php                                 0x0000000102b4e0f1 do_cli + 2755
        14  php                                 0x0000000102b4d4be main + 1180
        15  libdyld.dylib                       0x00007fff6ef48015 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

apache error

my php.ini

[ui]
extension=php_ui.dll

I download php-ui yesterday and my website acts as follows:
Internal Server Error
normal
Internal Server Error
normal
...
error and success is alternating, and when I note php-ui in php.ini, my website never shows error again.
this is apache log, I don't know if it has relations between apache and php-ui, but I think it may help:

[Wed Jan 23 15:14:08.070325 2019] [core:warn] [pid 12152:tid 744] AH00098: pid file E:/0_env/phpStudy/Apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Wed Jan 23 15:14:08.196326 2019] [mpm_winnt:notice] [pid 12152:tid 744] AH00455: Apache/2.4.23 (Win32) OpenSSL/1.0.2j mod_fcgid/2.3.9 configured -- resuming normal operations
[Wed Jan 23 15:14:08.196326 2019] [mpm_winnt:notice] [pid 12152:tid 744] AH00456: Server built: Jul  1 2016 16:42:20
[Wed Jan 23 15:14:08.196326 2019] [core:notice] [pid 12152:tid 744] AH00094: Command line: 'E:\\0_env\\phpStudy\\Apache\\bin\\httpd.exe -d E:/0_env/phpStudy/Apache'
[Wed Jan 23 15:14:08.203294 2019] [mpm_winnt:notice] [pid 12152:tid 744] AH00418: Parent: Created child process 5004
[Wed Jan 23 15:14:09.812294 2019] [mpm_winnt:notice] [pid 5004:tid 780] AH00354: Child: Starting 150 worker threads.
[Wed Jan 23 15:14:11.930571 2019] [core:error] [pid 5004:tid 2104] [client ::1:50235] End of script output before headers: index.php

Numbers use system locale

When the extension is enabled, PHP starts formatting numbers with my system locale.
In Estonia we use comma instead of dot as floating point separator.
This is an issue because it breaks all unit tests that assume the standard floating point separator.

In the UI elements created of course I want to see number formatted with my locale but that option should be off by default.

[request] UI\Draw\Color::getRgba(): int, ::setRgba(int $rgba), __toString()

The constructor of UI\Draw\Color accepts int $rgba (usually written in hex format).

While I can get/set the separate channels and even directly access the properties (as they are public), I would also like to be able to get that int-value via a getter, and to be able to change it through a setter.

And if you're feeling really fancy you could even implement a __toString resulting in the rgba hex color code.

(I think I will implement all these (in userland) in Dynamic Components, but native would be even better.)

how to hide the cmd in windows?

if i start a php-ui, i need start a cmd and call "php mygui.php" to start a GUI.
I want to click the cmd. So how to hide it?

Reference Counting

Any control that contain child controls should store references to those controls to maintain refcounts.

Currently Control::append(Area), or anything similar, may behave strangely when there is no reference to Area after the call to append returned.

Solved simply by keeping a reference.

Solved properly by adding tables of controls to all layout controls, and windows.

Shortcut key on button labels

Although it is not documented, I realized that if I use & before any letter on the label of a UI\ Controls\Button, the letter becomes shortcut key, as in & Close -> Close

However, I did not figure out how to capture hotkey presses. Is this implemented?

Warning: PHP Startup: Unable to load dynamic library 'ui.so'

Hello Mr!
I run 'make test' command, but PHP can`t load ui.so. what should I do ?


root@qing-PC:/usr/local/src/php_ui/ui# make test

Build complete.
Don't forget to run 'make test'.

=====================================================================
PHP : /opt/lampp/bin/php
Warning: PHP Startup: Unable to load dynamic library 'ui.so' (tried: /usr/local/src/php_ui/ui/modules/ui.so (/lib/x86_64-linux-gnu/libcairo.so.2: undefined symbol: FT_Get_Var_Design_Coordinates), /usr/local/src/php_ui/ui/modules/ui.so.so (/usr/local/src/php_ui/ui/modules/ui.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP_SAPI : cli
PHP_VERSION : 7.2.19
ZEND_VERSION: 3.2.0
PHP_OS : Linux - Linux qing-PC 5.3.0-3-amd64 #1 SMP deepin 5.3.15-6apricot (2020-04-13) x86_64
INI actual : /usr/local/src/php_ui/ui/tmp-php.ini
More .INIs :
PHP : /opt/lampp/bin/phpdbg
PHP_SAPI : PHP Warning: PHP Startup: Unable to load dynamic library 'ui.so' (tried: /usr/local/src/php_ui/ui/modules/ui.so (/lib/x86_64-linux-gnu/libcairo.so.2: undefined symbol: FT_Get_Var_Design_Coordinates), /usr/local/src/php_ui/ui/modules/ui.so.so (/usr/local/src/php_ui/ui/modules/ui.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'ui.so' (tried: /usr/local/src/php_ui/ui/modules/ui.so (/lib/x86_64-linux-gnu/libcairo.so.2: undefined symbol: FT_Get_Var_Design_Coordinates), /usr/local/src/php_ui/ui/modules/ui.so.so (/usr/local/src/php_ui/ui/modules/ui.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
phpdbg
PHP_VERSION : 7.2.19
ZEND_VERSION: 3.2.0
PHP_OS : Linux - Linux qing-PC 5.3.0-3-amd64 #1 SMP deepin 5.3.15-6apricot (2020-04-13) x86_64
INI actual : /usr/local/src/php_ui/ui/tmp-php.ini
More .INIs :
CWD : /usr/local/src/php_ui/ui
Extra dirs :
VALGRIND : Not used
TIME START 2020-08-16 03:28:02
No tests were run.

uiDrawText* have been deprecated

Failure to build at the moment is caused by upstream changes to uiDrawText and friends.

This needs fixing, so far as I can tell, there is a new "attributed string" model which I'll have to read about ...

If anyone else feels like they want to tackle this first, please holla ...

Sets/gets background/foreground color of element, interface UI\Colourable

interface UI\Colourable:

namespace UI;
use UI\Draw\Color;
interface Colourable
{
    public function setBackgroundColor(Color $color): self;
    public function getBackgroundColor(): Color;
    public function setForegroundColor(Color $color): self;
    public function getForegroundColor(): Color;
}

Class UI\Control:

namespace UI;
use UI\Draw\Color;
class Control implements Colourable
{
    protected $backgroundColor = 0x000000;
    protected $foregroundColor = 0xFFFFFF;

    public function setBackgroundColor(Color $color): self
    {
        $this->backgroundColor = $color;
        return $this;
    }
    public function getBackgroundColor()
    {
        if (is_int($this->backgroundColor)) {
            $this->backgroundColor = new Color($this->backgroundColor);
        }
        return $this->backgroundColor;
    }
    public function setForegroundColor(Color $color): self
    {
        $this->foregroundColor = $color;
        return $this;
    }
    public function getForegroundColor()
    {
        if (is_int($this->foregroundColor)) {
            $this->foregroundColor = new Color($this->foregroundColor);
        }
        return $this->foregroundColor;
    }
}

Class UI\Menu:

namespace UI;
use UI\Draw\Color;
class Menu implements Colourable
{
    protected $backgroundColor = 0x000000;
    protected $foregroundColor = 0xFFFFFF;

    public function setBackgroundColor(Color $color): self
    {
        $this->backgroundColor = $color;
        return $this;
    }
    public function getBackgroundColor()
    {
        if (is_int($this->backgroundColor)) {
            $this->backgroundColor = new Color($this->backgroundColor);
        }
        return $this->backgroundColor;
    }
    public function setForegroundColor(Color $color): self
    {
        $this->foregroundColor = $color;
        return $this;
    }
    public function getForegroundColor()
    {
        if (is_int($this->foregroundColor)) {
            $this->foregroundColor = new Color($this->foregroundColor);
        }
        return $this->foregroundColor;
    }
}

Adds image and table, browser controls

Adds from libui:
UI\Image
UI\Controls\Table

New control for display HTML, abstract class UI\Controls\Browser:

namespace UI\Controls;

use UI\Control;
use UI\Size;
use Closure;

class Browser extends Control
{
	protected $size;
	protected $onUpdateCallback;
	private $rawHtml = '';
	protected $html = '';
   
	public function __construct(Size $size, callable $onUpdate = null): void
	{
		$this->setSize($size);
		if ($onUpdate !== null) {
			$this->onUpdate($onUpdate);
		} 
	}
    public function setSize(Size $size): self
    {
		$this->size = $size;
		return $this;
    }
    public function getSize(): Size
    {
		return $this->size;
    }
    public function onUpdate(callable $callback): self
    {
		if (!($callback instanceof Closure)) {
			$callback = Closure::fromCallable($callback);
		}
		$this->onUpdateCallback = $callback;
		$this->html = $this->rawHtml;
		return $this->update();
    }
    public function setHtml(string $html): self
    {
		$this->rawHtml = $this->html = $html;
		return $this->update();
    }
    public function getHtml(bool $raw = false): string
    {
		return $raw ? $this->rawHtml : $this->html;
    }
    protected function update(): self
    {
		if ($this->rawHtml && $this->onUpdateCallback) {
			$raw = $this->rawHtml;
			$this->onUpdateCallback->call($this);
			$this->rawHtml = $raw;
		}
		$this->redraw();
		return $this;
    }
    private function redraw(): void
    {
		// Redraw control by $this->html
    }
}

Segmentation fault (core dumped)

Whenever I try to create an class with the UI\Executor abstract class I get an "Segmentation fault (core dumped)" on Linux, it only happends when that particular class is in another file.

So if call it from the file that gets executed first then there is no problem. So basically, the Executor isn't able to become an instance because he tries to write to certain memory from which he has no access. I assume its the main thread's memory.

configure: error: Please reinstall the ui distribution

I'm trying to get this to work but when I run configure I get the output below. I've already compiled the libui.so from master on github, and added this to php.ini as an extention. Made sure this file could also be found in my path. What ui distribution does configure want?

ᐅ ./configure               
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib/php/extensions/no-debug-zts-20160303
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... yes
checking for re2c... re2c
checking for re2c version... 0.16 (ok)
checking for gawk... gawk
checking for ui support... yes, shared
checking for ui threads... no
checking for ui files in default path... not found
configure: error: Please reinstall the ui distribution

Make in osx serria occur errors

/Users/suxiaolin/Downloads/UI-2.0.0/UI-2.0.0/ui.c:331:82: error: too few arguments to function call, expected 3, have 2
                add_next_index_string(return_value, uiDrawFontFamiliesFamily(families, familiy));

./configure success but make errors

gcc version

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Snake

Hi Joe,

Good job with the snake ;)

  • Rafał

[request] (Multiline)Entry::getType() and possibly setType()

There are Controls you create with a type (for example Entry, MultilineEntry, Box (where it's called orientation), etc.)

I would like for them to have getters.

Bonus request if possible: setters too, so you could for example reveal/hide a password by toggling between Entry::Normal and Entry::Password.

[idea] return $this in void method to allow chained calls

Perhaps stupid, just an idea, to be able to write

$bos = new Box(Box::Vertical)
    ->setPadded()
    ->append(new Combo()
        ->append("Item 1")
        ->append("Item 2")
        ->append("Item 3"))
    ->append(new Separator(Separator::Horizontal))
    ...

Thus, not having to give a name to each UI item.

[idea] UI\Controls\Combo::getSelectedText

Current method UI\Controls\Combo::getSelected rerieve an index, which is not always useful (as we don't know index when calling UI\Controls\Combo::append() and imply to keep a mirror array of index/value)

Does not build against PHP > 7.1

/bin/sh /usr/local/src/php/ui/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/usr/local/src/php/ui -DPHP_ATOM_INC -I/usr/local/src/php/ui/include -I/usr/local/src/php/ui/main -I/usr/local/src/php/ui -I/usr/local/php-7.2/include/php -I/usr/local/php-7.2/include/php/main -I/usr/local/php-7.2/include/php/TSRM -I/usr/local/php-7.2/include/php/Zend -I/usr/local/php-7.2/include/php/ext -I/usr/local/php-7.2/include/php/ext/date/lib  -DHAVE_CONFIG_H  -march=native -mtune=native -fdiagnostics-color=auto -O2 -fPIC -pipe   -c /usr/local/src/php/ui/classes/box.c -o classes/box.lo 
 cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/usr/local/src/php/ui -DPHP_ATOM_INC -I/usr/local/src/php/ui/include -I/usr/local/src/php/ui/main -I/usr/local/src/php/ui -I/usr/local/php-7.2/include/php -I/usr/local/php-7.2/include/php/main -I/usr/local/php-7.2/include/php/TSRM -I/usr/local/php-7.2/include/php/Zend -I/usr/local/php-7.2/include/php/ext -I/usr/local/php-7.2/include/php/ext/date/lib -DHAVE_CONFIG_H -march=native -mtune=native -fdiagnostics-color=auto -O2 -fPIC -pipe -c /usr/local/src/php/ui/classes/box.c  -fPIC -DPIC -o classes/.libs/box.o
/usr/local/src/php/ui/classes/box.c:188:91: error: macro "ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX" passed 6 arguments, but takes just 5
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(php_ui_box_is_padded_info, 0, 0, _IS_BOOL, NULL, 0)
                                                                                           ^
In file included from /usr/local/php-7.2/include/php/main/php.h:39,
                 from /usr/local/src/php/ui/classes/box.c:22:
/usr/local/php-7.2/include/php/Zend/zend_API.h:128:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘}’ token
 #define ZEND_END_ARG_INFO()  };
                              ^
/usr/local/src/php/ui/classes/box.c:192:1: note: in expansion of macro ‘ZEND_END_ARG_INFO’
 ZEND_END_ARG_INFO()
 ^~~~~~~~~~~~~~~~~
In file included from /usr/local/php-7.2/include/php/main/php.h:39,
                 from /usr/local/src/php/ui/classes/box.c:22:
/usr/local/src/php/ui/classes/box.c:217:31: error: ‘php_ui_box_is_padded_info’ undeclared here (not in a function); did you mean ‘php_ui_box_set_padded_info’?
  PHP_ME(Box, isPadded,        php_ui_box_is_padded_info, ZEND_ACC_PUBLIC)
                               ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/php-7.2/include/php/Zend/zend_API.h:70:75: note: in definition of macro ‘ZEND_FENTRY’
 #define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_internal_arg_info)-1), flags },
                                                                           ^~~~~~~~
/usr/local/php-7.2/include/php/main/php.h:422:25: note: in expansion of macro ‘ZEND_ME’
 #define PHP_ME          ZEND_ME
                         ^~~~~~~
/usr/local/src/php/ui/classes/box.c:217:2: note: in expansion of macro ‘PHP_ME’
  PHP_ME(Box, isPadded,        php_ui_box_is_padded_info, ZEND_ACC_PUBLIC)
  ^~~~~~
make: *** [Makefile:207: classes/box.lo] Error 1

Unable to install on linux

Hello guys, first of all, thank you very much for your work and time to create this. But sadly, I'm getting an error when I tried to install it in my linux, could you help me with that?

I'm following the tutorial of installation from here http://php.net/manual/en/ui.setup.php. I installed the last version of Libui.

Thank you in advance.

Error message:

downloading UI-2.0.0.tgz ...
Starting to download UI-2.0.0.tgz (49,498 bytes)
.............done: 49,498 bytes
79 source files, building
running: phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
building in /tmp/pear/temp/pear-build-root48Co5t/UI-2.0.0
running: /tmp/pear/temp/UI/configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20170718
checking for PHP installed headers prefix... /usr/include/php/20170718
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 1.0.1 (ok)
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for ui support... yes, shared
checking for ui threads... no
checking for ui files in default path... found in /usr/local
checking for uiInit in -lui... yes
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/x86_64-linux-gnu-ld
checking if the linker (/usr/bin/x86_64-linux-gnu-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/x86_64-linux-gnu-ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) nawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/x86_64-linux-gnu-ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
running: make
/bin/bash /tmp/pear/temp/pear-build-root48Co5t/UI-2.0.0/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/pear/temp/UI -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-root48Co5t/UI-2.0.0/include -I/tmp/pear/temp/pear-build-root48Co5t/UI-2.0.0/main -I/tmp/pear/temp/UI -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/UI/ui.c -o ui.lo
libtool: compile:  cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/pear/temp/UI -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-root48Co5t/UI-2.0.0/include -I/tmp/pear/temp/pear-build-root48Co5t/UI-2.0.0/main -I/tmp/pear/temp/UI -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/UI/ui.c  -fPIC -DPIC -o .libs/ui.o
In file included from /tmp/pear/temp/UI/ui.c:76:0:
/tmp/pear/temp/UI/classes/descriptor.h:27:2: error: unknown type name ‘uiDrawTextFontDescriptor’
  uiDrawTextFontDescriptor d;
  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/pear/temp/UI/ui.c:77:0:
/tmp/pear/temp/UI/classes/font.h:24:2: error: unknown type name ‘uiDrawTextFont’
  uiDrawTextFont* f;
  ^~~~~~~~~~~~~~
/tmp/pear/temp/UI/classes/font.h:25:2: error: unknown type name ‘uiDrawTextFontMetrics’
  uiDrawTextFontMetrics m;
  ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php/20170718/main/php.h:40:0,
                 from /tmp/pear/temp/UI/ui.c:25:
/tmp/pear/temp/UI/ui.c: In function ‘zm_startup_ui’:
/usr/include/php/20170718/Zend/zend_API.h:131:45: warning: implicit declaration of function ‘zm_startup_UI_EditableCombo’; did you mean ‘zm_startup_UI_Ecombo’? [-Wimplicit-function-declaration]
 #define ZEND_MODULE_STARTUP_N(module)       zm_startup_##module
                                             ^
/usr/include/php/20170718/main/php.h:442:20: note: in expansion of macro ‘ZEND_MODULE_STARTUP_N’
 #define PHP_MINIT  ZEND_MODULE_STARTUP_N
                    ^~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/UI/ui.c:151:2: note: in expansion of macro ‘PHP_MINIT’
  PHP_MINIT(UI_EditableCombo)(INIT_FUNC_ARGS_PASSTHRU);
  ^~~~~~~~~
/usr/include/php/20170718/Zend/zend_API.h:131:45: warning: implicit declaration of function ‘zm_startup_UI_MenuItem’; did you mean ‘zm_startup_UI_Item’? [-Wimplicit-function-declaration]
 #define ZEND_MODULE_STARTUP_N(module)       zm_startup_##module
                                             ^
/usr/include/php/20170718/main/php.h:442:20: note: in expansion of macro ‘ZEND_MODULE_STARTUP_N’
 #define PHP_MINIT  ZEND_MODULE_STARTUP_N
                    ^~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/UI/ui.c:155:2: note: in expansion of macro ‘PHP_MINIT’
  PHP_MINIT(UI_MenuItem)(INIT_FUNC_ARGS_PASSTHRU);
  ^~~~~~~~~
/usr/include/php/20170718/Zend/zend_API.h:131:45: warning: implicit declaration of function ‘zm_startup_UI_DrawMatrix’; did you mean ‘zm_startup_UI_DrawPath’? [-Wimplicit-function-declaration]
 #define ZEND_MODULE_STARTUP_N(module)       zm_startup_##module
                                             ^
/usr/include/php/20170718/main/php.h:442:20: note: in expansion of macro ‘ZEND_MODULE_STARTUP_N’
 #define PHP_MINIT  ZEND_MODULE_STARTUP_N
                    ^~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/UI/ui.c:163:2: note: in expansion of macro ‘PHP_MINIT’
  PHP_MINIT(UI_DrawMatrix)(INIT_FUNC_ARGS_PASSTHRU);
  ^~~~~~~~~
/tmp/pear/temp/UI/ui.c:169:2: warning: implicit declaration of function ‘php_ui_control_finalize’; did you mean ‘php_ui_control_fetch’? [-Wimplicit-function-declaration]
  php_ui_control_finalize();
  ^~~~~~~~~~~~~~~~~~~~~~~
  php_ui_control_fetch
/tmp/pear/temp/UI/ui.c: In function ‘zif_fontFamilies’:
/tmp/pear/temp/UI/ui.c:320:2: error: unknown type name ‘uiDrawFontFamilies’; did you mean ‘uiDrawTextAlign’?
  uiDrawFontFamilies* families;
  ^~~~~~~~~~~~~~~~~~
  uiDrawTextAlign
/tmp/pear/temp/UI/ui.c:329:13: warning: implicit declaration of function ‘uiDrawListFontFamilies’; did you mean ‘zif_fontFamilies’? [-Wimplicit-function-declaration]
  families = uiDrawListFontFamilies();
             ^~~~~~~~~~~~~~~~~~~~~~
             zif_fontFamilies
/tmp/pear/temp/UI/ui.c:329:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  families = uiDrawListFontFamilies();
           ^
/tmp/pear/temp/UI/ui.c:330:30: warning: implicit declaration of function ‘uiDrawFontFamiliesNumFamilies’ [-Wimplicit-function-declaration]
  for (familiy = 0; familiy < uiDrawFontFamiliesNumFamilies(families); familiy++) {
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/UI/ui.c:331:39: warning: implicit declaration of function ‘uiDrawFontFamiliesFamily’; did you mean ‘zif_fontFamilies’? [-Wimplicit-function-declaration]
   add_next_index_string(return_value, uiDrawFontFamiliesFamily(families, familiy));
                                       ^~~~~~~~~~~~~~~~~~~~~~~~
                                       zif_fontFamilies
/tmp/pear/temp/UI/ui.c:331:39: warning: passing argument 2 of ‘add_next_index_string’ makes pointer from integer without a cast [-Wint-conversion]
In file included from /usr/include/php/20170718/main/php.h:40:0,
                 from /tmp/pear/temp/UI/ui.c:25:
/usr/include/php/20170718/Zend/zend_API.h:450:14: note: expected ‘const char *’ but argument is of type ‘int’
 ZEND_API int add_next_index_string(zval *arg, const char *str);
              ^~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/UI/ui.c:334:2: warning: implicit declaration of function ‘uiDrawFreeFontFamilies’; did you mean ‘zif_fontFamilies’? [-Wimplicit-function-declaration]
  uiDrawFreeFontFamilies(families);
  ^~~~~~~~~~~~~~~~~~~~~~
  zif_fontFamilies
Makefile:195: recipe for target 'ui.lo' failed
make: *** [ui.lo] Error 1
ERROR: `make' failed

我的哥,这个UI不再更新了吗?

看到其他语言炫彩的桌面程序,很是羡慕。就PHP还是老版本的GDK。。后来发现出了这个UI,很是喜欢,,但还是缺少一些功能。
现在js的桌面程序也出来多版本。。也都在更新。。。
请问,现在这个UI不再更新了吗?

[request] Change case of constants

As far as I know all constants in PHP are SCREAMING_SNAKE_CASE. This is also what PSR-1 suggests for userland. This extension uses PascalCase (UpperCamelCase, StudlyCaps, you get the idea). Would you please change that?

Rewrite events ("on..." methods)

Set event as callback:

class UI\Control
{
	protected $on = [];

	protected function on(string $event, callable $callback): self
	{
		if (!($callback instanceof \Closure)) {
			$callback = \Closure::fromCallable($callback);
		}
		$this->on[strtolower($event)] = $callback;
		return $this;
	}
}

class UI\Controls\Button extends UI\Control
{
	public function onClick(callable $callback): self
	{
		return $this->on('click', $callback);
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.