Skip to content
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
5 changes: 5 additions & 0 deletions src/DisplaySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export class DisplaySettings {
*/
public barCountPerPartial: number = 10;

/**
* Whether the last system (row) should be also justified to the whole width of the music sheet.
* (applies only for page layout).
*/
public justifyLastSystem: boolean = false;

/**
* Gets or sets the resources used during rendering. This defines all fonts and colors used.
Expand Down
4 changes: 4 additions & 0 deletions src/generated/DisplaySettingsSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class DisplaySettingsSerializer {
o.set("startbar", obj.startBar);
o.set("barcount", obj.barCount);
o.set("barcountperpartial", obj.barCountPerPartial);
o.set("justifylastsystem", obj.justifyLastSystem);
o.set("resources", RenderingResourcesSerializer.toJson(obj.resources));
o.set("padding", obj.padding);
o.set("systemslayoutmode", obj.systemsLayoutMode as number);
Expand Down Expand Up @@ -60,6 +61,9 @@ export class DisplaySettingsSerializer {
case "barcountperpartial":
obj.barCountPerPartial = v! as number;
return true;
case "justifylastsystem":
obj.justifyLastSystem = v! as boolean;
return true;
case "padding":
obj.padding = v as number[] | null;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/layout/PageViewLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export class PageViewLayout extends ScoreLayout {
* Realignes the bars in this line according to the available space
*/
private fitGroup(group: StaveGroup): void {
if (group.isFull || group.width > this.maxWidth) {
if (group.isFull || group.width > this.maxWidth || this.renderer.settings.display.justifyLastSystem) {
group.scaleToWidth(this.maxWidth);
}
else {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion test/visualTests/features/Layout.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import { LayoutMode } from '@src/LayoutMode';
import { Settings } from '@src/Settings';
import { ScoreLoader } from '@src/importer';
import { TestPlatform } from '@test/TestPlatform';
import { VisualTestHelper } from '@test/visualTests/VisualTestHelper';

describe('LayoutTests', () => {
it('pageLayout', async () => {
it('page-layout', async () => {
await VisualTestHelper.runVisualTest('layout/page-layout.gp');
});

it('page-layout-justify-last-row', async () => {
const settings = new Settings();
settings.display.justifyLastSystem = true;

const inputFileData = await TestPlatform.loadFile('test-data/visual-tests/layout/page-layout.gp');
const score = ScoreLoader.loadScoreFromBytes(inputFileData, settings);
await VisualTestHelper.runVisualTestScore(score, 'layout/page-layout-justify-last-row.png', settings);
});

it('multi-track', async () => {
await VisualTestHelper.runVisualTest('layout/multi-track.gp', undefined, [0, 3]);
});
Expand Down