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

Made IDE console toggleble. IDE console will show automatically when running project. Replaced console Clear button with an image button. Added console hide button to console. Added getMainWidth and getMainHeight to UI sizers.

Ivan Safrin 12 лет назад
Родитель
Сommit
ce9250d76b

+ 85 - 1
IDE/Build/Mac OS X/English.lproj/MainMenu.xib

@@ -521,6 +521,30 @@
 							</object>
 						</object>
 					</object>
+					<object class="NSMenuItem" id="429735361">
+						<reference key="NSMenu" ref="649796088"/>
+						<string key="NSTitle">View</string>
+						<string key="NSKeyEquiv"/>
+						<int key="NSMnemonicLoc">2147483647</int>
+						<reference key="NSOnImage" ref="35465992"/>
+						<reference key="NSMixedImage" ref="502551668"/>
+						<string key="NSAction">submenuAction:</string>
+						<object class="NSMenu" key="NSSubmenu" id="623021514">
+							<string key="NSTitle">View</string>
+							<object class="NSMutableArray" key="NSMenuItems">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSMenuItem" id="269422455">
+									<reference key="NSMenu" ref="623021514"/>
+									<string key="NSTitle">Toggle Console</string>
+									<string key="NSKeyEquiv">C</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="35465992"/>
+									<reference key="NSMixedImage" ref="502551668"/>
+								</object>
+							</object>
+						</object>
+					</object>
 					<object class="NSMenuItem" id="947553395">
 						<reference key="NSMenu" ref="649796088"/>
 						<string key="NSTitle">Project</string>
@@ -1136,6 +1160,22 @@
 					</object>
 					<int key="connectionID">594</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">sdfsdf</string>
+						<reference key="source" ref="976324537"/>
+						<reference key="destination" ref="269422455"/>
+					</object>
+					<int key="connectionID">613</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">toggleConsole:</string>
+						<reference key="source" ref="976324537"/>
+						<reference key="destination" ref="269422455"/>
+					</object>
+					<int key="connectionID">614</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
@@ -1177,6 +1217,7 @@
 							<reference ref="379814623"/>
 							<reference ref="448692316"/>
 							<reference ref="947553395"/>
+							<reference ref="429735361"/>
 						</object>
 						<reference key="parent" ref="0"/>
 					</object>
@@ -1704,6 +1745,29 @@
 						<reference key="object" ref="317190896"/>
 						<reference key="parent" ref="720053764"/>
 					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">595</int>
+						<reference key="object" ref="429735361"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="623021514"/>
+						</object>
+						<reference key="parent" ref="649796088"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">596</int>
+						<reference key="object" ref="623021514"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="269422455"/>
+						</object>
+						<reference key="parent" ref="429735361"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">597</int>
+						<reference key="object" ref="269422455"/>
+						<reference key="parent" ref="623021514"/>
+					</object>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1789,6 +1853,9 @@
 					<string>585.IBPluginDependency</string>
 					<string>587.IBPluginDependency</string>
 					<string>588.IBPluginDependency</string>
+					<string>595.IBPluginDependency</string>
+					<string>596.IBPluginDependency</string>
+					<string>597.IBPluginDependency</string>
 					<string>72.IBPluginDependency</string>
 					<string>73.IBPluginDependency</string>
 					<string>75.IBPluginDependency</string>
@@ -1887,6 +1954,9 @@
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -1901,7 +1971,7 @@
 				<reference key="dict.values" ref="0"/>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">594</int>
+			<int key="maxID">614</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1929,6 +1999,7 @@
 							<string>runProject:</string>
 							<string>saveFile:</string>
 							<string>showAbout:</string>
+							<string>toggleConsole:</string>
 						</object>
 						<object class="NSArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1948,6 +2019,7 @@
 							<string>id</string>
 							<string>id</string>
 							<string>id</string>
+							<string>id</string>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="actionInfosByName">
@@ -1970,6 +2042,7 @@
 							<string>runProject:</string>
 							<string>saveFile:</string>
 							<string>showAbout:</string>
+							<string>toggleConsole:</string>
 						</object>
 						<object class="NSArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
@@ -2037,6 +2110,10 @@
 								<string key="name">showAbout:</string>
 								<string key="candidateClassName">id</string>
 							</object>
+							<object class="IBActionInfo">
+								<string key="name">toggleConsole:</string>
+								<string key="candidateClassName">id</string>
+							</object>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="outlets">
@@ -2045,12 +2122,14 @@
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>polycodeView</string>
 							<string>projectMenu</string>
+							<string>sdfsdf</string>
 							<string>window</string>
 						</object>
 						<object class="NSArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>PolycodeView</string>
 							<string>NSMenu</string>
+							<string>NSMenuItem</string>
 							<string>NSWindow</string>
 						</object>
 					</object>
@@ -2060,6 +2139,7 @@
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>polycodeView</string>
 							<string>projectMenu</string>
+							<string>sdfsdf</string>
 							<string>window</string>
 						</object>
 						<object class="NSArray" key="dict.values">
@@ -2072,6 +2152,10 @@
 								<string key="name">projectMenu</string>
 								<string key="candidateClassName">NSMenu</string>
 							</object>
+							<object class="IBToOneOutletInfo">
+								<string key="name">sdfsdf</string>
+								<string key="candidateClassName">NSMenuItem</string>
+							</object>
 							<object class="IBToOneOutletInfo">
 								<string key="name">window</string>
 								<string key="candidateClassName">NSWindow</string>

+ 2 - 0
IDE/Build/Mac OS X/PolycodeAppDelegate.h

@@ -53,6 +53,7 @@ public:
 
 // Menu accessors
 
+-(IBAction) toggleConsole: (id) sender;
 -(IBAction) refreshProject: (id) sender;
 -(IBAction) renameFile: (id) sender;
 -(IBAction) removeFile: (id) sender;
@@ -69,4 +70,5 @@ public:
 -(IBAction) findText: (id) sender;
 -(IBAction) openDocs: (id) sender;
 -(IBAction) showAbout: (id) sender;
+
 @end

+ 4 - 0
IDE/Build/Mac OS X/PolycodeAppDelegate.m

@@ -158,4 +158,8 @@
 	app->showAbout();
 }
 
+-(IBAction) toggleConsole: (id) sender {
+	app->toggleConsole();
+}
+
 @end

+ 3 - 1
IDE/Contents/Include/PolycodeConsole.h

@@ -96,7 +96,8 @@ class ConsoleWindow : public UIElement {
 		UITextInput *debugTextInput;
 		UITextInput *consoleTextInput;
 		
-		UIButton *clearButton;
+		UIImageButton *clearButton;
+		UIImageButton *hideConsoleButton;
 		
 		ScreenShape *labelBg;
 };
@@ -119,6 +120,7 @@ class PolycodeConsole : public UIElement {
 		static void clearBacktraces();
 		void _clearBacktraces();
 		
+		
 		void applyTheme();
 		
 		void _addBacktrace(String fileName, int lineNumber, PolycodeProject *project);

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

@@ -174,6 +174,10 @@ public:
 	
 	void showAssetBrowser(std::vector<String> extensions);
 	
+	void toggleConsole();
+	void showConsole();
+	void hideConsole();
+	
 	void showCurveEditor();
 	
 	PolycodeProjectBrowser *getProjectBrowser();
@@ -216,6 +220,9 @@ private:
 	int frameSizeY;
 	
 	bool willHideModal;
+	
+	bool showingConsole;
+	Number consoleSize;
 
 	ScreenShape *fileDialogBlocker;
 

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

@@ -87,7 +87,8 @@ public:
 	void findText();
 	void runProject();
 	void doRunProject();
-	void exportProject();	
+	void exportProject();
+	void toggleConsole();
 	
 	bool removeEditor(PolycodeEditor *editor);
 	

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


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


+ 13 - 3
IDE/Contents/Source/PolycodeConsole.cpp

@@ -23,9 +23,11 @@
 #include "PolycodeConsole.h"
 #include "PolycodeRemoteDebugger.h"
 #include "PolycodeTextEditor.h"
+#include "PolycodeFrame.h"
 
 PolycodeConsole* PolycodeConsole::instance = NULL;
 extern SyntaxHighlightTheme *globalSyntaxTheme;
+extern PolycodeFrame *globalFrame;
 
 BackTraceEntry::BackTraceEntry(String fileName, int lineNumber, PolycodeProject *project) : UIElement() {
 
@@ -174,16 +176,20 @@ ConsoleWindow::ConsoleWindow() : UIElement() {
 	ScreenLabel *label = new ScreenLabel("CONSOLE", 18, "section");
 	label->color.setColorHexFromString(CoreServices::getInstance()->getConfig()->getStringValue("Polycode", "uiHeaderFontColor"));
 	addChild(label);
-	label->setPosition(5,3);
+	label->setPosition(35,3);
 
 	debugTextInput = new UITextInput(true, 100, 100);
 	consoleTextInput = new UITextInput(false, 100, 100);
 	addChild(consoleTextInput);	
 	addChild(debugTextInput);	
 	
-	clearButton = new UIButton("Clear", 50);
+	clearButton = new UIImageButton("Images/clear_buffer_icon.png");
 	addChild(clearButton);
 	
+	hideConsoleButton = new UIImageButton("Images/console_hide_button.png");
+	addChild(hideConsoleButton);
+	hideConsoleButton->setPosition(7,5);
+	
 }
 
 void ConsoleWindow::Resize(Number width, Number height) {
@@ -192,7 +198,7 @@ void ConsoleWindow::Resize(Number width, Number height) {
 	debugTextInput->Resize(width, height-25-30);
 	debugTextInput->setPosition(0, 30);
 
-	clearButton->setPosition(width - 60, 4);
+	clearButton->setPosition(width - 22, 6);
 
 	consoleTextInput->Resize(width, 25);
 	consoleTextInput->setPosition(0, height-25);	
@@ -223,6 +229,8 @@ PolycodeConsole::PolycodeConsole() : UIElement() {
 	consoleHistoryMaxSize = 15;
 	
 	consoleWindow->clearButton->addEventListener(this, UIEvent::CLICK_EVENT);
+	consoleWindow->hideConsoleButton->addEventListener(this, UIEvent::CLICK_EVENT);
+	
 	CoreServices::getInstance()->getLogger()->addEventListener(this, Event::NOTIFY_EVENT);
 
 	PolycodeConsole::setInstance(this);
@@ -256,6 +264,8 @@ void PolycodeConsole::handleEvent(Event *event) {
 		if(event->getEventType() == "UIEvent" && event->getEventCode() == UIEvent::CLICK_EVENT) {
 			debugTextInput->setText("");
 		}
+	} else if(event->getDispatcher() == consoleWindow->hideConsoleButton) {
+		globalFrame->hideConsole();
 	}
 
 	if(event->getDispatcher() == consoleTextInput) {

+ 27 - 1
IDE/Contents/Source/PolycodeFrame.cpp

@@ -499,7 +499,7 @@ PolycodeFrame::PolycodeFrame() : ScreenEntity() {
 	globalFrame = this;
 	processInputEvents = true;
 	willHideModal = false;
-
+	showingConsole = true;
 	modalChild = NULL;
 	
 	welcomeEntity = new ScreenEntity();
@@ -524,6 +524,8 @@ PolycodeFrame::PolycodeFrame() : ScreenEntity() {
 	mainSizer->setPosition(0, 45);
 	addChild(mainSizer);
 
+	consoleSize = 200;
+
 	consoleSizer = new UIVSizer(100,100,200, false);
 	mainSizer->addRightChild(consoleSizer);	
 				
@@ -743,6 +745,30 @@ void PolycodeFrame::hideModal() {
 	modalBlocker->enabled = false;		
 }
 
+void PolycodeFrame::showConsole() {
+	if(!showingConsole)
+		toggleConsole();
+}
+
+void PolycodeFrame::hideConsole() {
+	if(showingConsole)
+		toggleConsole();
+}
+
+void PolycodeFrame::toggleConsole() {
+	if(showingConsole) {
+		consoleSize = consoleSizer->getMainHeight();
+		consoleSizer->setMainHeight(0);
+		console->visible = false;
+		console->enabled = false;
+	} else {
+		consoleSizer->setMainHeight(consoleSize);	
+		console->visible = true;
+		console->enabled = true;		
+	}
+	showingConsole = !showingConsole;
+}
+
 void PolycodeFrame::Update() {
 	if(willHideModal) {
 		hideModal();

+ 11 - 0
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -160,6 +160,9 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 	editEntry->addItem("Cut", "cut");
 	editEntry->addItem("Copy", "copy");
 
+	UIMenuBarEntry *viewEntry = menuBar->addMenuBarEntry("View");
+	viewEntry->addItem("Toggle Console", "toggle_console", KEY_LSHIFT, KEY_c);
+
 	UIMenuBarEntry *projectEntry = menuBar->addMenuBarEntry("Project");
 	projectEntry->addItem("Run Project", "run_project", KEY_r);
 	projectEntry->addItem("Publish Project", "export_project");
@@ -195,6 +198,10 @@ void PolycodeIDEApp::showAbout() {
 	frame->showModal(frame->aboutWindow);
 }
 
+void PolycodeIDEApp::toggleConsole() {
+	frame->toggleConsole();
+}
+
 void PolycodeIDEApp::doRemoveFile() {
 	if(projectManager->selectedFile != "") {
 		core->removeDiskItem(projectManager->selectedFile);
@@ -344,6 +351,8 @@ void PolycodeIDEApp::doRunProject() {
 	printf("Running project...\n");
 	stopProject();
 
+	frame->showConsole();
+
 	String outPath = PolycodeToolLauncher::generateTempPath(projectManager->getActiveProject()) + ".polyapp";
 	PolycodeToolLauncher::buildProject(projectManager->getActiveProject(), outPath);
 	PolycodeToolLauncher::runPolyapp(outPath);
@@ -504,6 +513,8 @@ void PolycodeIDEApp::handleEvent(Event *event) {
 			openDocs();
 		} else if(action == "show_about") {
 			showAbout();
+		} else if(action == "toggle_console") {
+			toggleConsole();
 		}
 	}
 

+ 1 - 0
Modules/Contents/UI/Include/PolyUIHSizer.h

@@ -37,6 +37,7 @@ namespace Polycode {
 			void handleEvent(Event *event);
 			
 			void setMainWidth(Number width);
+			Number getMainWidth();
 			
 			void addLeftChild(UIElement *element);
 			void addRightChild(UIElement *element);			

+ 1 - 0
Modules/Contents/UI/Include/PolyUIVSizer.h

@@ -37,6 +37,7 @@ namespace Polycode {
 			void handleEvent(Event *event);
 			
 			void setMainHeight(Number height);
+			Number getMainHeight();
 			
 			void addTopChild(UIElement *element);
 			void addBottomChild(UIElement *element);			

+ 4 - 0
Modules/Contents/UI/Source/PolyUIHSizer.cpp

@@ -133,6 +133,10 @@ void UIHSizer::Resize(Number width, Number height) {
 	updateSizer();
 }
 
+Number UIHSizer::getMainWidth() {
+	return mainWidth;
+}
+
 void UIHSizer::setMainWidth(Number width) {
 	mainWidth = width;
 	updateSizer();

+ 4 - 0
Modules/Contents/UI/Source/PolyUIVSizer.cpp

@@ -135,6 +135,10 @@ void UIVSizer::Resize(Number width, Number height) {
 	updateSizer();
 }
 
+Number UIVSizer::getMainHeight() {
+	return mainHeight;
+}
+
 void UIVSizer::setMainHeight(Number height) {
 	mainHeight = height;
 	updateSizer();