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

How to adjust the matrix padding in a sequencer? #150

Closed
rohitkrishna094 opened this issue Sep 2, 2019 · 7 comments
Closed

How to adjust the matrix padding in a sequencer? #150

rohitkrishna094 opened this issue Sep 2, 2019 · 7 comments

Comments

@rohitkrishna094
Copy link

In the example below, how do I add more padding between rows or columns in sequencer matrix?

Untitled

Here is the code snippet that I am using:

 const sequencer = new Nexus.Sequencer('#sequencer', {
      size: [400, 110],
      mode: 'toggle',
      rows: 4,
      columns: 16
    });

The cells are too close to one another and I want them more spaced out and want to add different padding for rows and columns. How can I do that?

Thanks

@rohitkrishna094
Copy link
Author

Anyone know how to fix this?

@tatecarson
Copy link
Collaborator

I am looking into this and thinking about it. It currently isn't possible but there should be a way of making it available without overcomplicating the component for people that don't need to use it. PRs or ideas welcome.

@vladansaracpv
Copy link
Contributor

Inside sequencer.js file there is a class called MatrixCell with method called sizeInterface():

  sizeInterface() {
    this.pad.setAttribute('x', 1);
    this.pad.setAttribute('y', 1);
    if (this.width > 2) {
      this.pad.setAttribute('width', this.width - 2);
    } else {
      this.pad.setAttribute('width', this.width);
    }
    if (this.height > 2) {
      this.pad.setAttribute('height', this.height - 2);
    } else {
      this.pad.setAttribute('height', this.height);
    }
    //this.pad.setAttribute('height', this.height - 2);
    this.pad.setAttribute('fill', this.matrix.colors.fill);
  }

If you look at the generated html you can see that sequencer(matrix) consists of svg elements (rects).

<svg width="40" height="40" style="top: 0px; left: 0px; position: absolute; cursor: pointer;">
    <rect x="1" y="1" width="38" height="38" fill="#eee"></rect>
</svg>

We can accept padding as parameter and use that value inside:

this.pad.setAttribute('x', 1);
this.pad.setAttribute('y', 1);

and

this.pad.setAttribute('width', this.width - 2);
this.pad.setAttribute('height', this.height - 2);

so that width & height of the rects would be svg.width - 2 * padding, svg.height - 2 * padding thus effectively creating the padding

@tatecarson
Copy link
Collaborator

I am attempting to fix this but only have made a partial fix. The way I have done it you can now add padding but it changes the button size. Maybe someone can look at what i've done and give me some advice. I am still learning a lot of the library.

https://github.com/nexus-js/ui/blob/abf1937fda7e246fd4bb859f69c6c3ceb0cd64de/lib/interfaces/sequencer.js

and see the example for it in use:

  const sequencer = new Nexus.Sequencer('#sequencer', {
    size: [400, 110],
    mode: 'toggle',
    rows: 4,
    columns: 16,
    paddingRow: 10,
    paddingColumn: 5
  });

@vladansaracpv
Copy link
Contributor

@tatecarson
If we don't mind having sequencer cell of unequal size, we can maybe do it somewhat like this
https://gist.github.com/vladansaracpv/8c1b719fa6885a621eec5f8bddb828d6

vladansaracpv added a commit to vladansaracpv/ui that referenced this issue Mar 30, 2020
@vladansaracpv
Copy link
Contributor

Created pr for this.

@tatecarson
Copy link
Collaborator

This was fixed with #178. Does this work for you @rohitkrishna094 ? I am going to close for now and you can comment again if you feel the need.

tatecarson added a commit that referenced this issue Aug 29, 2020
* updated discord message

* feat: support for vertical orientation (#115)

* fix: Nexus.tune.createScale() does not produce expected scale (#138)

* fix: numberOfSliders does not change number of sliders for Multislider (#161)

* feat: support for vertical orientation (#115)

* feat: add padding to sequencer (#150) #178

* feat: add padding to sequencer (#150) #178

* removed commented out line

* chore(release): 2.1.0

* chore(release): 2.1.1

* chore(release): 2.1.2

* add build

* fix issue #161

* modify regex to support input of negative numbers to number component

* update dist after regex change

* chore(release): 2.1.3

* 🐛 Fix Nexus.Interval import regression

* Fix Nexus.Interval import regression #184

* chore(release): 2.1.4

* Implement multi-touch piano

* chore(release): 2.1.5

* Remove document.write

* Rebuild dist files

* Fix broken CSS in examples

* Bump websocket-extensions from 0.1.3 to 0.1.4 (#185)

Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-node) from 0.1.3 to 0.1.4.
- [Release notes](https://github.com/faye/websocket-extensions-node/releases)
- [Changelog](https://github.com/faye/websocket-extensions-node/blob/master/CHANGELOG.md)
- [Commits](faye/websocket-extensions-node@0.1.3...0.1.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump standard-version from 7.1.0 to 8.0.1 (#187)

Bumps [standard-version](https://github.com/conventional-changelog/standard-version) from 7.1.0 to 8.0.1.
- [Release notes](https://github.com/conventional-changelog/standard-version/releases)
- [Changelog](https://github.com/conventional-changelog/standard-version/blob/master/CHANGELOG.md)
- [Commits](conventional-changelog/standard-version@v7.1.0...v8.0.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Reduce dependency on web audio (#190)

* Only create AudioContext when necessary

* Tweak npm version

* Rebuild dist files

* update documention cdn to use latest build

* fixed mistake

* fixed main and build

* "chore(release): 2.1.6"

* Update index.html

trying to get it to rebuild

Co-authored-by: Vladan Sarac <vladan.sarac.pv@gmail.com>
Co-authored-by: jamesstaub <james.staub@gmail.com>
Co-authored-by: Theis Bazin <theis.bazin@outlook.com>
Co-authored-by: Andy Harman <andyh.at.pendragon@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andy Harman <pendragon-andyh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants