function p.__on_start(wid)
    local scroll_min_x = -0.25
    local scroll_min_y = -0.25
    local scroll_max_x = 0.25
    local scroll_max_y = 0.25
    ga_win_set_scroll_bounds(
        wid, 
        scroll_min_x,
        scroll_min_y,
        scroll_max_x,
        scroll_max_y)
end

function p.__on_end(wid)
    --Nothing to do.
end

--Helper function.
function p.click_me_buttom_helper(wid)
    --"Map Coords"
    local mp = {x=0.5, y=0.5}
    --"Screen coords"
    local sc = ga_win_mtos(wid, mp.x, mp.y)

    local params = {}
    params.center_x = sc.x
    params.min_x = sc.x - 0.05
    params.min_y = sc.y - 0.05
    params.max_x = sc.x + 0.05
    params.max_y = sc.y + 0.05
    
    return params
end

function p.__render(wid)
    ga_win_set_background(wid, std.vec(0.0, 0.0, 0.0), 0.95)
    
    ga_win_set_char_size(wid, 0.02, 0.04)
    ga_win_txt_center(wid, 0.92, "TRY DRAGGING THE MOUSE TO SCROLL")

    ga_win_set_char_size(wid, 0.02, 0.04)
    ga_win_txt_center(wid, 0.02, "Go Back (ESC)")

    --"Click me" botton.
    local dims = p.click_me_buttom_helper(wid)
    ga_win_quad(wid, 
        dims.min_x, dims.min_y,
        dims.max_x, dims.max_y,
        "click_me")

    --Gravity indicator.
    local grav_str = ""
    if ga_get_b("var.physics.low_gravity") then
        grav_str = "LOW GRAVITY"
    else
        grav_str = "NORMAL GRAVITY"
    end
    ga_win_txt_center_at_bg(wid, 
        dims.center_x, dims.max_y + 0.02, grav_str);

    --Cursor.
    local cp = ga_win_get_cursor_pos(wid)
    ga_win_quad(wid, 
        cp.x - 0.0, cp.y - 0.05,
        cp.x + 0.025, cp.y + 0.0,
        "cursor")
end

function p.__process_input(wid)
    --If dragging the mouse.
    if ga_get_b("var.dragging_mouse") then
        local drag = ga_win_get_cursor_diff(wid)
        ga_win_scroll(wid, drag.x, drag.y)
    end

    if ga_win_key_pressed(wid, "ESC") then
        ga_window_pop()
    end

    if ga_win_mouse_pressed(wid, true) then
        --Seeing if clicked the "click me" button.
        local cp = ga_win_get_cursor_pos(wid)
        local dims = p.click_me_buttom_helper(wid)
        if  (cp.x >= dims.min_x) and
            (cp.x <= dims.max_x) and
            (cp.y >= dims.min_y) and
            (cp.y <= dims.max_y)
        then
            --Clicking the botton!
            ga_toggle_b("var.physics.low_gravity")
        else
            ga_set_b("var.dragging_mouse", true)
        end
    end

    if ga_win_mouse_released(wid, true) then
        ga_set_b("var.dragging_mouse", false)
    end
end
