You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Saturday, May 14th 2016, 10:17am

set(laye[name].x.normal,90)doesn't work

hi, i try to make one action include if....set(layer[name].x.nromal,90); set(layer[name].x.mobile,85)
but it doesn't work,should i rewrite the layer[name] x with device check?

Umalo

Professional

Posts: 1,048

Location: Osijek, Croatia, EU

  • Send private message

2

Saturday, May 14th 2016, 11:53pm

I would say that attribute device check is performed when viewer is creating objects in memory and that's why you should apply simple device check and redefine attributes you need to change. (hope it was not only up to syntax error nromal instead of normal)

3

Sunday, May 15th 2016, 9:16am

thanks umalo
i just set one ui_setting for the ui check
when some bottons false than the image of bottons will no show and the others will arrange in the other way.
the code just like
<ui_settings info="true"
tel="true"
showmap="true"
/>
and set one events onxmlcomplete="ui_startup();
the ui_startup action like this
<action name="ui_startup">
if(ui_settings.info == false,

set(layer[info].visible,false);
set(layer[tel].x,70);
set(layer[showmap].x,140);

);
if(ui_settings.tel ==false,
set(layer[tel].visible,false);
);
if(ui_settings.showmap ==false,
set(layer[showmap].visible,false);
);

</action>
it works in the pc viewers, but i also set position of the layer[info]and the others with x.normal and x.mobile ,when i put x.normal and x.mobile into the action, it doesn't work.
how to do

4

Sunday, May 15th 2016, 10:00am

the layer was set by this
<layer name="tel" url="%SWFPATH%/skin/vtourskin.png" crop="0|576|64|64" align="leftbottom" scale.normal="1" scale.mobile="0.8" x.normal="+140" x.mobile="112" y="0" keep="true" />

Umalo

Professional

Posts: 1,048

Location: Osijek, Croatia, EU

  • Send private message

5

Sunday, May 15th 2016, 7:09pm

Explore the code from Klaus in vtrouskin related to button arrangement and learn on how to do code with less IF as possible. One solution I prepared where you decide what buttons to include via ui settings as rest is done by the code:
Link to button arrangement demo

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<krpano>

	<preview type="grid(cube,64,64,512,0xCCCCCC,0x000000,0x999999);" />     
	
	<ui_settings 
		button_1								="true"
		button_2								="true"
		button_3								="true"
		button_4								="true"
		button_5								="true"
		x_offset.normal					="70"
		x_offset.mobile					="56"
		x_start_pos.normal			="-60"
		x_start_pos.mobile			="-46"
	/>
	
	<events name="ui_start" onxmlcomplete="ui_startup();"/>
	
	<action name="ui_startup">				
		position_button(button_1);				
		position_button(button_2);
		position_button(button_3);
		position_button(button_4);
		position_button(button_5);		
	</action>
	
	<action name="position_button">
		copy(layer[%1].visible,ui_settings.%1);
		set(layer[%1].x,calc(ui_settings.x_start_pos + calc((ui_settings.%1 == true) * ui_settings.x_offset)));
		set(ui_settings.x_start_pos,calc(ui_settings.x_start_pos+ calc((ui_settings.%1 == true) * ui_settings.x_offset)));		
	</action>
	
	<style name="your_button_style" url="%SWFPATH%/skin/vtourskin.png" align="left" scale.normal="1" scale.mobile="0.8" y="0" keep="true" visible="false"/>	
	<layer name="button_1" 	style="your_button_style" crop="0|576|64|64" />
	<layer name="button_2" 	style="your_button_style" crop="0|512|64|64" />
	<layer name="button_3" 	style="your_button_style" crop="0|448|64|64" />
	<layer name="button_4" 	style="your_button_style" crop="0|384|64|64" />
	<layer name="button_5" 	style="your_button_style" crop="0|320|64|64" />
	
</krpano>

Code:

Working package download

6

Monday, May 16th 2016, 11:12am

thanks a lot
it works fine.

7

Tuesday, May 17th 2016, 11:02am

Hi,

just as note - these xml device attribute checks like '.normal' or '.tablet' are only possible in static xml declarations.

They define if during xml parsing if that given attribute will be set or skipped.

For dynamic action code expressions should be used, e.g. this way:

Source code

1
if(device.normal, set(layer[name].x,90), set(layer[name].x,85));
or by using calc and the ternary operator:

Source code

1
set(layer[name].x, calc(device.normal ? 90 : 85));
or:

Source code

1
calc(layer[name].x, device.normal ? 90 : 85);


The result is the same in all three examples.

Note - 'normal' and 'mobile' and are exclusive to each other - that means when normal is true, mobile is always false and inverse.

Best regards,
Klaus