Ecere SDK/eC Forums • View topic - Picture.strech=true




Ecere SDK/eC Forums

Ecere Developers Community

Picture.strech=true

General help with the Ecere Cross Platform GUI toolkit: Window, common controls, events, etc.
Help with the 2D Graphics library: Surface, Display, Bitmap, Font and others.

Picture.strech=true

Postby samsam598 » Sun Mar 04, 2012 8:11 pm

Greetings!

When I played around the Picture control,unlucky I found it does not support certain property up to now.For example,I choose a picture in the picture control,after the form resizes,the the picuture shows different ,not the same part in the Picture control.In Delphi/Lazarus,there is a strech property which ensures the above mentioned changes won't happen.And,Picture.sizeAnchor.isClientW and isClientH always is false although I am not quite sure what they are for.

Hope you could guess what I tried to say.^_^.

Regards,
Sam
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm

Re: Picture.strech=true

Postby jerome » Sun Mar 04, 2012 11:20 pm

Hi Sam,

I have tried adding a Picture control, and setting it to be anchored to all 4 edges
(e.g. anchor = { left = 10, top = 10, right = 10, bottom = 10 })
Then I resize the form, and I see quite weird behavior by the picture control, when either dimension ends up making the picture control bigger than the bitmap's original size.
Is this what you are talking about? It looks like a bug, I will look into this right now.

The isClientW and isClientH of the size anchor, specifies whether the specified size of the anchor is the 'client area' size (excluding the decorations, e.g. title bar/resize frane) or the 'total size' (including the decorations).

It's more of an internal thing, it will be set to one or the other depending on whether you set 'clientSize' or 'size' for the window.

P.S.: Glad to see you're still around Sam! :D We have a big release coming up this week, 0.44!

Regards,

Jerome
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: Picture.strech=true

Postby samsam598 » Sun Mar 04, 2012 11:32 pm

Thanks Jerome!

Besides what you've found by yourself regarding the Picture control,what I want it provide is as :
Say I place a photo inside the Picture control at the beginning,suppose there is a property of the Picture control which can ensure the photo inside the Picture control is the whoe part as original photo,even when the form/Picture control resizes.

Regards,
Sam
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm

Re: Picture.strech=true

Postby jerome » Sun Mar 04, 2012 11:41 pm

Hi Sam,

Hmm regarding this, the picture control is meant to display the 'whole' picture only.
It doesn't have options to display only part of a picture, it will always be the 'whole' picture.

If it happens to not display the whole picture, it's either because of:
a) the bug I talked about above
b) the picture control actually extends past its parent.

To display part of a picture, you could either:

a) Put it inside a dummy parent window, whose dimensions are the part of the picture you would like to see. Then you can drag that window around in the form, it acts as a "window" (in the literal term, not the GUI/Ecere Window hehe) ON the picture. If you want it to be resizable as well, assuming the above bug is fixed (almost there! :D), and the picture itself is anchored to that parent dummy window using relative anchors (the % sign in the anchor popup box), it should work.

b) Draw the picture yourself. A simple picture drawing code is quite easy... You use a BitmapResource, and you use surface.Filter() or surface.Stretch() in an OnRedraw().

I will try to fix the resizing bug and then show you an example of what I'm talking about for the dummy window.

Regards,

Jerome
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: Picture.strech=true

Postby jerome » Mon Mar 05, 2012 12:11 am

Hi Sam,

Here is the sample code showing how to frame the picture:

Code: Select all
import "ecere"
 
class Form1 : Window
{
   caption = "Form1";
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   clientSize = { 632, 438 };
 
   Window frame { this, anchor = { left = 128, top = 72, right = 104, bottom = 62 } };
   Picture picture1
   {
      frame, anchor = { left = -0.5, top = -0.368421, right = 0.24, bottom = -0.210526 },
      image = { "http://ecere.com/media/infinity_knot.png" }, filter = true
   };
}
 
Form1 form1 {};


And the fix for the mentioned bug.

Please let me know if you have any further issues or recommendations regarding this :)

Regards,

Jerome
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: Picture.strech=true

Postby samsam598 » Mon Mar 05, 2012 1:25 am

Hi Jerome,

The bug fix really fixed the issue.Thanks for the example,for what I want,your examle without 'dummy window frame' suffices.

Regards,
Sam
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm

Re: Picture.strech=true

Postby jerome » Mon Mar 05, 2012 1:36 am

Hi Sam,

I am glad it fixed your issue :D
It will work without the frame if you are interested in the part of the picture at (0,0) :)

Right, now there is no other way to specify an 'offset' into the picture.

However, if you enable vertical/horizontal scrollbars on the Picture control, then it can be offset by setting the scroll position, but the scrollbars are shown (and the user can scroll it).

Cheers,

Jerome
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm


Return to GUI Toolkit & 2D Graphics

Who is online

Users browsing this forum: No registered users and 4 guests

cron