Skip to content

Commit 78ef87c

Browse files
committed
UI\App removal:
This has been removed because it needs to be obvious that UI\quit and UI\run are actually global functions. In addition, the onShouldQuit handler belongs on the quit menu item. This changes the constructor of UI\Window
1 parent 0465d3d commit 78ef87c

File tree

10 files changed

+75
-260
lines changed

10 files changed

+75
-260
lines changed

classes/app.c

Lines changed: 0 additions & 179 deletions
This file was deleted.

classes/app.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

classes/window.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <classes/control.h>
2525
#include <classes/point.h>
2626
#include <classes/size.h>
27-
#include <classes/app.h>
2827
#include <classes/window.h>
2928

3029
zend_object_handlers php_ui_window_handlers;
@@ -98,36 +97,31 @@ int php_ui_window_closing_handler(uiWindow *w, void *arg) {
9897
return result;
9998
}
10099

101-
ZEND_BEGIN_ARG_INFO_EX(php_ui_window_construct_info, 0, 0, 4)
102-
ZEND_ARG_OBJ_INFO(0, app, UI\\App, 0)
100+
ZEND_BEGIN_ARG_INFO_EX(php_ui_window_construct_info, 0, 0, 2)
103101
ZEND_ARG_TYPE_INFO(0, title, IS_STRING, 0)
104102
ZEND_ARG_OBJ_INFO(0, size, UI\\Size, 0)
105103
ZEND_ARG_TYPE_INFO(0, menu, _IS_BOOL, 0)
106104
ZEND_END_ARG_INFO()
107105

108-
/* {{{ proto Window Window::__construct(App app, string title, Size size, bool menu) */
106+
/* {{{ proto Window Window::__construct(string title, Size size, bool menu) */
109107
PHP_METHOD(Window, __construct)
110108
{
111109
php_ui_window_t *win = php_ui_window_fetch(getThis());
112-
zval *app = NULL;
113110
zend_string *title = NULL;
114111
zval *size = NULL;
115112
php_ui_size_t *s;
116113
zend_bool menu = 0;
117114

118-
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "OSO|b", &app, uiApp_ce, &title, &size, uiSize_ce, &menu) != SUCCESS) {
115+
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "SO|b", &title, &size, uiSize_ce, &menu) != SUCCESS) {
119116
return;
120117
}
121118

122119
s = php_ui_size_fetch(size);
123120

124-
win->w = uiNewWindow(ZSTR_VAL(title), (int) s->width, (int) s->height, menu);
121+
win->w = uiNewWindow(ZSTR_VAL(title),
122+
(int) s->width, (int) s->height, menu);
125123

126124
uiWindowOnClosing(win->w, php_ui_window_closing_handler, win);
127-
128-
php_ui_app_window(app, getThis());
129-
130-
zend_update_property(win->std.ce, getThis(), ZEND_STRL("app"), app);
131125
} /* }}} */
132126

133127
ZEND_BEGIN_ARG_INFO_EX(php_ui_window_set_title_info, 0, 0, 1)
@@ -448,7 +442,6 @@ PHP_MINIT_FUNCTION(UI_Window)
448442
uiWindow_ce = zend_register_internal_class_ex(&ce, uiControl_ce);
449443
uiWindow_ce->create_object = php_ui_window_create;
450444
zend_declare_property_null(uiWindow_ce, ZEND_STRL("controls"), ZEND_ACC_PROTECTED);
451-
zend_declare_property_null(uiWindow_ce, ZEND_STRL("app"), ZEND_ACC_PROTECTED);
452445

453446
memcpy(&php_ui_window_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
454447

config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ if test "$PHP_UI" != "no"; then
5454
PHP_SUBST(UI_SHARED_LIBADD)
5555
PHP_SUBST(EXTRA_LDFLAGS)
5656

57-
PHP_NEW_EXTENSION(ui, ui.c classes/form.c classes/grid.c classes/app.c classes/window.c classes/control.c classes/tab.c classes/box.c classes/check.c classes/button.c classes/cbutton.c classes/label.c classes/entry.c classes/multi.c classes/group.c classes/spin.c classes/slider.c classes/progress.c classes/separator.c classes/combo.c classes/ecombo.c classes/radio.c classes/picker.c classes/menu.c classes/item.c classes/point.c classes/size.c classes/area.c classes/path.c classes/color.c classes/brush.c classes/pen.c classes/stroke.c classes/matrix.c classes/descriptor.c classes/font.c classes/layout.c classes/exceptions.c classes/executor.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
57+
PHP_NEW_EXTENSION(ui, ui.c classes/form.c classes/grid.c classes/window.c classes/control.c classes/tab.c classes/box.c classes/check.c classes/button.c classes/cbutton.c classes/label.c classes/entry.c classes/multi.c classes/group.c classes/spin.c classes/slider.c classes/progress.c classes/separator.c classes/combo.c classes/ecombo.c classes/radio.c classes/picker.c classes/menu.c classes/item.c classes/point.c classes/size.c classes/area.c classes/path.c classes/color.c classes/brush.c classes/pen.c classes/stroke.c classes/matrix.c classes/descriptor.c classes/font.c classes/layout.c classes/exceptions.c classes/executor.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
5858
fi

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (PHP_UI != "no") {
1212
EXTENSION("ui", "ui.c", PHP_UI_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /I" + configure_module_dirname);
1313
ADD_SOURCES(
1414
configure_module_dirname + '/classes',
15-
"window.c box.c form.c grid.c app.c button.c cbutton.c check.c combo.c control.c ecombo.c entry.c group.c item.c label.c menu.c multi.c picker.c progress.c radio.c separator.c slider.c spin.c tab.c point.c size.c area.c pen.c path.c color.c brush.c stroke.c matrix.c descriptor.c font.c layout.c exceptions.c executor.c",
15+
"window.c box.c form.c grid.c button.c cbutton.c check.c combo.c control.c ecombo.c entry.c group.c item.c label.c menu.c multi.c picker.c progress.c radio.c separator.c slider.c spin.c tab.c point.c size.c area.c pen.c path.c color.c brush.c stroke.c matrix.c descriptor.c font.c layout.c exceptions.c executor.c",
1616
"ui"
1717
);
1818
} else {

examples/gallery.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
use UI\Size;
3-
use UI\App;
43
use UI\Menu;
54
use UI\MenuItem;
65
use UI\Window;
@@ -25,9 +24,7 @@
2524
use UI\Controls\Separator;
2625
use UI\Controls\ColorButton;
2726

28-
$app = new App();
29-
30-
$window = new Window($app, "libui Control Gallery", new Size(640, 480), true);
27+
$window = new Window("libui Control Gallery", new Size(640, 480), true);
3128
$window->setMargin(true);
3229

3330
$tab = new Tab();
@@ -292,5 +289,5 @@ public function onClick() {
292289

293290
$window->show();
294291

295-
$app->run();
292+
UI\run();
296293
?>

examples/histogram.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
use UI\App;
32
use UI\Point;
43
use UI\Size;
54
use UI\Window;
@@ -22,9 +21,7 @@
2221
use UI\Draw\Text\Font;
2322
use UI\Draw\Text\Layout;
2423

25-
$app = new App();
26-
27-
$window = new Window($app, "libui Histogram Example", new Size(640, 480), true);
24+
$window = new Window("libui Histogram Example", new Size(640, 480), true);
2825

2926
$window->setMargin(true);
3027

@@ -290,5 +287,5 @@ public function getFont(int $selected = -1, int $size = 12) {
290287

291288
$window->show();
292289

293-
$app->run();
290+
UI\run();
294291
?>

0 commit comments

Comments
 (0)