-
Notifications
You must be signed in to change notification settings - Fork 0
Widget Rows
For widgets that are really a stack of bars and labels (combat panels, group rosters), mdw.setWidgetRows renders a block of text, gauge and slider rows at the top of a plain widget's content area as real Geyser elements - gauges look like gauges, names stay clickable, sliders are draggable - with the widget's console keeping whatever space remains below. MDW owns geometry and lifecycle; your package owns content, styles, and values.
mdw.setWidgetRows("Combat", {
{ id = "hdr", type = "text", text = "<136,136,136>PLAYER:", height = 14 },
{ id = "hp", type = "gauge", value = hp, max = maxhp, text = "HP " .. hp,
front = fillCss, back = trackCss },
{ id = "foe1", type = "text", text = "<200,200,200>a goblin",
onClick = function() send("target #1") end },
{ id = "mate1", type = "text", text = "<232,220,200>Farquin",
rightText = "<136,136,136>L2 middle" },
})Rows work on plain widgets only (not tabbed widgets or groups). Pass nil or {} to clear the block.
| Row | Fields |
|---|---|
| Text |
id, type = "text", text (a decho string), optional rightText, onClick, height (default rowTextHeight, 18px), fontSize, css
|
| Gauge |
id, type = "gauge", value, max, text, front, back (Qt stylesheets for fill and track), optional textStyle, fgColor, fontSize, height (default rowGaugeHeight, 16px), rightText, rightWidth
|
| Slider | every gauge field, plus optional step (default rowSliderStep, 5), onChange, onPreview
|
Rows are separated by rowGap (3px). A text row's css styles the row itself (default transparent), which is how a rule between blocks is drawn:
{ id = "sep", type = "text", text = "", height = 6,
css = "background-color: rgba(0,0,0,0%); border-top: 1px solid rgb(58,53,48);" }A slider row is a gauge the player can set - a volume control, a brightness setting, anything the game holds a 0..max number for:
{ id = "vol_music", type = "slider", value = 70, max = 100, text = "Music 70",
front = fillCss, back = trackCss, step = 5,
onChange = function(value) send("music volume " .. value) end,
onPreview = function(value) relabel("Music " .. value) end }Clicking the bar sets the value at the click position, dragging keeps setting it while the button is held, and the mouse wheel steps by step (default rowSliderStep = 5) - up increases, down decreases, both clamped to 0..max (max defaults to 100). There is no knob: the fill follows the pointer.
| Callback | When |
|---|---|
onChange(value) |
Once per gesture, with the committed integer: the mouse release that ends a click or a drag, and each wheel notch that actually moves the value |
onPreview(value) |
Optional. Each value a drag passes through, so a renderer can relabel the bar (or apply the volume live) while the player is still holding the button |
mdw.rowTypes names the row types the running MDW renders ({ text = true, gauge = true, slider = true }). Check it the way you check any other capability - mdw.rowTypes and mdw.rowTypes.slider - and declare a plain gauge in the slider's place on a build that lacks it, so a volume row still shows its level there.
The row's text is always the game's to write - MDW never invents a label - so use onPreview to keep it in step with the pointer. While a drag is armed, a setWidgetRows call takes the row's new text, styles and callbacks but leaves the value alone: a server push landing mid-drag must not fight the hand. The first repaint after the release applies whatever the game declares.
rightText puts a second, right-aligned text on the same strip - the web clients' space-between header line (name on the left, rank on the right). Over a text row it simply overlays: row labels use the proportional UI font, so there is no column to split at; each text runs from its own edge, and the row's onClick still belongs to the whole strip. Over a gauge or slider row it carves out a reserved slice instead (rightWidth, default rowRightWidth = 64px, never more than half the row) - a bar cannot run under the words.
Call setWidgetRows on every GMCP push. Rows are diffed by their (type, id) sequence (a row gaining or losing rightText counts as a shape change) and updated in place when the sequence is unchanged, so per-combat-beat repaints never recreate Qt elements - and a value, stylesheet or row position is only re-applied when it changed.
MDW owns layout and resize (the rows track a live drag), tab-switch visibility (rows created while their widget sits behind another group tab stay hidden until that tab is selected), z-order, and teardown. Rows that would poke out of the bottom of the widget are hidden rather than painting over a neighbour.
mdw.setWidgetMenu(name, items, title) gives a widget a vertical-ellipsis button in its top-right corner that opens a context menu - pass a function as items for live checkbox states. nil removes the button. The button dies with the widget, so declare it where you create the widget. The prompt bar has the same affordance: see Prompt Bar.
Related options: rowGaugeHeight, rowTextHeight, rowGap, rowRightWidth, rowSliderStep, menuButtonSize, menuButtonFontSize in Configuration.