SetLayerStyle problem

Report any Hollywood bugs here
Post Reply
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

SetLayerStyle problem

Post 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
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: SetLayerStyle problem

Post by airsoftsoftwair »

Hmm, please post some demo code. I don't really see what you mean here.
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: SetLayerStyle problem

Post 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
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: SetLayerStyle problem

Post 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.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: SetLayerStyle problem

Post 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.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: SetLayerStyle problem

Post 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.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: SetLayerStyle problem

Post 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?
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: SetLayerStyle problem

Post by sinisrus »

Ok thank

Is it possible to change the height or width without resizing?
For just more pixels in width or height?
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: SetLayerStyle problem

Post 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.
Post Reply