Page 1 of 1

SetLayerStyle problem

Posted: Wed Feb 10, 2016 4:25 pm
by sinisrus
Hello,

Why when I change the size (width or height) the border layer change also?
Normally it should change with the ScaleLayer() function only?

SetLayerStyle(1,{Width=200,Border=True,BorderSize=1,BorderColor=#BLACK})

thank you

Re: SetLayerStyle problem

Posted: Fri Feb 12, 2016 4:26 pm
by airsoftsoftwair
Hmm, please post some demo code. I don't really see what you mean here.

Re: SetLayerStyle problem

Posted: Tue Feb 16, 2016 10:46 am
by sinisrus
use mouse wheel for see the problem

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

Layers={}




@DISPLAY 1, {X=150, Y=#CENTER, Width = 800, Height = 600, Title = "Layered display", Borderless=0}




ScreenWidth=GetAttribute(#DISPLAY,0,#ATTRWIDTH)
ScreenHeight=GetAttribute(#DISPLAY,0,#ATTRHEIGHT)

CreateBGPic(0,ScreenWidth,ScreenHeight,#GRAY)
DisplayBGPic(0)

EnableLayers()



Function p_Init(id,x,y,width,height,color)

;LoadBrush(0,name,{LoadAlpha=True})
CreateBrush(id,Width,Height,color)
DisplayBrush(id,X,Y)
SetLayerStyle(id,{width=width,height=height})
SetLayerBorder(id,True,#BLACK,1)

Selectlayer(1)
t=GetLayerStyle(1)
Box(20,20,t.width/2,t.height/2,#BLACK)
endselect

Layers[id]={}
Layers[id].PosX=x
Layers[id].PosY=y

EndFunction



Function p_Move(msg)

Switch msg.action

Case "OnWheelDown":
IF (t.width<3000)And(t.height<3000)
Layers[1].PosX=Layers[1].PosX-(t.width/2)
Layers[1].PosY=Layers[1].PosY-(t.height/2)
t.width=t.width*2
t.height=t.height*2
EndIF

Case "OnWheelUp":
IF (t.width>3)And(t.height>3)
Layers[1].PosX=Layers[1].PosX+(t.width/4)
Layers[1].PosY=Layers[1].PosY+(t.height/4)
t.width=t.width/2
t.height=t.height/2
EndIF

EndSwitch

SetLayerStyle(1,{X=Layers[1].PosX,Y=Layers[1].PosY,Width=t.width,Height=t.height})

EndFunction






p_Init(1,#CENTER,#CENTER,150,200,"$FFFFFF")



InstallEventHandler({OnWheelDown = P_Move, OnWheelUp = P_Move})



EscapeQuit(True)

/* Loops */

Repeat
WaitEvent
Forever

Re: SetLayerStyle problem

Posted: Wed Feb 17, 2016 5:26 pm
by airsoftsoftwair
Ok, now I understand. Check out the documentation of SetLayerStyle(). If you set the "Width" and "Height" tags, the layer *will* be scaled. This is why the border size changes too. So it's not a bug.

Re: SetLayerStyle problem

Posted: Wed Feb 17, 2016 7:08 pm
by Bugala
Posting this here instead of making new report, since this might be about same issue:

Code: Select all

EnableLayers()
CreateBrush(1, 500, 100, #GRAY)
DisplayBrush(1, 100, 100)
t_layerstyle = GetLayerStyle(1)
DebugPrint("width: "..t_layerstyle.width.." height: "..t_layerstyle.height.." x: "..t_layerstyle.x.." y: "..t_layerstyle.y)
Hollywood 6 in Windows 10 returns:

width: 0 height: 0 x: 100, y: 100

a bug?


edit: I can get around it by using GetAttribute command.

Re: SetLayerStyle problem

Posted: Wed Feb 17, 2016 10:33 pm
by airsoftsoftwair
No, it's not a bug. "Width" and "Height" contain scaled dimensions but your layer is unscaled so they are set to 0.

Re: SetLayerStyle problem

Posted: Thu Feb 18, 2016 10:39 am
by Bugala
So GetAttribute is then the only way to get this information, or is there some other .name that refers to actual width and height in GetLayerStyle?

Re: SetLayerStyle problem

Posted: Thu Feb 18, 2016 4:03 pm
by sinisrus
Ok thank

Is it possible to change the height or width without resizing?
For just more pixels in width or height?

Re: SetLayerStyle problem

Posted: Thu Feb 18, 2016 7:51 pm
by airsoftsoftwair
@Bugala:
Yes.

@sinisrus:
For layers of type #BRUSH this isn't possible. But when using type #BOX you can use the "SizeX" and "SizeY" tags to change the width and height.