Ver Fonte

layout: fixed absolute right, bottom

mattias há 19 horas atrás
pai
commit
b13b80fe9a

+ 3 - 0
demo/Inspector/InspectorDemo.lpi

@@ -49,7 +49,10 @@
       <Unit>
         <Filename Value="InspDemoStyles1.pas"/>
         <IsPartOfProject Value="True"/>
+        <ComponentName Value="DemoStylesWindow"/>
         <HasResources Value="True"/>
+        <ResourceBaseClass Value="Other"/>
+        <ResourceBaseClassname Value="TFresnelForm"/>
       </Unit>
       <Unit>
         <Filename Value="fresnel.cssstyleinspector.pas"/>

+ 1 - 1
demo/Inspector/InspectorDemo.lpr

@@ -17,8 +17,8 @@ uses
 
 begin
   Application.Initialize;
-  Application.CreateForm(TDemoStylesWindow, DemoStylesWindow);
   Application.CreateForm(TDemoForm1, DemoForm1);
+  Application.CreateForm(TDemoStylesWindow, DemoStylesWindow);
   DemoStylesWindow.CSSStyleInspector.Target:=DemoForm1.Div1;
   Application.Run;
 end.

+ 1 - 0
src/base/fresnel.forms.pas

@@ -627,6 +627,7 @@ procedure TFresnelCustomForm.WSResize(const NewFormBounds: TFresnelRect;
 begin
   if (FFormBounds=NewFormBounds) and (Width=NewWidth) and (Height=NewHeight) then exit;
   //FLLog(etDebug,['TFresnelCustomForm.WSResize ',ToString,' OldForm=',FFormBounds.ToString,' NewForm=',NewFormBounds.ToString,' OldWH=',FloatToStr(Width),',',FloatToStr(Height),' NewWH=',FloatToStr(NewWidth),',',FloatToStr(NewHeight)]);
+  //writeln('TFresnelCustomForm.WSResize ',ToString,' OldForm=',FFormBounds.ToString,' NewForm=',NewFormBounds.ToString,' OldWH=',FloatToStr(Width),',',FloatToStr(Height),' NewWH=',FloatToStr(NewWidth),',',FloatToStr(NewHeight));
   FFormBounds:=NewFormBounds;
   Width:=NewWidth;
   Height:=NewHeight;

+ 13 - 5
src/base/fresnel.layouter.pas

@@ -281,6 +281,7 @@ var
 begin
   El:=Node.Element;
 
+  //writeln('TFLNodeLayouter.Apply ',El.ClassName,' ',FloatToCSSStr(Node.Width),'x',FloatToCSSStr(Node.Height));
   MaxWidth:=Node.Width;
   if IsNan(MaxWidth) then
     MaxWidth:=Node.MaxWidth;
@@ -340,6 +341,7 @@ begin
         Node.Height:=AvailHeight;
     end;
 
+    //writeln('TFLNodeLayouter.Apply "',Node.Element.Name,'" AvailWidth=',FloatToCSSStr(AvailWidth));
     ApplyOverflow(AvailWidth,AvailHeight);
     {$IFDEF VerboseFresnelScrolling}
     writeln('TFLNodeLayouter.Apply "',Node.Element.Name,'" ScrollSize: ',FloatToCSSStr(Node.ScrollWidth),'x',FloatToCSSStr(Node.ScrollHeight),' Width=',FloatToCSSStr(Node.Width),' Height=',FloatToCSSStr(Node.Height));
@@ -1251,10 +1253,12 @@ begin
       aMaxHeight:=ChildNode.MaxHeight;
   end;
   Size:=ChildEl.GetIntrinsicContentSize(aMode,aMaxWidth,aMaxHeight);
+  //writeln('TFLLineLayouter.PlaceAbsoluteItem ',ChildEl.GetPath,' Size=',Size.ToString);
   if IsNan(NewWidth) then
     NewWidth:=ChildNode.FitWidth(Size.Width);
   if IsNan(NewHeight) then
     NewHeight:=ChildNode.FitHeight(Size.Height);
+  //writeln('TFLLineLayouter.PlaceAbsoluteItem ',ChildEl.GetPath,' NewWidth=',FloatToCSSStr(NewWidth));
 
   if IsNan(NewLeft) then
   begin
@@ -1277,20 +1281,24 @@ begin
     else
       NewTop:=aMaxHeight-NewBottom-NewHeight-FrameTop-FrameBottom;
   end;
+  if IsNan(NewBottom) then
+  begin
+    if IsNan(aMaxHeight) then
+      NewBottom:=0
+    else
+      NewBottom:=aMaxHeight-NewHeight-FrameTop-FrameBottom-NewTop;
+  end;
 
   // compute right, bottom of marginbox
   Result.Width:=NewLeft+FrameLeft+NewWidth+FrameRight;
   //writeln('TFLLineLayouter.PlaceAbsoluteItem ',ChildEl.Name,' NewLeft=',FloatToCSSStr(NewLeft),' FrameLeft=',FloatToCSSStr(FrameLeft),' NewWidth=',FloatToCSSStr(NewWidth),' FrameRight=',FloatToCSSStr(FrameRight),' NewRight=',FloatToCSSStr(NewRight));
-  if (not IsNan(NewRight)) and (NewRight>0) then
-    Result.Width:=Result.Width+NewRight;
 
   Result.Height:=NewTop+FrameTop+NewHeight+FrameBottom;
   //writeln('TFLLineLayouter.PlaceAbsoluteItem ',ChildEl.Name,' NewTop=',FloatToCSSStr(NewTop),' FrameTop=',FloatToCSSStr(FrameTop),' NewHeight=',FloatToCSSStr(NewHeight),' FrameBottom=',FloatToCSSStr(FrameBottom),' NewBottom=',FloatToCSSStr(NewBottom));
-  if (not IsNan(NewBottom)) and (NewBottom>0) then
-    Result.Height:=Result.Height+NewBottom;
 
   // overflow (render hull)
   Result.Overflow:=Size.Overflow;
+  //writeln('TFLLineLayouter.PlaceAbsoluteItem ',ChildEl.GetPath,' Result=',Result.ToString);
   Result.Overflow.Offset(NewLeft+FrameLeft,NewTop+FrameTop);
   if Result.Overflow.Right<Result.Width then
     Result.Overflow.Right:=Result.Width;
@@ -1512,7 +1520,7 @@ begin
   Result:=default(TFreIntrinsicContentSize);
   FOverflow:=default(TFresnelRect);
 
-  //writeln('AAA5 TFLFlowLayouter.ComputeLayoutContent ',Node.Element.GetPath,' ',aMode,' MaxWidth=',FloatToCSSStr(aMaxWidth),' MaxHeight=',FloatToCSSStr(aMaxHeight),' Commit=',Commit);
+  //writeln('TFLFlowLayouter.ComputeLayoutContent ',Node.Element.GetPath,' ',aMode,' MaxWidth=',FloatToCSSStr(aMaxWidth),' MaxHeight=',FloatToCSSStr(aMaxHeight),' Commit=',Commit);
 
   // ToDo: line-height
   // ToDo: baseline