2
0
Эх сурвалжийг харах

More UI tweaks, UI theme switching in IDE

Ivan Safrin 12 жил өмнө
parent
commit
ffec7d2521

+ 1 - 0
IDE/Contents/Include/PolycodeEditor.h

@@ -53,6 +53,7 @@ class PolycodeEditorAction  {
 		PolycodeEditorActionData *afterData;		
 };
 
+
 class PolycodeEditor : public UIElement, public ClipboardProvider { 
 public:
 	PolycodeEditor(bool _isReadOnly);

+ 7 - 0
IDE/Contents/Include/PolycodeFrame.h

@@ -151,6 +151,13 @@ class EditorHolder : public UIElement {
 		
 };
 
+class PolycodeEditorContainer : public UIElement {
+	public:
+		PolycodeEditorContainer();
+		~PolycodeEditorContainer();
+};
+
+
 class PolycodeFrame : public UIElement {
 public:
 	

+ 3 - 0
IDE/Contents/Include/PolycodeIDEApp.h

@@ -127,6 +127,9 @@ protected:
 	UIMenuBar *menuBar;
 	
 private:
+
+	std::vector<String> projectsToOpen;
+
 	void doCloseProject();
 	void doCloseFiles(std::vector<PolycodeEditor*> editors);
 	

+ 2 - 1
IDE/Contents/Include/SettingsWindow.h

@@ -45,7 +45,8 @@ class SettingsWindow : public UIWindow {
 		UITextInput *externalTextEditorCommand;
 		UIButton *browseButton;
 		UIComboBox *syntaxThemeBox;
-
+		UIComboBox *uiThemeBox;
+		
 		UIButton *cancelButton;
 		UIButton *okButton;
 };

BIN
IDE/Contents/Resources/Images/about.png


BIN
IDE/Contents/Resources/Images/box_icon.png


BIN
IDE/Contents/Resources/Images/cubemap_icon.png


BIN
IDE/Contents/Resources/Images/material_icon.png


BIN
IDE/Contents/Resources/Images/plane_icon.png


BIN
IDE/Contents/Resources/Images/play_icon.png


BIN
IDE/Contents/Resources/Images/remove_icon.png


BIN
IDE/Contents/Resources/Images/screenshader_icon.png


BIN
IDE/Contents/Resources/Images/shader_icon.png


BIN
IDE/Contents/Resources/Images/sphere_icon.png


BIN
IDE/Contents/Resources/Images/torus_icon.png


BIN
IDE/Contents/Resources/UIThemes/default/hsliderBg.png


BIN
IDE/Contents/Resources/UIThemes/default/hsliderHandle.png


BIN
IDE/Contents/Resources/UIThemes/default/templateIcon.png


+ 1 - 0
IDE/Contents/Source/PolycodeEditor.cpp

@@ -24,6 +24,7 @@
 
 extern PolycodeClipboard *globalClipboard;
 
+
 PolycodeEditorFactory::PolycodeEditorFactory() {
 	
 }

+ 8 - 0
IDE/Contents/Source/PolycodeFrame.cpp

@@ -28,6 +28,14 @@ PolycodeFrame *globalFrame;
 
 extern UIGlobalMenu *globalMenu;
 
+PolycodeEditorContainer::PolycodeEditorContainer() {
+
+}
+
+PolycodeEditorContainer::~PolycodeEditorContainer() {
+
+}
+
 EditPoint::EditPoint(BezierPoint *point, unsigned int type) : Entity() {
 	this->point = point;
 	this->type = type;

+ 35 - 15
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -58,17 +58,23 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 	CoreServices::getInstance()->getResourceManager()->addArchive("Physics3D.pak");
 	CoreServices::getInstance()->getResourceManager()->addArchive("UI.pak");
 			
-	CoreServices::getInstance()->getConfig()->loadConfig("Polycode", "UIThemes/default/theme.xml");
-	CoreServices::getInstance()->getResourceManager()->addArchive("UIThemes/default/");
-	CoreServices::getInstance()->getResourceManager()->addArchive("Images/");	
-
 	CoreServices::getInstance()->getFontManager()->registerFont("section", "Fonts/RobotoCondensed-Bold.ttf");
 
-	CoreServices::getInstance()->getRenderer()->clearColor.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiBgColor"));
 
 //	CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Renderer::TEX_FILTERING_LINEAR);
 	CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Renderer::TEX_FILTERING_NEAREST);
 	
+	loadConfigFile();	
+
+	String themeName = CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiTheme");
+	
+	CoreServices::getInstance()->getConfig()->loadConfig("Polycode", "UIThemes/"+themeName+"/theme.xml");
+	CoreServices::getInstance()->getResourceManager()->addArchive("UIThemes/"+themeName+"/");
+	CoreServices::getInstance()->getResourceManager()->addArchive("Images/");	
+
+	CoreServices::getInstance()->getRenderer()->clearColor.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiBgColor"));
+
+	
 	willRunProject = false;
 
 	SceneLabel::defaultAnchor = Vector3(-1.0, -1.0, 0.0);
@@ -126,6 +132,13 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 	
 	frame->Resize(core->getXRes(), core->getYRes());	
 
+	for(int i=0; i < projectsToOpen.size(); i++) {
+		PolycodeProject* project = projectManager->openProject(projectsToOpen[i]);
+		if(project) {
+			OSFileEntry projectEntry =	OSFileEntry(project->getProjectFile(), OSFileEntry::TYPE_FILE);
+			projectManager->setActiveProject(project);
+		}
+	}
 	
 	debugger = new PolycodeRemoteDebugger(projectManager);
 	frame->console->setDebugger(debugger);
@@ -140,7 +153,7 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 		
 	screen->addChild(globalMenu);	
 				
-	loadConfigFile();
+	frame->settingsWindow->updateUI();
 	frame->console->applyTheme();
 
 #ifdef USE_POLYCODEUI_MENUBAR
@@ -903,6 +916,7 @@ void PolycodeIDEApp::handleEvent(Event *event) {
 			if(event->getEventCode() == UIEvent::OK_EVENT) {
 				config->setStringValue("Polycode", "useExternalTextEditor", settingsWindow->useExternalTextEditorBox->isChecked() ? "true" : "false");
 				config->setStringValue("Polycode", "externalTextEditorCommand", settingsWindow->externalTextEditorCommand->getText());
+				config->setStringValue("Polycode", "uiTheme", settingsWindow->uiThemeBox->getSelectedItem()->label);
 			
 				frame->hideModal();
 			}
@@ -977,6 +991,8 @@ void PolycodeIDEApp::saveConfigFile() {
 	configFile.root.name = "config";
 	configFile.root.addChild("open_projects");
 	configFile.root.addChild("syntax_theme", globalSyntaxTheme->name);
+	configFile.root.addChild("ui_theme", config->getStringValue("Polycode", "uiTheme"));
+	
 	for(int i=0; i < projectManager->getProjectCount(); i++) {
 		PolycodeProject *project = projectManager->getProjectByIndex(i);		
 		ObjectEntry *projectEntry = configFile.root["open_projects"]->addChild("project");
@@ -1007,31 +1023,36 @@ void PolycodeIDEApp::loadConfigFile() {
 #else
 	configFile.loadFromXML(core->getUserHomeDirectory()+"/.polycode/config.xml");
 #endif	
+
+	Config *config = CoreServices::getInstance()->getConfig();
+
 	globalSyntaxTheme = new SyntaxHighlightTheme();
+	
+	String uiThemeName = "default";	
+	ObjectEntry *uiTheme = configFile.root["ui_theme"];
+	if(uiTheme) {
+		uiThemeName = uiTheme->stringVal;
+	}	
+	config->setStringValue("Polycode", "uiTheme", uiThemeName);
+	
 	String themeName = "monokai";
 	ObjectEntry *syntaxTheme = configFile.root["syntax_theme"];
 	if(syntaxTheme) {
 		themeName = syntaxTheme->stringVal;
 	}
 	globalSyntaxTheme->loadFromFile(themeName);
-	
+
 	if(configFile.root["open_projects"]) {
 		ObjectEntry *projects = configFile.root["open_projects"];
 		if(projects) {
 			for(int i=0; i < projects->length; i++) {
 				ObjectEntry *entry = (*(*projects)[i])["path"];
 				if(entry) {
-					PolycodeProject* project = projectManager->openProject(entry->stringVal);
-					if(project) {
-						OSFileEntry projectEntry =	OSFileEntry(project->getProjectFile(), OSFileEntry::TYPE_FILE);
-						projectManager->setActiveProject(project);
-					}
+					projectsToOpen.push_back(entry->stringVal);
 				}
 			}
 		}
 	}
-	
-	Config *config = CoreServices::getInstance()->getConfig();
 
 	if(configFile.root["settings"]) {
 		ObjectEntry *settings = configFile.root["settings"];
@@ -1053,7 +1074,6 @@ void PolycodeIDEApp::loadConfigFile() {
 		config->setStringValue("Polycode","useExternalTextEditor", "false");
 		config->setStringValue("Polycode", "externalTextEditorCommand", "");
 	}
-	frame->settingsWindow->updateUI();
 }
 
 

+ 1 - 1
IDE/Contents/Source/PolycodeMaterialEditor.cpp

@@ -692,7 +692,7 @@ MaterialPreviewBox::MaterialPreviewBox() : UIElement() {
 	if(previewBg->getLocalShaderOptions()) {
 	previewBg->getLocalShaderOptions()->addTexture("diffuse", tex);
 	}
-//	previewScene->addChild(previewBg);
+	previewScene->addChild(previewBg);
 	
 	previewScene->clearColor.setColor(0.1, 0.1, 0.1, 0.0);	
 	previewScene->ambientColor.setColor(0.2, 0.2, 0.2, 1.0);

+ 33 - 0
IDE/Contents/Source/SettingsWindow.cpp

@@ -70,6 +70,33 @@ SettingsWindow::SettingsWindow() : UIWindow(L"Settings", SETTINGS_WINDOW_WIDTH,
 	addChild(browseButton);
 	browseButton->setPosition(SETTINGS_WINDOW_WIDTH - (2*padding + BUTTON_WIDTH/2), EDITOR_BROWSE_POS);
 	
+	
+	label = new UILabel("GENERAL", 22, "section", Label::ANTIALIAS_FULL);
+	addChild(label);
+	label->color.a = 1.0;
+	label->setPosition(padding, 200);
+
+	label = new UILabel("UI theme (requires restart)", 12);
+	addChild(label);
+	label->color.a = 1.0;
+	label->setPosition(padding, 235);
+
+	uiThemeBox = new UIComboBox(globalMenu, 300);
+	addChild(uiThemeBox);
+	uiThemeBox->setPosition(padding, 255);
+	uiThemeBox->addEventListener(this, UIEvent::CHANGE_EVENT);
+	
+	std::vector<OSFileEntry> uiThemes = OSBasics::parseFolder(CoreServices::getInstance()->getCore()->getDefaultWorkingDirectory() + "/UIThemes", false);
+	
+	for(int i=0; i < uiThemes.size(); i++) {
+		if(uiThemes[i].type == OSFileEntry::TYPE_FOLDER) {
+			uiThemeBox->addComboItem(uiThemes[i].name);
+			if(uiThemes[i].name == CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiTheme")) {
+				uiThemeBox->setSelectedIndex(i);
+			}
+		}
+	}
+	
 
 	cancelButton = new UIButton("Cancel", BUTTON_WIDTH);
 	cancelButton->addEventListener(this, UIEvent::CLICK_EVENT);
@@ -152,6 +179,12 @@ void SettingsWindow::updateUI() {
 			syntaxThemeBox->setSelectedIndex(i);
 		} 
 	}
+
+	for(int i=0; i < uiThemeBox->getNumItems(); i++) {
+		if(config->getStringValue("Polycode", "uiTheme") == uiThemeBox->getItemAtIndex(i)->label) {
+			uiThemeBox->setSelectedIndex(i);
+		} 
+	}
 	
 }