Mercurial > code > home > repos > light9
annotate web/timeline/inline-attrs.coffee @ 2440:d1f86109e3cc
more *value getter variants
author | drewp@bigasterisk.com |
---|---|
date | Thu, 30 May 2024 01:08:45 -0700 |
parents | 4556eebe5d73 |
children |
rev | line source |
---|---|
1901
7fe81130b735
move web logging to https://github.com/visionmedia/debug/ so it can have channels that can be turned off
Drew Perttula <drewp@bigasterisk.com>
parents:
1747
diff
changeset
|
1 log = debug('attrs') |
7fe81130b735
move web logging to https://github.com/visionmedia/debug/ so it can have channels that can be turned off
Drew Perttula <drewp@bigasterisk.com>
parents:
1747
diff
changeset
|
2 debug.enable('*') |
1717 | 3 |
1731
e06c2c105035
workaround for coffee issue with static getters. polymer wasn't seeing my attributes at all
Drew Perttula <drewp@bigasterisk.com>
parents:
1717
diff
changeset
|
4 coffeeElementSetup(class InlineAttrs extends Polymer.Element |
1717 | 5 @is: "light9-timeline-note-inline-attrs" |
1731
e06c2c105035
workaround for coffee issue with static getters. polymer wasn't seeing my attributes at all
Drew Perttula <drewp@bigasterisk.com>
parents:
1717
diff
changeset
|
6 @getter_properties: |
1717 | 7 graph: { type: Object, notify: true } |
1746
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
8 project: { type: Object, notify: true } |
1717 | 9 song: { type: String, notify: true } |
1743
92104dcd33e2
finish mouse event routing. inlineAttrs display again.
Drew Perttula <drewp@bigasterisk.com>
parents:
1731
diff
changeset
|
10 config: { type: Object } # just for setup |
92104dcd33e2
finish mouse event routing. inlineAttrs display again.
Drew Perttula <drewp@bigasterisk.com>
parents:
1731
diff
changeset
|
11 uri: { type: Object, notify: true } # the Note |
1745
b0d6ace1db5a
inlineAttrs shows effect choice
Drew Perttula <drewp@bigasterisk.com>
parents:
1743
diff
changeset
|
12 effectStr: { type: String, notify: true } |
1717 | 13 colorScale: { type: String, notify: true } |
14 noteLabel: { type: String, notify: true } | |
15 selection: { type: Object, notify: true } | |
1731
e06c2c105035
workaround for coffee issue with static getters. polymer wasn't seeing my attributes at all
Drew Perttula <drewp@bigasterisk.com>
parents:
1717
diff
changeset
|
16 @getter_observers: [ |
1746
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
17 '_onConfig(config)' |
1717 | 18 'addHandler(graph, uri)' |
19 'onColorScale(graph, uri, colorScale)' | |
20 ] | |
1746
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
21 |
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
22 ready: -> |
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
23 super.ready() |
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
24 @$.effect.addEventListener 'edited', => |
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
25 @graph.patchObject(@uri, @graph.Uri(':effectClass'), @graph.Uri(@effectStr), @graph.Uri(@song)) |
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
26 |
1743
92104dcd33e2
finish mouse event routing. inlineAttrs display again.
Drew Perttula <drewp@bigasterisk.com>
parents:
1731
diff
changeset
|
27 _onConfig: -> |
92104dcd33e2
finish mouse event routing. inlineAttrs display again.
Drew Perttula <drewp@bigasterisk.com>
parents:
1731
diff
changeset
|
28 @uri = @config.uri |
92104dcd33e2
finish mouse event routing. inlineAttrs display again.
Drew Perttula <drewp@bigasterisk.com>
parents:
1731
diff
changeset
|
29 for side in ['top', 'left', 'width', 'height'] |
92104dcd33e2
finish mouse event routing. inlineAttrs display again.
Drew Perttula <drewp@bigasterisk.com>
parents:
1731
diff
changeset
|
30 @.style[side] = @config[side] + 'px' |
92104dcd33e2
finish mouse event routing. inlineAttrs display again.
Drew Perttula <drewp@bigasterisk.com>
parents:
1731
diff
changeset
|
31 |
1746
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
32 addHandler: -> |
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
33 return unless @uri |
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
34 @graph.runHandler(@update.bind(@), "update inline attrs #{@uri.value}") |
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
35 |
1717 | 36 onColorScale: -> |
1747
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
37 return unless @uri? and @colorScale? and @colorScaleFromGraph? |
1717 | 38 U = (x) => @graph.Uri(x) |
39 if @colorScale == @colorScaleFromGraph | |
40 return | |
1747
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
41 @editAttr(@uri, U(':colorScale'), @graph.Literal(@colorScale)) |
1717 | 42 |
1747
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
43 editAttr: (note, attr, value) -> |
1717 | 44 U = (x) => @graph.Uri(x) |
1747
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
45 if not @song? |
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
46 log("inline: can't edit inline attr yet, no song") |
1717 | 47 return |
48 | |
49 existingColorScaleSetting = null | |
50 for setting in @graph.objects(note, U(':setting')) | |
51 ea = @graph.uriValue(setting, U(':effectAttr')) | |
1747
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
52 if ea.equals(attr) |
1717 | 53 existingColorScaleSetting = setting |
54 | |
55 if existingColorScaleSetting | |
1747
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
56 log('inline: update setting', existingColorScaleSetting.value) |
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
57 @graph.patchObject(existingColorScaleSetting, U(':value'), value, U(@song)) |
1717 | 58 else |
1747
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
59 log('inline: new setting') |
1745
b0d6ace1db5a
inlineAttrs shows effect choice
Drew Perttula <drewp@bigasterisk.com>
parents:
1743
diff
changeset
|
60 setting = @graph.nextNumberedResource(note.value + 'set') |
1717 | 61 patch = {delQuads: [], addQuads: [ |
1747
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
62 @graph.Quad(note, U(':setting'), setting, U(@song)) |
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
63 @graph.Quad(setting, U(':effectAttr'), attr, U(@song)) |
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
64 @graph.Quad(setting, U(':value'), value, U(@song)) |
1717 | 65 ]} |
66 @graph.applyAndSendPatch(patch) | |
67 | |
68 update: -> | |
1745
b0d6ace1db5a
inlineAttrs shows effect choice
Drew Perttula <drewp@bigasterisk.com>
parents:
1743
diff
changeset
|
69 console.time('attrs update') |
1717 | 70 U = (x) => @graph.Uri(x) |
1746
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
71 @effectStr = @graph.uriValue(@uri, U(':effectClass'))?.value |
1745
b0d6ace1db5a
inlineAttrs shows effect choice
Drew Perttula <drewp@bigasterisk.com>
parents:
1743
diff
changeset
|
72 @noteLabel = @uri.value.replace(/.*\//, '') |
1717 | 73 existingColorScaleSetting = null |
74 for setting in @graph.objects(@uri, U(':setting')) | |
75 ea = @graph.uriValue(setting, U(':effectAttr')) | |
76 value = @graph.stringValue(setting, U(':value')) | |
1747
5c4d6be0f0fe
mostly fix color-picker
Drew Perttula <drewp@bigasterisk.com>
parents:
1746
diff
changeset
|
77 if ea.equals(U(':colorScale')) |
1717 | 78 @colorScaleFromGraph = value |
79 @colorScale = value | |
80 existingColorScaleSetting = setting | |
81 if existingColorScaleSetting == null | |
82 @colorScaleFromGraph = '#ffffff' | |
83 @colorScale = '#ffffff' | |
1745
b0d6ace1db5a
inlineAttrs shows effect choice
Drew Perttula <drewp@bigasterisk.com>
parents:
1743
diff
changeset
|
84 console.timeEnd('attrs update') |
1717 | 85 |
86 onDel: -> | |
1746
84adc69fdf8a
fix inlineattrs setup and effect editing
Drew Perttula <drewp@bigasterisk.com>
parents:
1745
diff
changeset
|
87 @project.deleteNote(@graph.Uri(@song), @uri, @selection) |
1731
e06c2c105035
workaround for coffee issue with static getters. polymer wasn't seeing my attributes at all
Drew Perttula <drewp@bigasterisk.com>
parents:
1717
diff
changeset
|
88 ) |