*/}}
Browse Source

ui fixes for android

YimingWu 3 months ago
parent
commit
ff3c05516a
2 changed files with 19 additions and 11 deletions
  1. 15 9
      ouroperations.c
  2. 4 2
      ourshader.cpp

+ 15 - 9
ouroperations.c

@@ -189,8 +189,8 @@ void ourui_Layer(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laC
         laShowSeparator(uil,c)->Expand=1;
         laShowItem(uil,c,This,"as_sketch")->Flags|=LA_UI_FLAGS_EXPAND|LA_UI_FLAGS_ICON|LA_UI_FLAGS_NO_CONFIRM;
         laShowSeparator(uil,c);
-        laShowItemFull(uil,c,This,"move",0,"direction=up;icon=🡱;",0,0)->Flags|=LA_UI_FLAGS_ICON;
-        laShowItemFull(uil,c,This,"move",0,"direction=down;icon=🡳;",0,0)->Flags|=LA_UI_FLAGS_ICON;
+        laShowItemFull(uil,c,This,"move",0,"direction=up;icon=🡱;",0,0)->Flags|=LA_UI_FLAGS_ICON|LA_UI_FLAGS_NO_CONFIRM;
+        laShowItemFull(uil,c,This,"move",0,"direction=down;icon=🡳;",0,0)->Flags|=LA_UI_FLAGS_ICON|LA_UI_FLAGS_NO_CONFIRM;
         laEndRow(uil,b);
     }laEndCondition(uil,b1);
 }
@@ -379,12 +379,12 @@ void ourui_ToolsPanel(laUiList *uil, laPropPack *This, laPropPack *DetachedProps
         }laEndCondition(uil,b);
         
         laShowLabel(uil,cr,"Reference:",0,0);
-        laShowItemFull(uil,cr,0,"our.canvas.ref_mode",0,0,0,0)->Flags|=LA_UI_FLAGS_EXPAND;
+        laShowItemFull(uil,cr,0,"our.canvas.ref_mode",0,0,0,0)->Flags|=LA_UI_FLAGS_EXPAND|LA_UI_FLAGS_NO_CONFIRM;
         b=laOnConditionThat(uil,cr,laPropExpression(0,"our.canvas.ref_mode"));{
             laShowItem(uil,cr,0,"our.canvas.ref_alpha");
-            laShowItem(uil,cr,0,"our.canvas.ref_category")->Flags|=LA_UI_FLAGS_EXPAND;
-            laShowItem(uil,cr,0,"our.canvas.ref_size")->Flags|=LA_UI_FLAGS_EXPAND;
-            laShowItem(uil,cr,0,"our.canvas.ref_orientation")->Flags|=LA_UI_FLAGS_EXPAND;
+            laShowItem(uil,cr,0,"our.canvas.ref_category")->Flags|=LA_UI_FLAGS_EXPAND|LA_UI_FLAGS_NO_CONFIRM;
+            laShowItem(uil,cr,0,"our.canvas.ref_size")->Flags|=LA_UI_FLAGS_EXPAND|LA_UI_FLAGS_NO_CONFIRM;
+            laShowItem(uil,cr,0,"our.canvas.ref_orientation")->Flags|=LA_UI_FLAGS_EXPAND|LA_UI_FLAGS_NO_CONFIRM;
             laShowLabel(uil,cr,"Margins:",0,0); laShowItem(uil,cr,0,"our.canvas.ref_margins")->Flags|=LA_UI_FLAGS_TRANSPOSE;
             laShowLabel(uil,cr,"Paddings:",0,0); laShowItem(uil,cr,0,"our.canvas.ref_paddings")->Flags|=LA_UI_FLAGS_TRANSPOSE;
             laShowItem(uil,cr,0,"our.canvas.ref_middle_margin");
@@ -2995,18 +2995,24 @@ void ourui_ToolExtras(laUiList *uil, laPropPack *pp, laPropPack *actinst, laColu
     laShowItemFull(uil,c,0,"our.tool",0,0,0,0)->Flags|=LA_UI_FLAGS_EXPAND|LA_UI_FLAGS_ICON;
     laUiItem* b=laOnConditionThat(uil,c,laEqual(laPropExpression(0,"our.tool"),laIntExpression(0)));{
         laShowItemFull(uil,c,0,"our.erasing",LA_WIDGET_ENUM_HIGHLIGHT,0,0,0)->Flags|=LA_UI_FLAGS_NO_CONFIRM;
-        laUiItem* b1=laOnConditionThat(uil,c,laPropExpression(0,"our.erasing"));{
-            laShowItem(uil,c,0,"our.brush_mix")->Flags|=LA_UI_FLAGS_EXPAND|LA_UI_FLAGS_ICON|LA_UI_FLAGS_DISABLED;
+        laUiItem* b1;
+#ifdef LAGUI_ANDROID
+        laShowItem(uil, c, 0, "LA_undo")->Flags|=LA_UI_FLAGS_NO_CONFIRM|LA_UI_FLAGS_ICON;
+        laShowItem(uil, c, 0, "LA_redo")->Flags|=LA_UI_FLAGS_NO_CONFIRM|LA_UI_FLAGS_ICON;
+#else
+        b1=laOnConditionThat(uil,c,laPropExpression(0,"our.erasing"));{
+            laShowItem(uil,c,0,"our.brush_mix")->Flags|=LA_UI_FLAGS_EXPAND|LA_UI_FLAGS_ICON|LA_UI_FLAGS_DISABLED|LA_UI_FLAGS_NO_CONFIRM;
         }laElse(uil,b1);{
             laShowItem(uil,c,0,"our.brush_mix")->Flags|=LA_UI_FLAGS_EXPAND|LA_UI_FLAGS_ICON|LA_UI_FLAGS_NO_CONFIRM;
         }laEndCondition(uil,b1);
+#endif
         b1=laOnConditionThat(uil,c,laPropExpression(0,"our.preferences.brush_numbers_on_header"));{
             laShowItem(uil,c,0,"our.preferences.brush_number")->Flags|=LA_UI_FLAGS_EXPAND;
         }laEndCondition(uil,b1);
     }laEndCondition(uil,b);
     char str[100]; sprintf(str,"text=%s",MAIN.MenuProgramName);
     laShowItemFull(uil,c,0,"OUR_show_splash",0,str,0,0)->Flags|=LA_UI_FLAGS_NO_DECAL|LA_UI_FLAGS_NO_TOOLTIP|LA_UI_FLAGS_EXIT_WHEN_TRIGGERED;
-#if LAGUI_ANDROID
+#ifdef LAGUI_ANDROID
     laUiList* mu;
     mu = laMakeMenuPage(uil,c,"🖌"); ourui_BrushesPanel(mu,0,0,0,0);
     mu = laMakeMenuPage(uil,c,"🎨"); ourui_ColorPanel(mu,0,0,0,0);

+ 4 - 2
ourshader.cpp

@@ -29,9 +29,11 @@ precision highp float;
 precision highp int;
 layout(r32ui, binding = 0) uniform uimage2D img;
 layout(r32ui, binding = 1) coherent uniform uimage2D smudge_buckets;
+#define OUR_FLT_EPS (1.0/255.0f)
 #else
 layout(rgba16ui, binding = 0) uniform uimage2D img;
 layout(rgba16ui, binding = 1) coherent uniform uimage2D smudge_buckets;
+#define OUR_FLT_EPS (1e-4)
 #endif
 uniform int uCanvasType;
 uniform int uCanvasRandom;
@@ -251,7 +253,7 @@ float brightness(vec4 color) {
 vec4 mix_over(vec4 colora, vec4 colorb){
     vec4 a=(colora.a==0.0f)?colora:vec4(colora.rgb/colora.a,colora.a);
     vec4 b=(colorb.a==0.0f)?colorb:vec4(colorb.rgb/colorb.a,colorb.a);
-    vec4 m=vec4(0,0,0,0); float aa=colora.a/(colora.a+(1.0f-colora.a)*colorb.a+0.0001);
+    vec4 m=vec4(0,0,0,0); float aa=colora.a/(colora.a+(1.0f-colora.a)*colorb.a+OUR_FLT_EPS);
     m=spectral_mix(a,b,aa);
     m.a=colora.a+colorb.a*(1.0f-colora.a);
     m=vec4(m.rgb*m.a,m.a);
@@ -259,7 +261,7 @@ vec4 mix_over(vec4 colora, vec4 colorb){
 }
 int dab(float d, vec2 fpx, vec4 color, float size, float hardness, float smudge, vec4 smudge_color, vec4 last_color, out vec4 final){
     vec4 cc=color;
-    float fac=1.0f-pow(d/size,1.0f+1.0f/(1.0f-hardness+1e-4));
+    float fac=1.0f-pow(d/size,1.0f+1.0f/(1.0f-hardness+OUR_FLT_EPS));
     float canvas=SampleCanvas(fpx,uBrushDirection,fac,uBrushForce,uBrushGunkyness);
     cc.a=color.a*canvas*(1.0f-smudge); cc.rgb=cc.rgb*cc.a;
     float erasing=float(uBrushErasing);