Browse Source

design: use autosize for new components with children

mattias 10 months ago
parent
commit
c58fbc069e

+ 5 - 0
demo/CheckBox/MainUnit.lfm

@@ -4,5 +4,10 @@ object FresnelCheckBoxForm: TFresnelCheckBoxForm
   FormTop = 206
   FormWidth = 320
   FormHeight = 240
+  Stylesheet.Strings = (
+    ':root {'
+    '  font-size: 15px;'
+    '}'
+  )
   OnCreate = FresnelCheckBoxFormCreate
 end

+ 5 - 6
demo/CheckBox/fresnel.democheckbox.pas

@@ -27,10 +27,10 @@ type
       cStyle = ''
         +'.CheckBoxButton {'+LineEnding
         +'  cursor: pointer;'+LineEnding
-        +'  border-radius: 2px;'+LineEnding
+        +'  border-radius: 0.2em;'+LineEnding
         +'  padding: 1px;'+LineEnding
-        +'  width: 11px;'+LineEnding
-        +'  height: 11px;'+LineEnding
+        +'  width: 1em;'+LineEnding
+        +'  height: 1em;'+LineEnding
         +'}'+LineEnding;
       cCheckedStyle = 'background: #68f; border: 2px solid #68f;';
       cUncheckedStyle = 'background: white; border: 2px solid #999;';
@@ -59,12 +59,11 @@ type
         +'}'+LineEnding
         +TDemoCheckBoxButton.cStyle
         +'.CheckBoxButton {'+LineEnding
-        +'  margin: 0 2px 0 0;'+LineEnding
+        +'  margin: 0 0.2em 0 0;'+LineEnding
         +'}'+LineEnding
         +'.CheckBoxLabel {'+LineEnding
         +'  cursor: pointer;'+LineEnding
-        +'  font-size: 12px;'+LineEnding
-        +'  padding: 2px 3px;'+LineEnding
+        +'  padding: 0.2em 0.3em;'+LineEnding
         +'  margin-bottom: 0;'+LineEnding
         +'}'+LineEnding;
   public

+ 9 - 11
demo/Slider/fresnel.demoslider.pas

@@ -33,25 +33,23 @@ type
     const
       cStyle = ''
        +'.SliderCaptionDiv {'+LineEnding
-       +'  margin-bottom: 4px;'+LineEnding
-       +'  font-size: 12px;'+LineEnding
+       +'  margin-bottom: 0.3em;'+LineEnding
        +'  width: 100%;'+LineEnding
        +'}'+LineEnding
        +'.SliderLabel {'+LineEnding
        +'}'+LineEnding
        +'.SliderValue {'+LineEnding
-       +'  margin-left: 5px;'+LineEnding
-       +'  font-size: 13px;'+LineEnding
+       +'  margin-left: 0.4em;'+LineEnding
        +'  font-weight: 700;'+LineEnding
        +'  color: #f66020;'+LineEnding
        +'}'+LineEnding
        +'.SliderDiv {'+LineEnding
-       +'  margin: 7px 0 5px;'+LineEnding
+       +'  margin: 0.5em 0 0.4em;'+LineEnding
        +'  position: relative;'+LineEnding
        +'  border: 1px solid #5080e0;'+LineEnding
        +'  background-color: #b6d6f0;'+LineEnding
-       +'  height: 9px;'+LineEnding
-       +'  border-radius: 6px;'+LineEnding
+       +'  height: 0.8em;'+LineEnding
+       +'  border-radius: 5px;'+LineEnding
        +'  width: 100%;'+LineEnding
        +'}'+LineEnding
        +'.SliderRange {'+LineEnding
@@ -67,14 +65,14 @@ type
        +'.SliderPoint {'+LineEnding
        +'  position: absolute;'+LineEnding
        +'  z-index: 2;'+LineEnding
-       +'  width: 15px;'+LineEnding
-       +'  height: 15px;'+LineEnding
+       +'  width: 1.3em;'+LineEnding
+       +'  height: 1.3em;'+LineEnding
        +'  border: 1px solid #385590;'+LineEnding
        +'  background-color: #fff;'+LineEnding
        +'  border-radius: 50%;'+LineEnding
        +'  cursor: pointer;'+LineEnding
-       +'  top: -4px;'+LineEnding
-       +'  margin-left: -6px;'+LineEnding
+       +'  top: -0.3em;'+LineEnding
+       +'  margin-left: -0.5em;'+LineEnding
        +'}'+LineEnding;
     var
     CaptionDiv: TDiv;

+ 8 - 6
design/fresnel.register.pas

@@ -345,12 +345,14 @@ begin
       El.SetStyleAttr('top',FloatToCSSPx(BorderBox.Top));
       if not (El is TReplacedElement) then
       begin
-        if NewBounds.Width<=0 then
-          NewBounds.Width:=50;
-        if NewBounds.Height<=0 then
-          NewBounds.Height:=50;
-        El.SetStyleAttr('width',FloatToCSSPx(BorderBox.Width));
-        El.SetStyleAttr('height',FloatToCSSPx(BorderBox.Height));
+        if (BorderBox.Width<=0) and (El.NodeCount=0) then
+          BorderBox.Width:=50;
+        if (BorderBox.Height<=0) and (El.NodeCount=0) then
+          BorderBox.Height:=50;
+        if BorderBox.Width>0 then
+          El.SetStyleAttr('width',FloatToCSSPx(BorderBox.Width));
+        if BorderBox.Height>0 then
+          El.SetStyleAttr('height',FloatToCSSPx(BorderBox.Height));
       end;
     end;
   end else