make button backgrounds optional

akkartik
Dec 19, 2023, 5:34 AM
UQI34GQFLN3YSDDBVNABM7VX5UKGIDBKD2AWGGEVR4QAMHMPKJ3AC

Dependencies

  • [2] MXXCTVXW document facilities for buttons on screen
  • [3] EDWRWZRV use color alpha in button backgrounds
  • [4] N2NUGNN4 include a brief reference enabling many useful apps
  • [5] 54HEXCWV clearer API for drawing a button
  • [6] GJ4LBCIE streamline button.lua
  • [7] C2M4RUU5 reorganize some comments
  • [8] XX7G2FFJ intermingle freehand line drawings with text
  • [9] PP2IIHL6 stop putting button state in a global
  • [10] BZHJNMDN document some editor constants
  • [11] H5UZI3YN editor documentation
  • [12] GZ5WULJV switch source side to new screen-line-based render
  • [*] KKMFQDR4 editing source code from within the app

Change contents

  • replacement in source_text.lua at line 37
    [4.869][4.8:111]()
    button(State, 'link', {x=State.left+lo, y=y, w=hi-lo, h=State.line_height, bg={r=1,g=1,b=1},
    [4.869]
    [4.969]
    button(State, 'link', {x=State.left+lo, y=y, w=hi-lo, h=State.line_height,
  • replacement in reference.md at line 280
    [2.808][2.808:876]()
    button(state, name, {x=..., y=..., w=..., h=..., color={r,g,b},
    [2.808]
    [2.876]
    button(state, name, {x=..., y=..., w=..., h=..., bg={r,g,b},
  • replacement in reference.md at line 286
    [2.974][2.974:1293]()
    Call this either directly or indirectly from `App.draw`. It will paint a
    rectangle to the screen with top-left at (x,y), dimensions w×h pixels in the
    specified `color`. It will then overlay any drawing instructions within
    `icon` atop it. The `icon` callback will receive a table containing the same
    x/y/w/h.
    [2.974]
    [4.2345]
    Call this either directly or indirectly from `App.draw`. It will assign a
    rectangle with the given dimensions and trigger the provided (zero-arg)
    `onpress1` callback when the primary mouse button is clicked within.
    It will also optionally paint the rectangle with the specified background
    color `bg` and a foreground described by the `icon` callback (which will
    receive the same dimensions).
  • replacement in reference.md at line 293
    [4.2346][2.1294:1560]()
    The rectangle also registers within `state` the `onpress1` callback (without
    any arguments) when mouse button 1 is clicked on it. This way you can see
    everything about a button in one place. Create as many buttons as you like
    within a single shared `state`.
    [4.2346]
    [2.1560]
    This way you can see everything about a button in one place. Create as many
    buttons as you like within a single shared `state`.
  • replacement in button.lua at line 12
    [4.296][3.34:111]()
    love.graphics.setColor(params.bg.r, params.bg.g, params.bg.b, params.bg.a)
    [4.220]
    [4.2230]
    if params.bg then
    love.graphics.setColor(params.bg.r, params.bg.g, params.bg.b, params.bg.a)
    end