Skip to content

Commit

Permalink
update musicsheets widget
Browse files Browse the repository at this point in the history
  • Loading branch information
BurningTreeC committed Aug 19, 2021
1 parent c7cff25 commit 0fcdea1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
31 changes: 14 additions & 17 deletions plugins/musicsheets/files/modules/widgets/musicsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,17 @@ ABCJSWidget.prototype.render = function(parent,nextSibling) {
var program = programs.indexOf(this.program);

var renderedABC;
if(this.tiddler) {
this.tunebookString = $tw.wiki.getTiddlerText(self.tiddler);
if(this.tunebookString) {
renderedABC = ABCJS.renderAbc(this.pNode, this.tunebookString);
var width = parent.clientWidth*2/3;
this.parentwidth = parent.clientWidth;

ABCJS.renderAbc(this.pNode, "%%staffwidth "+width+"\n"+this.tunebookString, {
hint_measures: true,
responsive: "resize",
add_classes: true,
oneSvgPerLine: self.svgPerLine
});
}
if(this.text) {
renderedABC = ABCJS.renderAbc(this.pNode, this.text);
var width = parent.clientWidth*2/3;
this.parentwidth = parent.clientWidth;

ABCJS.renderAbc(this.pNode, "%%staffwidth "+width+"\n"+this.text, {
hint_measures: true,
responsive: "resize",
add_classes: true,
oneSvgPerLine: self.svgPerLine
});
}
if(renderedABC && this.renderMidi) {
this.pNode2 = this.document.createElement("div");
Expand Down Expand Up @@ -88,7 +85,7 @@ ABCJSWidget.prototype.render = function(parent,nextSibling) {
Compute the internal state of the widget
*/
ABCJSWidget.prototype.execute = function() {
this.tiddler = this.getAttribute("tiddler",undefined);
this.text = this.getAttribute("text",undefined);
this.renderMidi = this.getAttribute("midi","no") === "yes";
this.svgPerLine = this.getAttribute("separatelines","no") === "yes";
this.sound = this.getAttribute("sound");
Expand All @@ -101,8 +98,8 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/
ABCJSWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.tiddler || changedAttributes.midi || changedAttributes.soundfont || changedAttributes.separatelines ||
changedAttributes.hints || changedAttributes.autoplay || changedAttributes.sound || changedTiddlers[this.tiddler] || (changedTiddlers["$:/config/musicsheets/program"] && !this.sound)) {
if(changedAttributes.text || changedAttributes.midi || changedAttributes.soundfont || changedAttributes.separatelines ||
changedAttributes.sound || changedTiddlers[this.tiddler] || (changedTiddlers["$:/config/musicsheets/program"] && !this.sound)) {
this.synthControl.pause();
this.refreshSelf();
return true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/musicsheets/plugin.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"title": "$:/plugins/BTC/musicsheets",
"description": "Music scores in abc notation for TiddlyWiki5",
"author": "Simon Huber",
"version": "0.0.1",
"version": "0.0.2",
"list": "readme usage license"
}

0 comments on commit 0fcdea1

Please sign in to comment.