Просмотр исходного кода

Added a close file button next to the file selector combobox.

Ethan M 12 лет назад
Родитель
Сommit
c8a2a2a53c

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

@@ -214,6 +214,9 @@ public:
 	
 	UIWindow *aboutWindow;
 	UIButton *aboutOKButton;
+	
+	UIImageButton *closeFileButton;
+	
 	void updateFileSelector();
 	void showNextEditor();
 	void showPreviousEditor();
@@ -258,4 +261,6 @@ private:
 	UIButton *newProjectButton;
 	UIButton *examplesButton;
 	
+	bool displayFilePathInSelector;
+
 };

+ 3 - 2
IDE/Contents/Source/PolycodeFrame.cpp

@@ -566,9 +566,10 @@ PolycodeFrame::PolycodeFrame() : ScreenEntity() {
 
 	currentFileSelector = new UIComboBox(globalMenu, 300);
 	currentFileSelector->addEventListener(this, UIEvent::CHANGE_EVENT);
-	
 	addChild(currentFileSelector);
 
+	closeFileButton = new UIImageButton("Images/remove_icon.png");
+	addChild(closeFileButton);
 	
 	resizer = new ScreenImage("Images/corner_resize.png");	
 	addChild(resizer);
@@ -920,7 +921,7 @@ void PolycodeFrame::Resize(int x, int y) {
 	fileDialogBlocker->setShapeSize(x, y);
 		
 	currentFileSelector->setPosition(x-350, 11);
-	
+	closeFileButton->setPosition(currentFileSelector->getPosition().x-20, currentFileSelector->getPosition().y+6);
 	
 	if(this->modalChild) {
 		modalChild->setPosition((x-modalChild->getWidth())/2.0f, (y-modalChild->getHeight())/2.0f);

+ 13 - 1
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -183,6 +183,8 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 
 	needsRedraw = false;
 	lastConnected = false;
+	
+	frame->closeFileButton->addEventListener(this, UIEvent::CLICK_EVENT);
 }
 
 void PolycodeIDEApp::renameFile() {
@@ -812,7 +814,17 @@ void PolycodeIDEApp::handleEvent(Event *event) {
 			
 			frame->hideModal();			
 		}
-	}	
+	}
+	
+	// close files and editors after the close file button is pressed
+	if (event->getDispatcher() == frame->closeFileButton) {
+		if (event->getEventCode() == UIEvent::CLICK_EVENT) {
+			if (core->getInput()->getKeyState(KEY_RSHIFT) || core->getInput()->getKeyState(KEY_LSHIFT))
+				closeFiles(editorManager->openEditors);
+			else
+				closeFile();
+		}
+	}
 }
 
 void PolycodeIDEApp::saveConfigFile() {