Skip to content

Commit

Permalink
Shoebox -- add "set row height" to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Oct 28, 2024
1 parent 94c6e72 commit d416a2d
Showing 1 changed file with 54 additions and 9 deletions.
63 changes: 54 additions & 9 deletions js/shoebox/shoeboxTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class ShoeboxTrack extends TrackBase {

// Hardcoded -- todo, perhaps, get from track line
this.sampleKeys = []
for (let i = 1; i <= 100; i++) {
for (let i = 1; i <= this.rowCount; i++) {
this.sampleKeys.push(i)
}

if(config.max) {
if (config.max) {
this.dataRange = {
min: config.min || 0,
max: config.max
Expand All @@ -58,7 +58,7 @@ class ShoeboxTrack extends TrackBase {
}
// Set properties from track line
if (this.header) {
if(this.header.scale) {
if (this.header.scale) {
this.header.scale = Number.parseFloat(this.header.scale)
}
this.setTrackProperties(this.header)
Expand All @@ -72,10 +72,14 @@ class ShoeboxTrack extends TrackBase {
this.colorScale = new ShoeboxColorScale({min, max, color: this.color})

// This shouldn't be neccessary
if(!this.scale) this.scale = 1.0
if (!this.scale) this.scale = 1.0

}

get rowCount() {
return 100 // TODO Hardcoded, get from data
}

get color() {
return this._color || "rgb(0,0,255)"
}
Expand All @@ -91,15 +95,56 @@ class ShoeboxTrack extends TrackBase {

const menuItems = []

menuItems.push('<hr/>')
let object = $('<div>')
object.text('Set row height')

function dialogHandler(e) {

const callback = () => {

const number = parseInt(this.browser.inputDialog.value, 10)

if (undefined !== number) {

const tracks = []
if (this.trackView.track.selected) {
tracks.push(...(this.trackView.browser.getSelectedTrackViews().map(({track}) => track)))
} else {
tracks.push(this)
}

for (const track of tracks) {
track.rowHeight = number
if(track.rowHeight * track.rowCount < track.height) {
track.trackView.setTrackHeight(track.rowHeight * track.rowCount, true)
}
track.trackView.checkContentHeight()
track.trackView.repaintViews()
}
}
}

const config =
{
label: 'Row Height',
value: this.rowHeight,
callback
}

this.browser.inputDialog.present(config, e)
}

menuItems.push({object, dialog: dialogHandler})

menuItems.push('<hr/>')

// Data range
let object = $('<div>')
object = $('<div>')
object.text('Set data range')

function dialogPresentationHandler() {

// Note -- menu item handlers must be functions, not arrow functions
function dataRangeHandler() {
if (this.trackView.track.selected) {
this.browser.dataRangeDialog.configure(this.trackView.browser.getSelectedTrackViews())
} else {
Expand All @@ -108,7 +153,7 @@ class ShoeboxTrack extends TrackBase {
this.browser.dataRangeDialog.present($(this.browser.columnContainer))
}

menuItems.push({object, dialog: dialogPresentationHandler})
menuItems.push({object, dialog: dataRangeHandler})

return menuItems
}
Expand Down Expand Up @@ -165,7 +210,7 @@ class ShoeboxTrack extends TrackBase {

const v = f.values[i] // / this.scale

if(v >= this.dataRange.min) {
if (v >= this.dataRange.min) {

const row = f.values.length - 1 - i
const y = row * rowHeight
Expand Down

0 comments on commit d416a2d

Please sign in to comment.