Skip to content

Commit

Permalink
feat(qt): adding pixmap, image, button, proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
razshare committed Mar 17, 2024
1 parent a37b8c0 commit c8a1435
Show file tree
Hide file tree
Showing 3 changed files with 328 additions and 25 deletions.
25 changes: 24 additions & 1 deletion src/gui-example.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use function CatPaw\Core\asFileName;
use function CatPaw\Core\error;


use function CatPaw\Core\goffi;
use CatPaw\Gui\Contract;

Expand All @@ -14,6 +15,8 @@ function main() {
return error($error);
}

$logo_file_name = asFileName(__DIR__, "../php-logo.png");

$lib->application();

$window = $lib->window();
Expand All @@ -26,8 +29,27 @@ function main() {
$scene = $lib->scene();
$view = $lib->view();

$lib->scene_match_window($scene, $window);


// ==== START ADDING STUFF ====

// TEXT
$text = $lib->text($scene, "hello world");
$lib->text_set_position($text, 20, 20);
$lib->text_set_position($text, 0, 0);

// LOGO
$logo = $lib->image_from_file_name($logo_file_name, "png");
$item = $lib->image_add_to_scene($logo, $scene);
$lib->pixmap_item_set_position($item, 100, 100);

// BUTTON
$button = $lib->button("This is a button that doesn't work... yet.");
$proxy = $lib->button_add_to_scene($button, $scene);
$lib->proxy_widget_set_position($proxy, 0, 50);


// ==== END ADDING STUFF ====

$lib->view_set_scene($view, $scene);
$lib->view_show($view);
Expand All @@ -42,6 +64,7 @@ function main() {

echo "Started\n";
while (true) {
echo "looping...\n";
delay(10);
}
}
72 changes: 69 additions & 3 deletions src/lib/Gui/Contract.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,32 @@ interface MouseEvent {
}
interface HoverEvent {
}
interface PixelMap {
interface PixmapItem {
}
interface Text {
}
interface Image {
}
interface Button {
}
interface ProxyWidget {
}

const ApplicationCode = 0;
const WindowCode = 1;
const StatusBarCode = 2;
const SceneCode = 3;
const ViewCode = 4;
const KeyEventCode = 5;
const WheelEventCode = 6;
const ResizeEventCode = 7;
const MouseEventCode = 8;
const HoverEventCode = 9;
const PixelMapCode = 10;
const TextCode = 11;
const ImageCode = 12;
const PixmapCode = 13;
const PushButtonCode = 14;
const ProxyWidgetCode = 15;

interface Contract {
// #################################
Expand Down Expand Up @@ -83,7 +96,8 @@ function view_show(View $view):void;
// #################################
// ======================[START]===> Scene
function scene():Scene;

function scene_set_rect(Scene $scene, float $x, float $y, float $width, float $height):void;
function scene_match_window(Scene $scene, Window $window):void;

// #################################
// #################################
Expand All @@ -94,4 +108,56 @@ function scene():Scene;
function text(Scene $scene, string $text):Text;
function text_set_default_color(Text $text, string $color):void;
function text_set_position(Text $text, float $x, float $y):void;

// #################################
// #################################
// #################################
// #################################
// #################################
// ======================[START]===> Image
function image(string $data, int $width, int $height):Image;
function image_from_file_name(string $file_name, string $format):Image;
function image_add_to_scene(Image $image, Scene $scene):PixmapItem;

// #################################
// #################################
// #################################
// #################################
// #################################
// ======================[START]===> PixmapItem
function pixmap_item_set_position(PixmapItem $item, float $x, float $y):void;
function pixmap_item_set_opacity(PixmapItem $item, float $opacity):void;
function pixmap_item_set_scale(PixmapItem $item, float $scale):void;
function pixmap_item_set_rotation(PixmapItem $item, float $angle):void;
function pixmap_item_set_tooltip(PixmapItem $item, string $tooltip):void;
function pixmap_item_set_visible(PixmapItem $item, bool $visible):void;
function pixmap_item_set_z(PixmapItem $item, float $z):void;
function pixmap_item_set_x(PixmapItem $item, float $x):void;
function pixmap_item_set_y(PixmapItem $item, float $y):void;

// #################################
// #################################
// #################################
// #################################
// #################################
// ======================[START]===> Button
function button(string $text):Button;
function button_add_to_scene(Button $button, Scene $scene):ProxyWidget;

// #################################
// #################################
// #################################
// #################################
// #################################
// ======================[START]===> ProxyWidget
function proxy_widget_set_position(ProxyWidget $proxy_widget, float $x, float $y):void;
function proxy_widget_set_opacity(ProxyWidget $proxy_widget, float $opacity):void;
function proxy_widget_set_tooltip(PixmapItem $item, string $tooltip):void;
function proxy_widget_set_scale(PixmapItem $item, float $scale):void;
function proxy_widget_set_rotation(PixmapItem $item, float $angle):void;
function proxy_widget_set_enabled(ProxyWidget $proxy_widget, bool $enabled):void;
function proxy_widget_set_visible(ProxyWidget $proxy_widget, bool $visible):void;
function proxy_widget_set_x(ProxyWidget $proxy_widget, float $x):void;
function proxy_widget_set_y(ProxyWidget $proxy_widget, float $y):void;
function proxy_widget_set_z(ProxyWidget $proxy_widget, float $z):void;
}
Loading

0 comments on commit c8a1435

Please sign in to comment.