Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 14-Oct-2014 15:04:19

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

hybrid GUI plugit

Scene posted to: http://www.ifam.net/openspace/hybridgui1/web/index.html

Goal: To allow user to create 2d gui elements in the os3d player that are not filled with the 3d buffer. For comments, chat, tags, buttons, sliders, whatever other 2d elements scol has in its apis. Present plugin (is supposed to, but there's a problem) toglle the 2d gui on and off.

Future options:
Specify position (left, right, above, below) , size, and color of 2Dgui and allow plugit to insert 2d elements created in other plugits in 2d gui.  Create multiple 2d guis. (like one on the left, another on the right, a third on the bottom.)

Problem:
I cannot resize the 3d buffer with cBshowGUI to take up the entire screen (turning off the 2d gui), although a similar function manages to resize the buffer to make it smaller (less high) cbhideGUI. I added a console for debugging purposes and it prints the new height of DMSwin, but it returns the value "19c" and "258" whereas it should be 600 (for 600 pixels in height)


All files including xos file posted to: http://www.ifam.net/openspace/hybridgui1/hybridgui.zip

Question:
1. mainwindow....this is a global variable represents an EdWindow object that is a child of the parent/root ObjWin global variable DMSwin. Correct?

xml file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<PLUGIN name="Hybrid Gui Creator" version="1.0" type="misc">

  <DESCRIPTION>Create 2D Gui Outisde of 3d Buffer</DESCRIPTION>

  <HELP>http://www.ifam.net</HELP>

  <RESOURCE></RESOURCE>

  <EDITOR>

    <SCRIPT path="./ehybridgui.pkg" />

  </EDITOR>

  <CLIENT minstance="true">

    <SCRIPT path="./chybridgui.pkg" />
       <ACTION name="Show GUI">
    </ACTION>
    
    <ACTION name="Hide GUI">
    </ACTION>

  </CLIENT>

</PLUGIN>

client file

/*

-----------------------------------------------------------------------------

This source file is part of the Media Octopus Player

For the latest info, see http://www.ifam.net/medioctopusplayer
[this url doens't exist at the moment]



Copyright (c) 2014 Media Octopus



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



-----------------------------------------------------------------------------

*/





//struct definition
  struct Hybrid_GUI = [
  Hybrid_GUI_plugin_instance           				: PInstance,
  Hybrid_GUI_window_object_container					: ObjContainer,
  Hybrid_GUI_height											: I,
  Hybrid_GUI_width											: I
  				
  ]mkHybrid_GUI;;
  



fun deleteOb(inst, hybrid_GUI)=
//get size of main window so we can resize 3d buffer
let _GETwindowPositionSize DMSwin -> [dmsx dmsy dmsw dmsh] in
  (
	 let V3DgetSessionView c3dXsession -> viewstr in
  			//restore v3dview to full width and height
  			(
  				V3DresizeView viewstr 0 0 dmsw dmsh;
  			);
  	);
_DScontainer hybrid_GUI.Hybrid_GUI_window_object_container; 


  0;;
  
  

fun cbResizeMainGui(winstr, w, h, hybrid_GUI_container) =
    let V3DgetSessionView c3dXsession -> viewstr in
    (
      //make v3dview 600 pixels wide and 450 high so it leaves room for non3d window and container this doesn't seem to work
      V3DresizeView viewstr 0 0 w (h - 150);
      
      _SIZEcontainer hybrid_GUI_container 0 (h - 150) w 150;
      _PAINTcontainer hybrid_GUI_container;
    );
  0;;



fun cbhideGUI(inst, from, action, param, rep, hybrid_GUI)=
//hide 2d gui
_DScontainer  hybrid_GUI.Hybrid_GUI_window_object_container;
_showconsole;
 
//get size of main window so we can resize 3d buffer
let _GETwindowPositionSize DMSwin -> [dmsx dmsy dmsw dmsh] in
  (
	 let V3DgetSessionView c3dXsession -> viewstr in
  			//restore v3dview to full width ane height
  			(
  				V3DresizeView viewstr 0 0 dmsw dmsh;
  				_fooS "the new height of the 3d window is:";
  				_fooI dmsh;
  			);
  	);
 


  0;;
  
  
  
  fun cBshowGUI(inst, from, action, param, rep, hybrid_GUI)=

//get size of main window so we can resize 3d buffer and make it 150 pixels less high
let _GETwindowPositionSize DMSwin -> [dmsx dmsy dmsw dmsh] in
  (
  	_ENcontainer hybrid_GUI.Hybrid_GUI_window_object_container 1; 
	 let V3DgetSessionView c3dXsession -> viewstr in
  			//restore v3dview to full width ane height
  			(
  				V3DresizeView viewstr 0 0 dmsw (dmsh-150);
  				_fooS "the new height of the 3d window is:";
  				_fooI dmsh;
  			);
  	);
 


  0;;



  


  



fun newOb(inst)=

  // test if we are in editor then we stop the play mode

  if (_test_exist "stopEditorFromPlugin") then

  (

    0;

  )

  else

  (

  let _GETwindowPositionSize DMSwin -> [dmsx dmsy dmsw dmsh] in
  let _CRcontainerFromObjWin _channel mainWindow.EDW_win 0 (dmsh - 150) dmsw 150 CO_CHILDINSIDE|CO_DISABLE 0x000000 "gui_container_name" -> twodguicontainer in
    //create new hybridGUI object
  let mkHybrid_GUI [inst twodguicontainer dmsw (dmsh - 150)] -> hybrid_GUI_instance in
  (
  		   setEdwindowCbSize mainWindow mkfun4 @cbResizeMainGui hybrid_GUI_instance.Hybrid_GUI_window_object_container;
			setPluginInstanceCbDel inst mkfun2 @deleteOb hybrid_GUI_instance;
			PluginRegisterAction inst "Hide GUI" mkfun6 @cbhideGUI hybrid_GUI_instance;
			PluginRegisterAction inst "Show GUI" mkfun6 @cBshowGUI hybrid_GUI_instance;
   //close let brace
    );
	//return 0 close then brace

    0;

  );



 

  0;;





fun IniPlug(file)=

  PlugRegister @newOb nil;

  setPluginEditor @dynamicedit;

  0;;

editor file, ignore for now since I am not using any values from editor but I'm posting it if it's somehow responsible for any bugs. I will be rewriting it:

/*

-----------------------------------------------------------------------------

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 -> [ctrlwinw ctrlwinh ctrldesksize ctrlresize ctrlborder ctrlcaption ctrldestroy ctrltitle] in

  let ftoi getEdCtrlFloatValue ctrlwinw -> width in

  let ftoi getEdCtrlFloatValue ctrlwinh -> height in

  let getEdCtrlCheckState ctrldesksize -> desksize in

  let getEdCtrlCheckState ctrlresize -> resize in

  let getEdCtrlCheckState ctrlborder -> border in

  let getEdCtrlCheckState ctrlcaption -> caption in

  let getEdCtrlCheckState ctrldestroy -> catchClose in

  let getEdCtrlTextLineValue ctrltitle -> title in

    ["width" itoa width]::

    ["height" itoa height]::

    ["desksize" itoa desksize]::

    ["resize" itoa resize]::

    ["border" itoa border]::

    ["caption" itoa caption]::

    ["catchClose" itoa catchClose]::

    ["title" title]::

    if (!catchClose) then nil else (["EVENT" "Closed"]::nil);;





fun cbDeskSize(ctrl, state, p)=

  let p -> [ctrlwinw ctrlwinh] in

  (

    setEdCtrlFloatEnable ctrlwinw !state;

    setEdCtrlFloatEnable ctrlwinh !state;

  );

  0;;





fun dynamicedit(winstr, inst, viewstr) =

  let [400 240] -> [iw ih] in

  let 10 -> ypos in

  (

    setEdWindowSize winstr iw ih;

    

    let atof (getPluginInstanceParam inst "width") -> width in

    let if width == nil then 800.0 else width -> width in  

    let atof (getPluginInstanceParam inst "height") -> height in

    let if height == nil then 600.0 else height -> height in

    let atoi (getPluginInstanceParam inst "desksize") -> desksize in

    let if desksize == nil then 0 else desksize -> desksize in

    let atoi (getPluginInstanceParam inst "resize") -> resize in

    let if resize == nil then 1 else resize -> resize in

    let atoi (getPluginInstanceParam inst "border") -> border in

    let if border == nil then 1 else border -> border in

    let atoi (getPluginInstanceParam inst "caption") -> caption in

    let if caption == nil then 1 else caption -> caption in

    let atoi (getPluginInstanceParam inst "catchClose") -> catchClose in

    let if catchClose == nil then 0 else catchClose -> catchClose in

    let (getPluginInstanceParam inst "title") -> title in

  

    let crEdCtrlLabel winstr 10 ypos + 2 iw-20 20 "Warning : Only one instance is allowed" nil -> warninglabel in

    let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 170 20 "Window width" nil -> labelwinw in

    let crEdCtrlFloat winstr 190 ypos 100 20 width 0.0 12000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlwinw in

    let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 170 20 "Window height" nil -> labelwinh in

    let crEdCtrlFloat winstr 190 ypos 100 20 height 0.0 12000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlwinh in

    let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 "Use desktop size" EDWIN_RESIZE_MW -> ctrldesksize in

    let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 "Allow resize" EDWIN_RESIZE_MW -> ctrlresize in

    let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 "Show border" EDWIN_RESIZE_MW -> ctrlborder in

    let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 "Show caption" EDWIN_RESIZE_MW -> ctrlcaption in

    let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 "Window title" nil -> labeltitle in

    let crEdCtrlTextLine winstr 180 ypos 200 20 title nil EDWIN_RESIZE_MW -> ctrltitle in

    let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 "Catch close event" EDWIN_RESIZE_MW -> ctrldestroy in

    (

      setEdCtrlCheckState ctrldesksize desksize;

      setEdCtrlCheckState ctrlresize resize;

      setEdCtrlCheckState ctrlborder border;

      setEdCtrlCheckState ctrlcaption caption;

      setEdCtrlCheckState ctrldestroy catchClose;

      if (!desksize) then nil else

      (

        setEdCtrlFloatEnable ctrlwinw 0;

        setEdCtrlFloatEnable ctrlwinh 0;

      );

      

      setEdCtrlCheckCbState ctrldesksize mkfun3 @cbDeskSize [ctrlwinw ctrlwinh];

      

      

      [mkfun1 @cbCloseEdit [ctrlwinw ctrlwinh ctrldesksize ctrlresize ctrlborder ctrlcaption ctrldestroy ctrltitle] nil];

    );

  );;

Offline

#2 14-Oct-2014 15:22:51

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: hybrid GUI plugit

problem solved:

I changed:

//get size of main window so we can resize 3d buffer
let _GETwindowPositionSize DMSwin -> [dmsx dmsy dmsw dmsh] in

to

let _GETwindowPositionSize mainWindow.EDW_win-> [dmsx dmsy dmsw dmsh] in

so DMSwin and mainWindow.EDW_win are different objects. How are they related to each other?

I put an interger flag in the plugit's struct to the buttons don't hide or show containers when they are already hidden or showing:

http://www.ifam.net/openspace/hybridgui2/web/index.html


updated client:

/*

-----------------------------------------------------------------------------

This source file is part of the Media Octopus Player

For the latest info, see http://www.ifam.net/medioctopusplayer
[this url doens't exist at the moment]



Copyright (c) 2014 Media Octopus



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



-----------------------------------------------------------------------------

*/





//struct definition
  struct Hybrid_GUI = [
  Hybrid_GUI_plugin_instance           				: PInstance,
  Hybrid_GUI_window_object_container					: ObjContainer,
  Hybrid_GUI_height											: I,
  Hybrid_GUI_width											: I,
  Hybrid_GUI_minimized										: I
  				
  ]mkHybrid_GUI;;
  



fun deleteOb(inst, hybrid_GUI)=
//get size of main window so we can resize 3d buffer
let _GETwindowPositionSize DMSwin -> [dmsx dmsy dmsw dmsh] in
  (
	 let V3DgetSessionView c3dXsession -> viewstr in
  			//restore v3dview to full width and height
  			(
  				V3DresizeView viewstr 0 0 dmsw dmsh;
  			);
  	);
_DScontainer hybrid_GUI.Hybrid_GUI_window_object_container; 


  0;;
  
  

fun cbResizeMainGui(winstr, w, h, hybrid_GUI_container) =
    let V3DgetSessionView c3dXsession -> viewstr in
    (
      //make v3dview 600 pixels wide and 450 high so it leaves room for non3d window and container this doesn't seem to work
      V3DresizeView viewstr 0 0 w (h - 150);
      
      _SIZEcontainer hybrid_GUI_container 0 (h - 150) w 150;
      _PAINTcontainer hybrid_GUI_container;
    );
  0;;



fun cbhideGUI(inst, from, action, param, rep, hybrid_GUI)=

if hybrid_GUI.Hybrid_GUI_minimized ==1 then 
(
nil;
0;
)
	 else
(
//hide 2d gui
_ENcontainer hybrid_GUI.Hybrid_GUI_window_object_container 0;
_SHOWcontainer hybrid_GUI.Hybrid_GUI_window_object_container	CONTAINER_HIDDEN;
_showconsole;
//set minimized flag to 1
 set hybrid_GUI.Hybrid_GUI_minimized =1;
//get size of main window so we can resize 3d buffer
let _GETwindowPositionSize mainWindow.EDW_win-> [dmsx dmsy dmsw dmsh] in
  (
	 let V3DgetSessionView c3dXsession -> viewstr in
  			//restore v3dview to full width ane height
  			(
  				V3DresizeView viewstr 0 0 dmsw dmsh;
  				_fooS "the new height of the 3d window is:";
  				_fooI dmsh;
  			);
  	);
//return 0 close else brace
 0;
);


  0;;
  
  
  
  fun cBshowGUI(inst, from, action, param, rep, hybrid_GUI)=
  
  if (hybrid_GUI.Hybrid_GUI_minimized == 0) then
  (
  nil;
  0;
  )
  else
  (
//get size of main window so we can resize 3d buffer and make it 150 pixels less high
let _GETwindowPositionSize mainWindow.EDW_win -> [dmsx dmsy dmsw dmsh] in
  (
  	//set minimized flag to 0
 	set hybrid_GUI.Hybrid_GUI_minimized = 0;

_ENcontainer hybrid_GUI.Hybrid_GUI_window_object_container 1; 
  	_SHOWcontainer hybrid_GUI.Hybrid_GUI_window_object_container	CONTAINER_UNHIDDEN;
	 let V3DgetSessionView c3dXsession -> viewstr in
  			//restore v3dview to full width ane height
  			(
  				V3DresizeView viewstr 0 0 dmsw (dmsh-150);
  				_fooS "the new height of the 3d window is:";
  				_fooI dmsh;
  			);
  	);
 //return 0 close then brace
 0;
 );


  0;;



  


  



fun newOb(inst)=

  // test if we are in editor then we stop the play mode

  if (_test_exist "stopEditorFromPlugin") then

  (

    0;

  )

  else

  (

  let _GETwindowPositionSize DMSwin -> [dmsx dmsy dmsw dmsh] in
  let _CRcontainerFromObjWin _channel mainWindow.EDW_win 0 (dmsh - 150) dmsw 150 CO_CHILDINSIDE|CO_DISABLE 0x000000 "gui_container_name" -> twodguicontainer in
    //create new hybridGUI object
  let mkHybrid_GUI [inst twodguicontainer dmsw (dmsh - 150) 0] -> hybrid_GUI_instance in
  (
  		   setEdwindowCbSize mainWindow mkfun4 @cbResizeMainGui hybrid_GUI_instance.Hybrid_GUI_window_object_container;
			setPluginInstanceCbDel inst mkfun2 @deleteOb hybrid_GUI_instance;
			PluginRegisterAction inst "Hide GUI" mkfun6 @cbhideGUI hybrid_GUI_instance;
			PluginRegisterAction inst "Show GUI" mkfun6 @cBshowGUI hybrid_GUI_instance;
   //close let brace
    );
	//return 0 close then brace

    0;

  );



 

  0;;





fun IniPlug(file)=

  PlugRegister @newOb nil;

  setPluginEditor @dynamicedit;

  0;;

Last edited by hebdemnobad (14-Oct-2014 16:18:44)

Offline

#3 14-Oct-2014 19:13:22

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: hybrid GUI plugit

hoo my bad ^^
DMSwin()= v3dMain.V3D_win;;

the DMSwin is the 3D window... why did I do that ?! I don't remember ^^

Offline

#4 15-Oct-2014 18:03:43

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: hybrid GUI plugit

hebdemnobad wrote:

but it returns the value "19c" and "258" whereas it should be 600 (for 600 pixels in height)

19C and 258 are in hexadecimale.
Probably, in your debugger, you are used _fooI (returns the value in hexa) and not _fooId (returns the value in decimale).

19C (hexa) = 412 (decimale) = your window height + the title bar.
258 (hexa) = 600 (decimale). So, it is ok.

Offline

#5 15-Oct-2014 18:09:58

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: hybrid GUI plugit

iri wrote:
hebdemnobad wrote:

but it returns the value "19c" and "258" whereas it should be 600 (for 600 pixels in height)

19C and 258 are in hexadecimale.
Probably, in your debugger, you are used _fooI (returns the value in hexa) and not _fooId (returns the value in decimale).

19C (hexa) = 412 (decimale) = your window height + the title bar.
258 (hexa) = 600 (decimale). So, it is ok.

stupid question on my part but thx!

Offline

#6 15-Oct-2014 18:20:31

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: hybrid GUI plugit

wink

Offline

Board footer

Powered by FluxBB