浏览代码

Support styles loading with drag and drop

Ray 6 年之前
父节点
当前提交
4401da21f0
共有 1 个文件被更改,包括 16 次插入3 次删除
  1. 16 3
      examples/controls_test_suite/controls_test_suite.c

+ 16 - 3
examples/controls_test_suite/controls_test_suite.c

@@ -104,6 +104,16 @@ int main()
         exitWindow = WindowShouldClose();
         exitWindow = WindowShouldClose();
         
         
         if (IsKeyPressed(KEY_ESCAPE)) showMessageBox = !showMessageBox;
         if (IsKeyPressed(KEY_ESCAPE)) showMessageBox = !showMessageBox;
+        
+        if (IsFileDropped())
+        {
+            int dropsCount = 0;
+            char **droppedFiles = GetDroppedFiles(&dropsCount);
+            
+            if ((dropsCount > 0) && IsFileExtension(droppedFiles[0], ".rgs")) GuiLoadStyle(droppedFiles[0]);
+            
+            ClearDroppedFiles();    // Clear internal buffers
+        }
         //----------------------------------------------------------------------------------
         //----------------------------------------------------------------------------------
 
 
         // Draw
         // Draw
@@ -126,8 +136,11 @@ int main()
             GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
             GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
             if (GuiTextBox((Rectangle){ 25, 215, 125, 30 }, textBoxText, 64, textBoxEditMode)) textBoxEditMode = !textBoxEditMode;
             if (GuiTextBox((Rectangle){ 25, 215, 125, 30 }, textBoxText, 64, textBoxEditMode)) textBoxEditMode = !textBoxEditMode;
             
             
-            GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
-            if (GuiButton((Rectangle){ 25, 255, 125, 30 }, "#04#SAMPLE TEXT")) { };
+            GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
+            
+            //if (GuiButton((Rectangle){ 25, 255, 125, 30 }, "#05#Open File")) { };
+
+            if (GuiButton((Rectangle){ 25, 255, 125, 30 }, GuiIconText(RICON_FILE_OPEN, "Open File"))) { };
             
             
             GuiGroupBox((Rectangle){ 25, 310, 125, 150 }, "STATES");
             GuiGroupBox((Rectangle){ 25, 310, 125, 150 }, "STATES");
             GuiLock();
             GuiLock();
@@ -149,7 +162,7 @@ int main()
             // Second GUI column      
             // Second GUI column      
             if (GuiListView((Rectangle){ 165, 25, 140, 140 }, "Charmander;Bulbasaur;#18#Squirtel;Pikachu;Eevee;Pidgey", &listViewActive, &listViewScrollIndex, listViewEditMode)) listViewEditMode = !listViewEditMode;
             if (GuiListView((Rectangle){ 165, 25, 140, 140 }, "Charmander;Bulbasaur;#18#Squirtel;Pikachu;Eevee;Pidgey", &listViewActive, &listViewScrollIndex, listViewEditMode)) listViewEditMode = !listViewEditMode;
             if (GuiListViewEx((Rectangle){ 165, 180, 140, 200 }, listViewExList, 8, listViewExElementsEnable, &listViewExActive, &listViewExFocus, &listViewExScrollIndex, listViewExEditMode)) listViewExEditMode = !listViewExEditMode;
             if (GuiListViewEx((Rectangle){ 165, 180, 140, 200 }, listViewExList, 8, listViewExElementsEnable, &listViewExActive, &listViewExFocus, &listViewExScrollIndex, listViewExEditMode)) listViewExEditMode = !listViewExEditMode;
-            if (listViewExFocus >= 0 && listViewExFocus < 8) DrawText(FormatText("FOCUS: %s", listViewExList[listViewExFocus]), 165, 385, 10, listViewExElementsEnable[listViewExFocus] ? LIME : MAROON);
+            //if ((listViewExFocus >= 0) && (listViewExFocus < 8)) DrawText(FormatText("FOCUS: %s", listViewExList[listViewExFocus]), 165, 385, 10, (listViewExElementsEnable[listViewExFocus] > 0)? LIME : MAROON);
             
             
             toggleGroupActive = GuiToggleGroup((Rectangle){ 165, 400, 140, 25 }, "#1#ONE\n#3#TWO\n#8#THREE\n#23#", toggleGroupActive);
             toggleGroupActive = GuiToggleGroup((Rectangle){ 165, 400, 140, 25 }, "#1#ONE\n#3#TWO\n#8#THREE\n#23#", toggleGroupActive);