/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com

Copyright (c) 2012 I-maginer

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt

-----------------------------------------------------------------------------
*/

fun cbCloseEdit(p)=
  let p -> [ctrlfps ctrllag /*ctrldsample*/] in
  let itoa (ftoi getEdCtrlFloatValue ctrlfps) -> minfps in
  let itoa (ftoi getEdCtrlFloatValue ctrllag) -> maxlag in
  //let itoa getEdCtrlCheckState ctrldsample -> downsample in
    ["minfps" minfps]::
    ["maxlag" maxlag]::
    //["downsample" downsample]::
  nil;;


fun dynamicedit(winstr, inst, viewstr, applybtn)=
  let [400 90] -> [iw ih] in
  (
    setEdWindowSize winstr iw ih;
    let atof (getPluginInstanceParam inst "minfps") -> minfps in
    let if minfps == nil then 20.0 else minfps -> minfps in
    let atof (getPluginInstanceParam inst "maxlag") -> maxlag in
    let if maxlag == nil then 2000.0 else maxlag -> maxlag in
    //let atoi (getPluginInstanceParam inst "downsample") -> downsample in
    //let if downsample == nil then 0 else downsample -> downsample in
    
    let 10 -> ypos in
    let crEdCtrlLabel winstr 10 (ypos + 2) 220 20 (loc "OS3DFPSCONTROL_0018") nil -> labelfps in
    let crEdCtrlFloat winstr 240 ypos 130 20 minfps 1.0 120.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlfps in
    let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 220 20 (loc "OS3DFPSCONTROL_0016") nil -> labellag in
    let crEdCtrlFloat winstr 240 ypos 130 20 maxlag 1.0 100000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrllag in
    //let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) (iw - 20) 20 (loc "OS3DFPSCONTROL_0017") EDWIN_RESIZE_MW -> ctrldsample in
    (
      //setEdCtrlCheckState ctrldsample downsample;
      [mkfun1 @cbCloseEdit [ctrlfps ctrllag /*ctrldsample*/] nil];
    );
  );;