Jump to content
IElite

Layouts still not working correctly in SMS 2.2 beta 5

Recommended Posts

I have created two forms,

 

Form1 has a label and a button. The layout displays the label (Form1) at the top of the form and the button at the bottom right

fLayout:= Layout.Client(Layout.Margins(10),
                          [Layout.Top(W3Label1),
                          Layout.Bottom(Layout.Height(50),
                                        Layout.Right(W3Button1)
                                        )]
                         )

Form2 has a label and a button. The layout displays the label (Form2) at the top of the form and the button at the bottom Left

 

fLayout:= Layout.Client(Layout.Margins(10),
                          [Layout.Top(W3Label1),
                          Layout.Bottom(Layout.Height(50),
                                        Layout.Left(W3Button1)
                                        )]
  

 

Form1 displays perfectly,

Form2 displays things all out of whack!

 

view demo here

 

download Code here

Share this post


Link to post
Share on other sites

Awesome!  That worked!

 

Thanx!

 

 

 

 

An workaround is:

Open SmartCL.Layout

goto to line 877 (ALT G) 

 

and comment this

/*    if FControls[iControl] is TLayoutImpl then
      (FControls[iControl] as TLayoutImpl).ResolveDimensionsFromChildren;
*/

 

Share this post


Link to post
Share on other sites

In InitializeObject, controls are not yet fully instantiated and don't have Width/Height.

 

You have to create a layout in InitializeForm.

 

As first Resize is called before the InitializeForm is called, you have to change the code in Resize to:

 

  if assigned(fLayout) then
    fLayout.Resize(self);
 
I have also created a pull request for your GitHub project with corrected code: https://github.com/holmesshanea/smartmobilestudio/pull/1

Share this post


Link to post
Share on other sites

ahhhhh, OK

 

I have reverted the code in the SmartCL.Layout back to its original,  and I have Created my Layouts for my forms, in the InitializeForm as you suggested. I have also changed all my Resize events to include the   "if assigned(fLayout) then" .

 

Everything seems to be working good

 

THANK YOU!

Share this post


Link to post
Share on other sites

Please, take a closer look at TW3Label component, everything seems to be working good but we still have problems with this component. When I click on Form2 button the label component gets invisible, we have an issue with the label container, see the attributes is width: 0px; height: 0px invisible!

<fieldset id="OBJ4" class="TW3Label"
style="visibility: visible; display: inline-block; position: absolute; overflow: hidden; left: 10px; top: 10px; height: 32px; width: 1004px;">

  <div id="OBJ5" class="TW3LabelText"
  style="visibility: visible; display: inline-block; position: absolute; overflow: hidden; left: 0px; top: 0px; text-overflow: ellipsis; white-space: nowrap; width: 0px; height: 0px;">
  Form2</div>
</fieldset>

Note: I'm using SMS 2.2.0.4165 beta4 with the newer RTL (winxp compatible).

Share this post


Link to post
Share on other sites

I am experiencing the same thing in my projects with the labels as well

 

 

Please, take a closer look at TW3Label component, everything seems to be working good but we still have problems with this component. When I click on Form2 button the label component gets invisible, we have an issue with the label container, see the attributes is width: 0px; height: 0px invisible!

<fieldset id="OBJ4" class="TW3Label"
style="visibility: visible; display: inline-block; position: absolute; overflow: hidden; left: 10px; top: 10px; height: 32px; width: 1004px;">

  <div id="OBJ5" class="TW3LabelText"
  style="visibility: visible; display: inline-block; position: absolute; overflow: hidden; left: 0px; top: 0px; text-overflow: ellipsis; white-space: nowrap; width: 0px; height: 0px;">
  Form2</div>
</fieldset>

Note: I'm using SMS 2.2.0.4165 beta4 with the newer RTL (winxp compatible).

Share this post


Link to post
Share on other sites

I can repeat the problem if I click 'Form2', 'Form1', and then again 'Form2'.

 

The problem doesn't occur if I remove the call to fLayout.Resize from TForm2.Resize.

 

We'll have this fixed, thanks for the report!

Share this post


Link to post
Share on other sites

BTW this works as a quick hack for me:

 

procedure TForm2.Resize;
begin
  inherited;
  if assigned(fLayout) then
    fLayout.Resize(self);
  W3Label1.Width := W3Label1.Width - 1;
end;
 
Can you test it, please?

Share this post


Link to post
Share on other sites

It works for me in a simple test with two forms and two labels Layed out at the tops of each forms.

 

However, it doesn't work for TW3HeaderControls. Their Labels are still invisible

 

I tried the following:    

Header.Title.Width := Header.Title.Width - 1;

but it does not work

 

 

 

 

 

 

 

BTW this works as a quick hack for me:

 

procedure TForm2.Resize;
begin
  inherited;
  if assigned(fLayout) then
    fLayout.Resize(self);
  W3Label1.Width := W3Label1.Width - 1;
end;
 
Can you test it, please?

 

Share this post


Link to post
Share on other sites

Did some testing and this is the preferred way layouts should be used if your program has more than one form:

 

  TForm2 = class(TW3Form)
  private
    {$I 'Form2:intf'}
    FLayout: TLayout;
    procedure Form2Deactivate(Sender: TObject);
  protected
    procedure InitializeForm; override;
    procedure InitializeObject; override;
    procedure Resize; override;
  end;
 
implementation
 
{ TForm2 }
 
procedure TForm2.Form2Deactivate(Sender: TObject);
begin
  FLayout := nil;
end;
 
procedure TForm2.InitializeForm;
begin
  inherited;
  // this is a good place to initialize components
  FLayout := Layout.Client(Layout.Top([W3Label1, W3Button1]));
end;
 
procedure TForm2.InitializeObject;
begin
  inherited;
  {$I 'Form2:impl'}
end;
 
procedure TForm2.Resize;
begin
  inherited;
  if assigned(FLayout) then
    FLayout.Resize(Self);
end;
 

Primož

Share this post


Link to post
Share on other sites

The layout manager does not like of TW3Label (SmartCL.Controls.Label.pas), if you replace

                                                      to TW3SimpleLabel (SmartCL.Controls.SimpleLabel.pas) it will work as expected. 

Share this post


Link to post
Share on other sites

Please, take a closer look at TW3Label component, everything seems to be working good but we still have problems with this component. When I click on button the label component gets invisible! 

 

4phWME.gif

Note: I'm using SMS 2.2.0.4165 beta4 with the newer RTL (winxp compatible).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×