responsively increase/decrease font height

akkartik
Nov 15, 2023, 5:30 PM
PRE6XPRNICDCHMF7C45A6DRPVT47IPAIWW6Q7AHNGW3D2PBGOPNAC

Dependencies

Change contents

  • file addition: 0032-update_font_settings (----------)
    [6.2]
    update_font_settings = function(font_height)
    love.graphics.setFont(love.graphics.newFont(font_height))
    Line_height = math.floor(love.graphics.getFont():getHeight()*1.3)
    Line_number_padding = Line_number_width*App.width('m')
    Menu_height = 5 + Line_height + 5
    Menu_bottom = Menu_top + Menu_height
    Editor_state.top = Menu_bottom + 20
    Editor_state.left = Menu_left + 50 + Line_number_padding
    Editor_state.right = math.min(100+30*App.width('m'), Safe_width*2/3)
    Editor_state.width = Editor_state.right - Editor_state.left
    edit.update_font_settings(Editor_state, font_height)
    Text.redraw_all(Editor_state)
    end
  • edit in 0031-on.resize at line 5
    [2.215]
    [2.215]
    Editor_state.bottom = Safe_height/2-5
  • replacement in 0027-Menu_background at line 1
    [3.391][3.392:431]()
    Menu_background = {r=0.2, g=0.2, b=0.2}
    [3.391]
    Menu_background = {r=0.6, g=0.8, b=0.6}
  • replacement in 0021-draw_menu at line 4
    [3.825][3.825:948]()
    button(Editor_state, 'run', {x=Menu_left+5, y=Menu_top+5, w=App.width('Run')+10, h=Line_height, bg={r=0.5, g=0.8, b=0.5},
    [3.825]
    [3.948]
    -- main buttons
    button(Editor_state, 'run', {x=Menu_left+5, y=Menu_top+5, w=App.width('Run')+10, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
  • edit in 0021-draw_menu at line 8
    [3.995]
    [3.995]
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
  • edit in 0021-draw_menu at line 13
    [3.1085]
    [3.1085]
    end,
    })
    -- settings button on right
    local w = App.width('settings')
    button(Editor_state, 'settings', {x=Safe_width-w-10-5, y=Menu_top+5, w=w+10, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
    icon = function(p)
    App.color{r=0,g=0,b=0}
    love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
    love.graphics.print('settings', p.x+5,p.y+2)
    end,
    onpress1 = function()
    print('settings')
  • edit in 0021-draw_menu at line 27
    [3.1096]
    [3.1096]
    -- nav buttons along sides
    button(Editor_state, 'left', {x=0, y=Menu_bottom, w=Menu_left+30, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
    icon = function(p)
    App.color{r=0.4,g=0.4,b=0.4}
    love.graphics.polygon('fill', Menu_left+5, App.screen.height/2, Menu_left+25, App.screen.height/2-10, Menu_left+25, App.screen.height/2+10)
    end,
    })
    local r = Menu_left + Safe_width
    button(Editor_state, 'left', {x=r-30, y=Menu_bottom, w=100, h=App.screen.height, bg={r=0.5, g=0.5, b=0.5, a=0.2},
    icon = function(p)
    App.color{r=0.4,g=0.4,b=0.4}
    love.graphics.polygon('fill', r-25, App.screen.height/2-10, r-25, App.screen.height/2+10, r-5, App.screen.height/2)
    end,
    })
  • replacement in 0013-on.keychord_press at line 2
    [3.2800][3.2800:2847]()
    edit.keychord_press(Editor_state, chord, key)
    [3.2800]
    [3.2847]
    if chord == 'C-=' then
    update_font_settings(Editor_state.font_height+2)
    elseif chord == 'C--' then
    update_font_settings(Editor_state.font_height-2)
    elseif chord == 'C-0' then
    update_font_settings(20)
    else
    edit.keychord_press(Editor_state, chord, key)
    end
  • replacement in 0011-on.initialize at line 11
    [2.580][2.580:596]()
    100, -- left
    [2.580]
    [2.596]
    Menu_left + 50 + Line_number_padding, -- left