瀏覽代碼

IDE text editor tweaks

Ivan Safrin 13 年之前
父節點
當前提交
27b28a43df

+ 1 - 1
Core/Contents/Source/PolyLabel.cpp

@@ -297,7 +297,7 @@ void Label::drawGlyphBitmap(FT_Bitmap *bitmap, unsigned int x, unsigned int y, C
 	
 	Number alphaMultiplier = 1.0;
 	if(antiAliasMode == ANTIALIAS_STRONG) {
-		alphaMultiplier = 1.5;
+		alphaMultiplier = 1.2;
 	}
 
 	switch(antiAliasMode) {

+ 2 - 0
IDE/Contents/Include/PolycodeConsole.h

@@ -104,6 +104,8 @@ class PolycodeConsole : public UIElement {
 		static void clearBacktraces();
 		void _clearBacktraces();
 		
+		void applyTheme();
+		
 		void _addBacktrace(String fileName, int lineNumber, PolycodeProject *project);
 		
 		void Resize(Number width, Number height);

二進制
IDE/Contents/Resources/Fonts/Inconsolata.otf


+ 16 - 0
IDE/Contents/Resources/SyntaxThemes/monokai.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" ?>
+<syntaxTheme useStrongHinting="false">
+	<bgColor r="39" g="40" b="34"/>
+	<cursorColor r="255" g="255" b="255"/>
+	<selectionColor r="51" g="50" b="54"/>
+	<textColors>
+		<color r="233" g="226" b="222"/>
+		<color r="117" g="113" b="94"/>	
+		<color r="249" g="38" b="114"/>
+		<color r="253" g="151" b="31"/>
+		<color r="231" g="220" b="116"/>
+		<color r="102" g="217" b="239"/>		
+		<color r="174" g="128" b="255"/>
+		<color r="0" g="0" b="0"/>		
+	</textColors>
+</syntaxTheme>

+ 9 - 9
IDE/Contents/Resources/SyntaxThemes/solarized_dark.xml

@@ -1,16 +1,16 @@
 <?xml version="1.0" ?>
-<syntaxTheme useStrongHinting="true">
-	<bgColor r="5" g="32" b="42"/>
+<syntaxTheme useStrongHinting="false">
+	<bgColor r="2" g="42" b="55"/>
 	<cursorColor r="130" g="144" b="144"/>
 	<selectionColor r="88" g="110" b="117"/>
 	<textColors>
-		<color r="113" g="130" b="132"/>
-		<color r="71" g="91" b="98"/>
-		<color r="193" g="33" b="114"/>
-		<color r="46" g="145" b="134"/>
-		<color r="204" g="33" b="30"/>
-		<color r="118" g="137" b="0"/>
-		<color r="86" g="90" b="190"/>
+		<color r="133" g="150" b="152"/>
+		<color r="91" g="111" b="118"/>
+		<color r="213" g="53" b="134"/>
+		<color r="66" g="165" b="154"/>
+		<color r="224" g="53" b="50"/>
+		<color r="138" g="157" b="20"/>
+		<color r="106" g="110" b="210"/>
 		<color r="0" g="0" b="0"/>		
 	</textColors>
 </syntaxTheme>

+ 10 - 10
IDE/Contents/Resources/UIThemes/default/theme.xml

@@ -2,14 +2,22 @@
 <PolyConfig>
 	<uiDefaultFontName>sans</uiDefaultFontName>
 	<uiTextInputFontName>sans</uiTextInputFontName>
-	<uiTextInputFontNameMultiLine>editor_font</uiTextInputFontNameMultiLine>
+	<uiTextInputFontNameMultiLine>mono</uiTextInputFontNameMultiLine>
 	<uiDefaultFontSize>11</uiDefaultFontSize>
 	<uiTextInputFontSize>11</uiTextInputFontSize>
-	<uiTextInputFontSizeMultiline>11</uiTextInputFontSizeMultiline>	
+	<uiTextInputFontSizeMultiline>13</uiTextInputFontSizeMultiline>	
 	<uiTreeArrowIconImage>arrowIcon.png</uiTreeArrowIconImage>
 	<uiTreeCellHeight>20</uiTreeCellHeight>
 	<uiTreeCellPadding>4</uiTreeCellPadding>
 	
+	<textBgSkin>textfield.png</textBgSkin>
+	<textBgSkinT>3</textBgSkinT>
+	<textBgSkinR>3</textBgSkinR>
+	<textBgSkinB>3</textBgSkinB>
+	<textBgSkinL>3</textBgSkinL>
+	<textBgSkinPadding>5</textBgSkinPadding>
+	<textEditLineSpacing>14</textEditLineSpacing>
+	
 	<uiTreeCellSkin>treeCellBg.png</uiTreeCellSkin>
 	<uiTreeCellSkinPadding>0</uiTreeCellSkinPadding>
 	<uiTreeCellSkinT>3</uiTreeCellSkinT>
@@ -70,14 +78,6 @@
 	<uiScrollHandleSkinR>6</uiScrollHandleSkinR>
 	<uiScrollHandleSkinB>6</uiScrollHandleSkinB>
 	<uiScrollHandleSkinL>6</uiScrollHandleSkinL>
-	
-	<textBgSkin>textfield.png</textBgSkin>
-	<textBgSkinT>3</textBgSkinT>
-	<textBgSkinR>3</textBgSkinR>
-	<textBgSkinB>3</textBgSkinB>
-	<textBgSkinL>3</textBgSkinL>
-	<textBgSkinPadding>5</textBgSkinPadding>
-	<textEditLineSpacing>12</textEditLineSpacing>
 		
 	<uiScrollHandleMinSize>30</uiScrollHandleMinSize>	
 	<uiTreeContainerScrollBarOffset>27</uiTreeContainerScrollBarOffset>

+ 12 - 0
IDE/Contents/Source/PolycodeConsole.cpp

@@ -22,8 +22,10 @@
 
 #include "PolycodeConsole.h"
 #include "PolycodeRemoteDebugger.h"
+#include "PolycodeTextEditor.h"
 
 PolycodeConsole* PolycodeConsole::instance = NULL;
+extern SyntaxHighlightTheme *globalSyntaxTheme;
 
 BackTraceEntry::BackTraceEntry(String fileName, int lineNumber, PolycodeProject *project) : UIElement() {
 
@@ -170,6 +172,7 @@ PolycodeConsole::PolycodeConsole() : UIElement() {
 	debugTextInput = new UITextInput(true, 100, 100);
 	backtraceSizer->addLeftChild(debugTextInput);
 
+
 	backtraceWindow = new BackTraceWindow();
 	backtraceSizer->addRightChild(backtraceWindow);
 
@@ -183,10 +186,19 @@ PolycodeConsole::PolycodeConsole() : UIElement() {
 	PolycodeConsole::setInstance(this);
 }
 
+
 PolycodeConsole::~PolycodeConsole() {
 
 }
 
+void PolycodeConsole::applyTheme() {
+	debugTextInput->setBackgroundColor(globalSyntaxTheme->bgColor);
+	debugTextInput->setCursorColor(globalSyntaxTheme->cursorColor);
+	debugTextInput->setSelectionColor(globalSyntaxTheme->selectionColor);
+	debugTextInput->useStrongHinting = globalSyntaxTheme->useStrongHinting;
+	debugTextInput->setTextColor(globalSyntaxTheme->colors[0]);
+}
+
 void PolycodeConsole::setDebugger(PolycodeRemoteDebugger *debugger) {
 	this->debugger = debugger;
 }

+ 3 - 3
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -50,9 +50,8 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 
 	CoreServices::getInstance()->getFontManager()->registerFont("section", "Fonts/LeagueGothic-Regular.otf");	
 
-	CoreServices::getInstance()->getFontManager()->registerFont("editor_font", "/Library/Fonts/Menlo.ttc");
+	CoreServices::getInstance()->getFontManager()->registerFont("editor_font", "Fonts/Inconsolata.otf");
 
-	
 //	CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Renderer::TEX_FILTERING_LINEAR);
 	CoreServices::getInstance()->getRenderer()->setTextureFilteringMode(Renderer::TEX_FILTERING_NEAREST);
 	
@@ -112,6 +111,7 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 	screen->addChild(globalMenu);	
 				
 	loadConfigFile();
+	frame->console->applyTheme();
 }
 
 void PolycodeIDEApp::renameFile() {
@@ -502,7 +502,7 @@ void PolycodeIDEApp::loadConfigFile() {
 	if(syntaxTheme) {
 		themeName = syntaxTheme->stringVal;
 	}
-	themeName = "solarized_dark";	
+	themeName = "monokai";	
 	globalSyntaxTheme->loadFromFile(themeName);
 	
 	if(configFile.root["open_projects"]) {

+ 4 - 1
Modules/Contents/UI/Include/PolyUITextInput.h

@@ -105,7 +105,8 @@ namespace Polycode {
 			void setBackgroundColor(Color color);
 			void setSelectionColor(Color color);
 			void setCursorColor(Color color);
-						
+			void setTextColor(Color color);
+			
 			void replaceAll(String what, String withWhat);
 			
 			void findString(String stringToFind, bool replace=false, String replaceString="");
@@ -132,6 +133,8 @@ namespace Polycode {
 			bool useStrongHinting;
 		
 		protected:
+		
+			Color textColor;
 				
 			void setUndoState(UITextInputUndoState state);
 			void saveUndoState();

+ 13 - 3
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -150,6 +150,8 @@ UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElemen
 	
 	syntaxHighliter = NULL;
 	
+	textColor = Color(0.0,0.0,0.0,1.0);
+	
 	insertLine(true);		
 }
 
@@ -413,7 +415,7 @@ int UITextInput::insertLine(bool after) {
 	}
 
 	ScreenLabel *newLine = new ScreenLabel(L"", fontSize, fontName, aaMode);
-	newLine->setColor(0,0,0,1);
+	newLine->color = textColor;
 	lineHeight = newLine->getHeight();
 	linesContainer->addChild(newLine);
 	
@@ -702,7 +704,7 @@ void UITextInput::findCurrent() {
 
 void UITextInput::setCaretToMouse(Number x, Number y) {
 	clearSelection();
-	x -= (padding* 2.0);
+	x -= (padding);
 	y -= padding;
 	//if(lines.size() > 1) {
 		lineOffset = y  / (lineHeight+lineSpacing);
@@ -715,10 +717,11 @@ void UITextInput::setCaretToMouse(Number x, Number y) {
 	Number slen;
 	
 	int newCaretPosition = -1;
+	
 	for(int i=1; i < len; i++) {
 		slen = currentLine->getLabel()->getTextWidthForString(currentLine->getText().substr(0,i));
 		Number slen_prev = currentLine->getLabel()->getTextWidthForString(currentLine->getText().substr(0,i-1));		
-		if(x > slen_prev && x < slen) {
+		if(x >= slen_prev && x <= slen) {
 			if(x < slen_prev + ((slen - slen_prev) /2.0)) {
 				newCaretPosition = i-1;
 				break;			
@@ -847,6 +850,13 @@ void UITextInput::setBackgroundColor(Color color) {
 	inputRect->color = color;
 }
 
+void UITextInput::setTextColor(Color color) {
+	textColor = color;
+	for(int i=0; i < lines.size(); i++) {
+		lines[i]->color = textColor;
+	}
+}
+
 UIScrollContainer *UITextInput::getScrollContainer() {
 	return scrollContainer;
 }