better-rtplot 0.4.0__tar.gz → 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: better-rtplot
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary:
5
5
  License: GPL V3.0
6
6
  Author: jmontp
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "better-rtplot"
3
- version = "0.4.0"
3
+ version = "0.4.1"
4
4
  description = ""
5
5
  authors = ["jmontp <jmontp@umich.edu>"]
6
6
  license = "GPL V3.0"
@@ -158,12 +158,13 @@ class Plot:
158
158
  class Button:
159
159
  id: str
160
160
  label: str
161
+ color: Optional[str] = None
161
162
  height: Optional[float] = None
162
163
 
163
164
  def to_dict(self):
164
165
  return _drop_none({
165
166
  "type": "button", "id": self.id, "label": self.label,
166
- "height": self.height,
167
+ "color": self.color, "height": self.height,
167
168
  })
168
169
 
169
170
 
@@ -176,13 +177,15 @@ class Slider:
176
177
  value: float = 0.0
177
178
  step: Optional[float] = None
178
179
  format: Optional[str] = None
180
+ color: Optional[str] = None
179
181
  height: Optional[float] = None
180
182
 
181
183
  def to_dict(self):
182
184
  return _drop_none({
183
185
  "type": "slider", "id": self.id, "label": self.label,
184
186
  "min": self.min, "max": self.max, "value": self.value,
185
- "step": self.step, "format": self.format, "height": self.height,
187
+ "step": self.step, "format": self.format,
188
+ "color": self.color, "height": self.height,
186
189
  })
187
190
 
188
191
 
@@ -196,6 +199,7 @@ class Dial:
196
199
  step: Optional[float] = None
197
200
  sensitivity: Optional[float] = None
198
201
  format: Optional[str] = None
202
+ color: Optional[str] = None
199
203
  height: Optional[float] = None
200
204
 
201
205
  def to_dict(self):
@@ -203,7 +207,8 @@ class Dial:
203
207
  "type": "dial", "id": self.id, "label": self.label,
204
208
  "min": self.min, "max": self.max, "value": self.value,
205
209
  "step": self.step, "sensitivity": self.sensitivity,
206
- "format": self.format, "height": self.height,
210
+ "format": self.format, "color": self.color,
211
+ "height": self.height,
207
212
  })
208
213
 
209
214
 
@@ -787,6 +787,8 @@ INDEX_HTML = """<!doctype html>
787
787
  .ctrl-item-tall > .ctrl-val { align-self: center; }
788
788
  .ctrl-btn:hover { background: #f0f0f0; }
789
789
  .ctrl-btn:active { background: #e2e2e2; }
790
+ .ctrl-btn-colored:hover { filter: brightness(0.93); }
791
+ .ctrl-btn-colored:active { filter: brightness(0.85); }
790
792
  .ctrl-slider .ctrl-rangeinput { flex: 1; min-width: 120px; }
791
793
  .ctrl-numinput { width: 72px; font-family: monospace; font-size: calc(13px * var(--ui-scale)); padding: 4px 6px; border: 1px solid #b8b8b8; border-radius: 3px; background: #fff; color: #222; text-align: right; -moz-appearance: textfield; }
792
794
  .ctrl-numinput::-webkit-outer-spin-button,
@@ -1093,6 +1095,7 @@ INDEX_HTML = """<!doctype html>
1093
1095
  min, max, step, initial: value,
1094
1096
  commit, applyLocal,
1095
1097
  sensitivity, hasMin, hasMax,
1098
+ color: el.color,
1096
1099
  });
1097
1100
  if (widget && widget.node) item.appendChild(widget.node);
1098
1101
 
@@ -1127,7 +1130,7 @@ INDEX_HTML = """<!doctype html>
1127
1130
  return item;
1128
1131
  }
1129
1132
 
1130
- function buildSliderWidget({ min, max, step, initial, commit, applyLocal, hasMin, hasMax }) {
1133
+ function buildSliderWidget({ min, max, step, initial, commit, applyLocal, hasMin, hasMax, color }) {
1131
1134
  // HTML range inputs can't represent unbounded values, so fall back
1132
1135
  // to sane defaults when the user omits min/max on a slider.
1133
1136
  const rangeMin = hasMin ? min : 0;
@@ -1137,6 +1140,7 @@ INDEX_HTML = """<!doctype html>
1137
1140
  range.className = 'ctrl-rangeinput';
1138
1141
  range.min = rangeMin;
1139
1142
  range.max = rangeMax;
1143
+ if (color != null) range.style.accentColor = resolveColor(color);
1140
1144
  range.step = step;
1141
1145
  range.value = initial;
1142
1146
  // Live preview: update the number box (and any other mirrors) on every
@@ -1149,7 +1153,7 @@ INDEX_HTML = """<!doctype html>
1149
1153
  };
1150
1154
  }
1151
1155
 
1152
- function buildDialWidget({ min, max, initial, commit, applyLocal, sensitivity, hasMin, hasMax }) {
1156
+ function buildDialWidget({ min, max, initial, commit, applyLocal, sensitivity, hasMin, hasMax, color }) {
1153
1157
  const svgNS = 'http://www.w3.org/2000/svg';
1154
1158
  const size = 100;
1155
1159
  const svg = document.createElementNS(svgNS, 'svg');
@@ -1185,6 +1189,7 @@ INDEX_HTML = """<!doctype html>
1185
1189
 
1186
1190
  const indicator = document.createElementNS(svgNS, 'line');
1187
1191
  indicator.classList.add('dial-indicator');
1192
+ if (color != null) indicator.style.stroke = resolveColor(color);
1188
1193
  svg.appendChild(indicator);
1189
1194
 
1190
1195
  // Unified rotation math: the indicator advances by 2π radians for
@@ -1270,6 +1275,12 @@ INDEX_HTML = """<!doctype html>
1270
1275
  const b = document.createElement('button');
1271
1276
  b.className = 'ctrl-btn';
1272
1277
  b.textContent = el.label || el.id;
1278
+ if (el.color != null) {
1279
+ const c = resolveColor(el.color);
1280
+ b.style.backgroundColor = c;
1281
+ b.style.borderColor = c;
1282
+ b.classList.add('ctrl-btn-colored');
1283
+ }
1273
1284
  b.addEventListener('click', () => sendCtrl({ type: 'control_button', id: el.id }));
1274
1285
  item.appendChild(b);
1275
1286
  } else if (el.type === 'slider') {
File without changes
File without changes