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

Update the MusicKeyboard widget on maximizing. #2857

Merged
merged 12 commits into from
Mar 12, 2021

Conversation

daksh4469
Copy link
Member

Issue Reference: #2767, #2808
This PR improves the UI and fixes some bugs in the music keyboard widget.

Firstly, there is an unnecessary scroll bar present (as shown below) on the right-most side of the widget which can be removed without any issues.

mk

Secondly, the main issue was on maximizing this widget, as on maximizing it there was plenty of space left which was unused but could be used for a better User Experience. This PR enables this widget to enlarge the note matrix on maximizing, so as to take full advantage of a full screen.

Before:

mkscreen-capture.1.mp4

After: (without the right-most scroll bar as mentioned above)

mkscreen-capture.2.mp4

@daksh4469
Copy link
Member Author

Please Review this @meganindya @walterbender.
Thanks.

@walterbender
Copy link
Member

I need to do a bit more testing, but I am seeing the note duration cut off at the bottom of the screen.
Also, there seems to be a regression -- not introduced in this patch -- that prevents one from clicking on the lower 2/3 of the grid.

js/widgets/status.js Outdated Show resolved Hide resolved
Co-authored-by: Vaibhav D. Aren <[email protected]>
@daksh4469
Copy link
Member Author

I am seeing the note duration cut off at the bottom of the screen.

Also, there seems to be a regression -- not introduced in this patch -- that prevents one from clicking on the lower 2/3 of the grid.

I will try to resolve these issues. @walterbender

@daksh4469
Copy link
Member Author

daksh4469 commented Feb 25, 2021

I am seeing the note duration cut off at the bottom of the screen.

I used the white space below it so as to eliminate the need for a vertical scroll.
Would this work? @walterbender

mk1

Also, I noticed another regression (not introduced in this patch), in which, if multiple notes are selected to be played at one time, then on clicking the Play button, the sound will stop at that particular step and not go any further.

screen-capture.mkr.mp4

@walterbender
Copy link
Member

walterbender commented Feb 25, 2021

Yes. The duration does not seem to be getting cut off.

One other weirdness I see: When you go to full screen, the grid does not expand until you play another note.

Screenshot from 2021-02-25 07-44-07

Screenshot from 2021-02-25 07-44-12

Screenshot from 2021-02-25 07-44-24

@daksh4469
Copy link
Member Author

One other weirdness I see: When you go to full screen, the grid does not expand until you play another note.

I rechecked this, and this doesn't seem to be happening in my system. Can you please verify this? @walterbender

MusicKeyboard.mp4

@walterbender
Copy link
Member

I was in Chromium on Fedora 33. I'll check the same with Firefox.

@daksh4469
Copy link
Member Author

I also checked this firefox and this was working fine there too.

Firefox_MuiscKeyboard.mp4

Copy link
Member

@ricknjacky ricknjacky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maximizing doesn't work as you have described :-
Screenshot (574)

Lot of "unused" space at the bottom, just like there was previously

OS: Windows
Browser: Brave(chromium based)

@daksh4469
Copy link
Member Author

OS: Windows
Browser: Brave(chromium based)

Ohh....I have checked this on Google Chrome and Mozilla Firefox.
There, it worked perfectly.

@ricknjacky
Copy link
Member

OS: Windows
Browser: Brave(chromium based)

Ohh....I have checked this on Google Chrome and Mozilla Firefox.
There, it worked perfectly.

;-; Brave is chromium based, more of it is exactly google chrome tbh.

@daksh4469
Copy link
Member Author

I now also checked on Brave browser and got the same results:

Brave.mp4

@walterbender
Copy link
Member

Version 88.0.4324.150 (Developer Build) Fedora Project (64-bit)
Also on FF, 85.0.1 (64-bit)

Screenshot from 2021-02-25 19-37-51

@daksh4469
Copy link
Member Author

daksh4469 commented Feb 26, 2021

So, is there any error shown in the console related to this or it is just not working? @walterbender @ricknjacky
Also, can you suggest how should I test this as on my system it works fine on all browsers?

@daksh4469
Copy link
Member Author

daksh4469 commented Feb 26, 2021

Regarding the issue where the cells are "unclickable" in the bottom around 2/3rd part of the grid (bottom 7 to be precise), it is happening as the for loop (starting from line 1057 in the makeClickable function), the parameter this.layout.length is getting set to 5, after #2849, instead of 12.
Now, the error arises in the _keysLayout function where the notes the are pushed in the layout array. In #2849, I think there is a mistake in lines 953 through 960 wherein, after #2849, is:

for (let i = 0; i < sortedList.length; i++) {
            this.layout.push({
                noteName: sortedList[i].noteName,
                noteOctave: sortedList[i].noteOctave,
                blockNumber: sortedList[i].blockNumber,
                voice: sortedList[i].voice
            });
}

In this code, sortedList should be replaced by newList (newList = fillChromaticGaps(sortedNotesList)). Here, the sortedList.length = 5 which is correct but it makes the for loop iterate only 5 times and thus limiting the layout array to a length of 5. Thus, in the for loop, it should be i < newList.length.
I did this and the widget has been working as expected without the above-mentioned issue.
This is also done in the current release of musicblocks.
Please check this @walterbender.
If you approve this, I would commit these changes.

cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
if(!(this.isMaximized)){
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) * 0.9 + "%";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status is different widget afaik, why is this file a part of this PR?

Sorry, I missed this file previously. But please do tell me If I have missed something and what has this file to do with maximizing musickeyboard widget in particular.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, status is a different widget. Actually, after #2838 was merged, as always I deleted that branch and then realized that I left debug statements (that I used for #2838) in the code and did not Prettify the code. So just to rectify that, I did not feel that a different PR would be needed. Thus, I committed those changes first, so this could be rectified.

@@ -120,7 +120,8 @@ class StatusMatrix {
const row = header.insertRow();

cell = row.insertCell(); // i + 1);
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) * 0.9 + "%";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please explain what you've done here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in your previous review, this is just prettifying the code (as mentioned in #2609) and removing debug statement.

@@ -176,7 +177,8 @@ class StatusMatrix {
if (_THIS_IS_MUSIC_BLOCKS_) {
const row = header.insertRow();
cell = row.insertCell();
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) * 0.9 + "%";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^same here

Copy link
Member

@ricknjacky ricknjacky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, is there any error shown in the console related to this or it is just not working? @walterbender @ricknjacky
Also, can you suggest how should I test this as on my system it works fine on all browsers?

Not sure what you mean by working fine, I tested again and

  1. there is still lot of unused space at the bottom
  2. maximize funcn doesn't work as it should, instead it malfunctions
Bug.mp4

See console log on the right of the screen

@daksh4469
Copy link
Member Author

So, is there any error shown in the console related to this or it is just not working? @walterbender @ricknjacky
Also, can you suggest how should I test this as on my system it works fine on all browsers?

Not sure what you mean by working fine, I tested again and

  1. there is still lot of unused space at the bottom
  2. maximize funcn doesn't work as it should, instead it malfunctions

Thanks for the feedback.
I am working on the case where there is no grid. Also, I think using relative lengths instead of static lengths would fix this.
Because as the developer tools tabs get larger, the cell-height diminishes and thus unused space increases (due to static lengths). Also, if in full-screen (without the developer tools tabs), is the unused space (white space) minimal?

@walterbender
Copy link
Member

walterbender commented Mar 12, 2021

I am still seeing the same problem (tested on Chromium). I play some notes;

Screenshot from 2021-03-12 07-26-11

Then click to expand the window:

Screenshot from 2021-03-12 07-23-01

Not until I play more notes does the grid display properly.

Screenshot from 2021-03-12 07-23-08

@daksh4469
Copy link
Member Author

I am trying to figure out this. Don't know why it is working on my device. @walterbender

@daksh4469
Copy link
Member Author

Since it is not maximized until a new note is added, I suspect this could be happening in the widgetWindow.onmaximize event. Thus, I changed it to this.widgetWindow.onmaximize.
Could you check this, please? @walterbender

@walterbender
Copy link
Member

I've just tested on a small screen and as soon as I click on any note, it jumps to full screen. Was that the intention?

@daksh4469
Copy link
Member Author

Is it just maximizing on clicking on the keyboard? If yes, then no actually. This should not be happening.

@walterbender
Copy link
Member

Yes... just clicking on the keyboard.

@walterbender
Copy link
Member

Although it seems to happen even w/o your latest changes.

@daksh4469
Copy link
Member Author

The state of widgetWindow_maximized is got through widgetWindows.js file and there are no changes done there, and, its state is not affected in this musickeyboard.js file also. Also, what I have done is set the styles according to the condition of whether the widget is maximized or not. This condition is applied in 4 cases:

  • When the widget is maximized, i.e., the onmaximize event.
  • When the erase button is clicked.
  • When a note is added through a click event. (__endNote method taking element as an argument)
  • When a note is added through keyboard input event. (__endNote method taking event as an argument)

Now, I can't figure out why this won't work.

@walterbender
Copy link
Member

I just realized that clicking on the "full screen" button vs double-clicking on the toolbar exhibits different behavior. Double-clicking is where I experience the problem. Clicking the button works fine. The double-click handler was missing some steps. Works fine now.

@walterbender walterbender merged commit 0f906f7 into sugarlabs:master Mar 12, 2021
@walterbender
Copy link
Member

a795c8e

@daksh4469
Copy link
Member Author

Thanks @walterbender :)

@daksh4469 daksh4469 deleted the daksh4469-master branch March 13, 2021 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants