From 4a125784b67a4a76c782053b4dc87e6dfce5391b Mon Sep 17 00:00:00 2001 From: Dmytro Soldatov Date: Sat, 21 Oct 2023 00:42:06 +0300 Subject: [PATCH 1/2] remove txmizer --- package-lock.json | 6 ------ package.json | 9 ++++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index d9fed7e3..3fa6f5f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "0.9.0", "license": "MIT", "dependencies": { - "ts-mixer": "^6.0.3", "tweedle.js": "^2.1.0", "typed-signals": "^2.5.0" }, @@ -32942,11 +32941,6 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, - "node_modules/ts-mixer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.3.tgz", - "integrity": "sha512-k43M7uCG1AkTyxgnmI5MPwKoUvS/bRvLvUb7+Pgpdlmok8AoqmUaZxUUw8zKM5B1lqZrt41GjYgnvAi0fppqgQ==" - }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", diff --git a/package.json b/package.json index fd34f932..d9df0e1e 100644 --- a/package.json +++ b/package.json @@ -61,25 +61,24 @@ "docsKeyword": "PixiJS, UI, components" }, "dependencies": { - "ts-mixer": "^6.0.3", "tweedle.js": "^2.1.0", "typed-signals": "^2.5.0" }, "devDependencies": { "@babel/preset-env": "^7.20.2", "@babel/preset-typescript": "^7.18.6", - "@pixi/eslint-config": "^4.0.1", - "@pixi/extension-scripts": "^1.3.0", "@pixi/core": "^7.3.1", "@pixi/display": "^7.3.1", + "@pixi/eslint-config": "^4.0.1", "@pixi/events": "^7.3.1", + "@pixi/extension-scripts": "^1.3.0", "@pixi/graphics": "^7.3.1", "@pixi/sprite": "^7.3.1", + "@pixi/storybook-renderer": "^0.0.6", + "@pixi/storybook-webpack5": "^0.0.6", "@pixi/text": "^7.3.1", "@pixi/text-bitmap": "^7.3.1", "@pixi/text-html": "^7.3.1", - "@pixi/storybook-renderer": "^0.0.6", - "@pixi/storybook-webpack5": "^0.0.6", "@storybook/addon-essentials": "7.5.1", "@storybook/addon-interactions": "7.5.1", "@storybook/addon-links": "7.5.1", From 1441b0ff0965f71b0b27fa0d2ebea96475a1be61 Mon Sep 17 00:00:00 2001 From: Dmytro Soldatov Date: Sat, 21 Oct 2023 00:42:14 +0300 Subject: [PATCH 2/2] fix button --- src/Button.ts | 26 ++++++++++++++++++++++---- src/FancyButton.ts | 21 ++++++++++++++------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/Button.ts b/src/Button.ts index 15be944e..dab341ac 100644 --- a/src/Button.ts +++ b/src/Button.ts @@ -1,6 +1,7 @@ import { Container } from '@pixi/display'; import { ButtonEvents } from './ButtonEvents'; -import { Mixin } from 'ts-mixer'; +import { Signal } from 'typed-signals'; +import { FederatedPointerEvent } from '@pixi/events'; /** * Adds button events to a given container-based view @@ -99,18 +100,35 @@ export class Button extends ButtonEvents * * container.addChild(button); */ -export class ButtonContainer extends Mixin(Container, Button) +export class ButtonContainer extends Container { + button: Button; + + onDown: Signal<(btn?: Button, e?: FederatedPointerEvent) => void>; + onUp: Signal<(btn?: Button, e?: FederatedPointerEvent) => void>; + onUpOut: Signal<(btn?: Button, e?: FederatedPointerEvent) => void>; + onOut: Signal<(btn?: Button, e?: FederatedPointerEvent) => void>; + onPress: Signal<(btn?: Button, e?: FederatedPointerEvent) => void>; + onHover: Signal<(btn?: Button, e?: FederatedPointerEvent) => void>; + constructor(view?: Container) { super(); - this.view = this; - this.enabled = true; + this.button = new Button(this); + + this.button.enabled = true; if (view) { this.addChild(view); } + + this.onPress = this.button.onPress; + this.onDown = this.button.onDown; + this.onUp = this.button.onUp; + this.onHover = this.button.onHover; + this.onOut = this.button.onOut; + this.onUpOut = this.button.onUpOut; } } diff --git a/src/FancyButton.ts b/src/FancyButton.ts index bd2ef279..6965c7d5 100644 --- a/src/FancyButton.ts +++ b/src/FancyButton.ts @@ -236,16 +236,16 @@ export class FancyButton extends ButtonContainer * Setter, that prevents all button events from firing. * @param {boolean} enabled */ - override set enabled(enabled: boolean) + set enabled(enabled: boolean) { - super.enabled = enabled; + this.button.enabled = enabled; this.setState(enabled ? 'default' : 'disabled'); } - override get enabled(): boolean + get enabled(): boolean { - return super.enabled; + return this.button.enabled; } /** @@ -390,6 +390,11 @@ export class FancyButton extends ButtonContainer const activeView = this.getStateView(state); + if (!activeView) + { + return; + } + fitToView(activeView, this._views.iconView, this.padding); (this._views.iconView as Sprite).anchor?.set(0); @@ -590,6 +595,9 @@ export class FancyButton extends ButtonContainer set iconView(view: ButtonView | null) { if (view === undefined) return; + console.log({ + view + }); this.removeView('iconView'); @@ -605,7 +613,6 @@ export class FancyButton extends ButtonContainer this.innerView.addChild(this._views.iconView); } - this.updateAnchor(); this.setState(this.state, true); } @@ -691,7 +698,7 @@ export class FancyButton extends ButtonContainer this.onOut.connect(() => { - if (!this.isDown) + if (!this.button.isDown) { this.setState('default'); } @@ -706,7 +713,7 @@ export class FancyButton extends ButtonContainer this.onHover.connect(() => { - if (!this.isDown) + if (!this.button.isDown) { utils.isMobile.any ? this.setState('default')