Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

94 FancyButton & ButtonContainer does not recognised as Container #112

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 22 additions & 4 deletions src/Button.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Container } from '@pixi/display';

Check failure on line 1 in src/Button.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject>' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/Button.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject>' is not assignable to parameter of type 'DisplayObject'.
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
Expand Down Expand Up @@ -99,18 +100,35 @@
*
* 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;
}
}
21 changes: 14 additions & 7 deletions src/FancyButton.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ObservablePoint, Ticker, Rectangle, utils } from '@pixi/core';

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject>' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'PixiText' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject>' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject>' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'PixiText' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject> | PixiText' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject>' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'PixiText' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject>' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject>' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'PixiText' is not assignable to parameter of type 'DisplayObject'.

Check failure on line 1 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'Container<DisplayObject> | PixiText' is not assignable to parameter of type 'DisplayObject'.
import { Container } from '@pixi/display';
import { Sprite } from '@pixi/sprite';
import { getView } from './utils/helpers/view';
Expand Down Expand Up @@ -236,16 +236,16 @@
* 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;
}

/**
Expand Down Expand Up @@ -390,6 +390,11 @@

const activeView = this.getStateView(state);

if (!activeView)
{
return;
}

fitToView(activeView, this._views.iconView, this.padding);

(this._views.iconView as Sprite).anchor?.set(0);
Expand Down Expand Up @@ -590,6 +595,9 @@
set iconView(view: ButtonView | null)
{
if (view === undefined) return;
console.log({

Check warning on line 598 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

Check warning on line 598 in src/FancyButton.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
view
});

this.removeView('iconView');

Expand All @@ -605,7 +613,6 @@
this.innerView.addChild(this._views.iconView);
}

this.updateAnchor();
this.setState(this.state, true);
}

Expand Down Expand Up @@ -691,7 +698,7 @@

this.onOut.connect(() =>
{
if (!this.isDown)
if (!this.button.isDown)
{
this.setState('default');
}
Expand All @@ -706,7 +713,7 @@

this.onHover.connect(() =>
{
if (!this.isDown)
if (!this.button.isDown)
{
utils.isMobile.any
? this.setState('default')
Expand Down
Loading