*/}}
Bläddra i källkod

highlight warning in label

YimingWu 7 månader sedan
förälder
incheckning
5fd3e7f850
3 ändrade filer med 23 tillägg och 1 borttagningar
  1. 18 0
      la_util.c
  2. 1 0
      la_util.h
  3. 4 1
      resources/la_widgets.c

+ 18 - 0
la_util.c

@@ -2353,6 +2353,24 @@ out_error:
     return 0;
 #endif //linux
 }
+int laEnsureDir(const char *dir) {
+#ifdef __linux__
+    char tmp[1024]; char *p = NULL; size_t len;
+    snprintf(tmp, sizeof(tmp),"%s",dir);
+    len = strlen(tmp);
+    if (tmp[len - 1] == '/') tmp[len - 1] = 0;
+    for (p = tmp + 1; *p; p++){
+        if (*p == '/') { *p = 0;
+            mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO);
+            *p = '/';
+        }
+    }
+    mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO);
+    struct stat statbuf;
+    if(stat(dir, &statbuf) != 0){ return 0; }
+    return S_ISDIR(statbuf.st_mode);
+#endif
+}
 
 //======================================================[ translation ]
 

+ 1 - 0
la_util.h

@@ -734,6 +734,7 @@ void strBackspace(laStringEdit* se);
 void strMoveView(laStringEdit *se, int DownLines, int RightCharacters);
 
 int laCopyFile(char *to, char *from);
+int laEnsureDir(const char *dir);
 
 void transNewLanguage(const char * LanguageID);
 void transSetLanguage(const char * LanguageID);

+ 4 - 1
resources/la_widgets.c

@@ -1024,6 +1024,7 @@ void la_LabelDraw(laUiItem *ui, int h){
     laBoxedTheme *bt = (*ui->Type->Theme);
     int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
     int IsHighlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
+    int IsWarning=ui->Flags&LA_UI_FLAGS_WARNING;
 
     if (!ui->State) ui->State = LA_UI_NORMAL;
     if (ui->ExtraInstructions && !ui->Instructions){
@@ -1033,7 +1034,9 @@ void la_LabelDraw(laUiItem *ui, int h){
     //int State = ui->Instructions ? (strArgumentMatch(ui->Instructions, "disabled", "true") ? LA_THEME_DISABLED : LA_UI_NORMAL) : LA_UI_NORMAL;
 
     tnsDrawStringAuto(transLate(SSTR(ui->Display)),
-        IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):(IsHighlight?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT)),
+        IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):
+            (IsHighlight?laAccentColor(LA_BT_TEXT):
+                (IsWarning?laAccentColor(LA_BT_WARNING):laThemeColor(bt,LA_BT_TEXT))),
         ui->L, ui->R, ui->U, ui->Flags);
 }
 void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se){