From 3a78d902017a780e65f21f12c709aa746dfcab84 Mon Sep 17 00:00:00 2001
From: Garux <garux@mail.ru>
Date: Wed, 2 Aug 2017 09:10:43 +0300
Subject: [PATCH] Radiant:

binds...
	* m1 + shift drag: snapped modes of manipulators:
		freedrag: constrain to axis with biggest move amount
		rotate axis: snap to angles, multiple of 15'
		scale axis: scale all axes synchronously
		scale free: scale axes with non zero drag synchronously (i.e. two visible ones in projection views)
misc...
	* fix: CameraFreeMoveUp, CameraFreeMoveDown shortcuts are editable
	* prism, cone prefabs: increased precision
	* fix: out of pivot rotating is active from start, no additional magic is needed for that
	* fix: could lock (but not set) transform origin in non-pivoted mode
	* arbitrary rotation dialog allows decimals
	* fix: grid rendering with ToggleGridSnap off
	* fix of: scale tool scale, locked to 1 for things w/o bbox with bigger grid (e.g. single misc_model)
		(snapped drag start was = 0, scale func depends on initial click point: closer to center = more extreme scaling)
	* fix: make detail / structural are undoable
	* default autosave period: 5 -> 15 minutes
	* texBro option: hide nonShaders in common folder; def = yes; are shown, if are in use
---
 libs/gtkutil/xorrectangle.h |   1 +
 radiant/autosave.cpp        |   2 +-
 radiant/brush.h             |   3 +-
 radiant/brushmanip.cpp      |  31 ++++---
 radiant/camwindow.cpp       |  81 +++++++++---------
 radiant/select.cpp          |   6 +-
 radiant/selection.cpp       | 165 ++++++++++++++++++++++++++----------
 radiant/texwindow.cpp       |  35 +++++---
 radiant/xywindow.cpp        |   2 +
 9 files changed, 214 insertions(+), 112 deletions(-)

diff --git a/libs/gtkutil/xorrectangle.h b/libs/gtkutil/xorrectangle.h
index 03da9324..3c3d838f 100644
--- a/libs/gtkutil/xorrectangle.h
+++ b/libs/gtkutil/xorrectangle.h
@@ -122,6 +122,7 @@ void set( rectangle_t rectangle ){
 				glVertex2f( rectangle.x, rectangle.y );
 				glEnd();
 
+				glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
 				glDrawBuffer( GL_BACK );
 				GlobalOpenGL_debugAssertNoErrors();
 				//glwidget_swap_buffers( m_widget );
diff --git a/radiant/autosave.cpp b/radiant/autosave.cpp
index fe42687c..cb66cf49 100644
--- a/radiant/autosave.cpp
+++ b/radiant/autosave.cpp
@@ -104,7 +104,7 @@ void Map_Snapshot(){
  */
 
 bool g_AutoSave_Enabled = true;
-int m_AutoSave_Frequency = 5;
+int m_AutoSave_Frequency = 15;
 bool g_SnapShots_Enabled = false;
 
 namespace
diff --git a/radiant/brush.h b/radiant/brush.h
index 611ad115..4c3d5fd1 100644
--- a/radiant/brush.h
+++ b/radiant/brush.h
@@ -376,7 +376,8 @@ SavedState( const FaceShader& faceShader ){
 
 void exportState( FaceShader& faceShader ) const {
 	faceShader.setShader( m_shader.c_str() );
-	faceShader.setFlags( m_flags );
+	//faceShader.setFlags( m_flags );
+	faceShader.m_flags = m_flags;
 }
 };
 
diff --git a/radiant/brushmanip.cpp b/radiant/brushmanip.cpp
index 884c1c0d..520af385 100644
--- a/radiant/brushmanip.cpp
+++ b/radiant/brushmanip.cpp
@@ -138,17 +138,22 @@ void Brush_ConstructPrism( Brush& brush, const AABB& bounds, std::size_t sides,
 		double sv = sin( i * 3.14159265 * 2 / sides );
 		double cv = cos( i * 3.14159265 * 2 / sides );
 
-		planepts[0][( axis + 1 ) % 3] = static_cast<float>( floor( mid[( axis + 1 ) % 3] + radius * cv + 0.5 ) );
-		planepts[0][( axis + 2 ) % 3] = static_cast<float>( floor( mid[( axis + 2 ) % 3] + radius * sv + 0.5 ) );
+//		planepts[0][( axis + 1 ) % 3] = static_cast<float>( floor( mid[( axis + 1 ) % 3] + radius * cv + 0.5 ) );
+//		planepts[0][( axis + 2 ) % 3] = static_cast<float>( floor( mid[( axis + 2 ) % 3] + radius * sv + 0.5 ) );
+		planepts[0][( axis + 1 ) % 3] = static_cast<float>( mid[( axis + 1 ) % 3] + radius * cv );
+		planepts[0][( axis + 2 ) % 3] = static_cast<float>( mid[( axis + 2 ) % 3] + radius * sv );
 		planepts[0][axis] = mins[axis];
 
 		planepts[1][( axis + 1 ) % 3] = planepts[0][( axis + 1 ) % 3];
 		planepts[1][( axis + 2 ) % 3] = planepts[0][( axis + 2 ) % 3];
 		planepts[1][axis] = maxs[axis];
 
-		planepts[2][( axis + 1 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 1 ) % 3] - radius * sv + 0.5 ) );
-		planepts[2][( axis + 2 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 2 ) % 3] + radius * cv + 0.5 ) );
+//		planepts[2][( axis + 1 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 1 ) % 3] - radius * sv + 0.5 ) );
+//		planepts[2][( axis + 2 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 2 ) % 3] + radius * cv + 0.5 ) );
+		planepts[2][( axis + 1 ) % 3] = static_cast<float>( planepts[0][( axis + 1 ) % 3] - radius * sv );
+		planepts[2][( axis + 2 ) % 3] = static_cast<float>( planepts[0][( axis + 2 ) % 3] + radius * cv );
 		planepts[2][axis] = maxs[axis];
+		//globalOutputStream() << planepts[0] << "   " << planepts[2] << "  #" << i << "   sin " << sv << "  cos " << cv << "\n";
 
 		brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
 	}
@@ -189,16 +194,20 @@ void Brush_ConstructCone( Brush& brush, const AABB& bounds, std::size_t sides, c
 		double sv = sin( i * 3.14159265 * 2 / sides );
 		double cv = cos( i * 3.14159265 * 2 / sides );
 
-		planepts[0][0] = static_cast<float>( floor( mid[0] + radius * cv + 0.5 ) );
-		planepts[0][1] = static_cast<float>( floor( mid[1] + radius * sv + 0.5 ) );
+		planepts[0][0] = static_cast<float>( mid[0] + radius * cv );
+		planepts[0][1] = static_cast<float>( mid[1] + radius * sv );
+//		planepts[0][0] = static_cast<float>( floor( mid[0] + radius * cv + 0.5 ) );
+//		planepts[0][1] = static_cast<float>( floor( mid[1] + radius * sv + 0.5 ) );
 		planepts[0][2] = mins[2];
 
 		planepts[1][0] = mid[0];
 		planepts[1][1] = mid[1];
 		planepts[1][2] = maxs[2];
 
-		planepts[2][0] = static_cast<float>( floor( planepts[0][0] - radius * sv + 0.5 ) );
-		planepts[2][1] = static_cast<float>( floor( planepts[0][1] + radius * cv + 0.5 ) );
+		planepts[2][0] = static_cast<float>( planepts[0][0] - radius * sv );
+		planepts[2][1] = static_cast<float>( planepts[0][1] + radius * cv );
+//		planepts[2][0] = static_cast<float>( floor( planepts[0][0] - radius * sv + 0.5 ) );
+//		planepts[2][1] = static_cast<float>( floor( planepts[0][1] + radius * cv + 0.5 ) );
 		planepts[2][2] = maxs[2];
 
 		brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
@@ -428,12 +437,12 @@ void Scene_BrushSetTexdef_Component_Selected( scene::Graph& graph, const Texture
 
 class FaceSetFlags
 {
-const ContentsFlagsValue& m_projection;
+const ContentsFlagsValue& m_flags;
 public:
-FaceSetFlags( const ContentsFlagsValue& flags ) : m_projection( flags ){
+FaceSetFlags( const ContentsFlagsValue& flags ) : m_flags( flags ){
 }
 void operator()( Face& face ) const {
-	face.SetFlags( m_projection );
+	face.SetFlags( m_flags );
 }
 };
 
diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp
index 45f59016..01a7f491 100644
--- a/radiant/camwindow.cpp
+++ b/radiant/camwindow.cpp
@@ -319,17 +319,17 @@ void Camera_FreeMove( camera_t& camera, int dx, int dy ){
 }
 
 void Cam_MouseControl( camera_t& camera, int x, int y ){
-	int xl, xh;
-	int yl, yh;
+//	int xl, xh;
+//	int yl, yh;
 	float xf, yf;
 
 	xf = (float)( x - camera.width / 2 ) / ( camera.width / 2 );
 	yf = (float)( y - camera.height / 2 ) / ( camera.height / 2 );
 
-	xl = camera.width / 3;
-	xh = xl * 2;
-	yl = camera.height / 3;
-	yh = yl * 2;
+//	xl = camera.width / 3;
+//	xh = xl * 2;
+//	yl = camera.height / 3;
+//	yh = yl * 2;
 
 	xf *= 1.0f - fabsf( yf );
 	if ( xf < 0 ) {
@@ -913,101 +913,101 @@ void KeyEvent_disconnect( const char* name ){
 }
 
 void CamWnd_registerCommands( CamWnd& camwnd ){
-	GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_Up ),
+	GlobalKeyEvents_insert( "CameraForward", accelerator_null(),
 							ReferenceCaller<camera_t, Camera_MoveForward_KeyDown>( camwnd.getCamera() ),
 							ReferenceCaller<camera_t, Camera_MoveForward_KeyUp>( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_Down ),
+	GlobalKeyEvents_insert( "CameraBack", accelerator_null(),
 							ReferenceCaller<camera_t, Camera_MoveBack_KeyDown>( camwnd.getCamera() ),
 							ReferenceCaller<camera_t, Camera_MoveBack_KeyUp>( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_Left ),
+	GlobalKeyEvents_insert( "CameraLeft", accelerator_null(),
 							ReferenceCaller<camera_t, Camera_RotateLeft_KeyDown>( camwnd.getCamera() ),
 							ReferenceCaller<camera_t, Camera_RotateLeft_KeyUp>( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_Right ),
+	GlobalKeyEvents_insert( "CameraRight", accelerator_null(),
 							ReferenceCaller<camera_t, Camera_RotateRight_KeyDown>( camwnd.getCamera() ),
 							ReferenceCaller<camera_t, Camera_RotateRight_KeyUp>( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_period ),
+	GlobalKeyEvents_insert( "CameraStrafeRight", accelerator_null(),
 							ReferenceCaller<camera_t, Camera_MoveRight_KeyDown>( camwnd.getCamera() ),
 							ReferenceCaller<camera_t, Camera_MoveRight_KeyUp>( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_comma ),
+	GlobalKeyEvents_insert( "CameraStrafeLeft", accelerator_null(),
 							ReferenceCaller<camera_t, Camera_MoveLeft_KeyDown>( camwnd.getCamera() ),
 							ReferenceCaller<camera_t, Camera_MoveLeft_KeyUp>( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraUp", Accelerator( 'D' ),
+	GlobalKeyEvents_insert( "CameraUp", accelerator_null(),
 							ReferenceCaller<camera_t, Camera_MoveUp_KeyDown>( camwnd.getCamera() ),
 							ReferenceCaller<camera_t, Camera_MoveUp_KeyUp>( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraDown", Accelerator( 'C' ),
+	GlobalKeyEvents_insert( "CameraDown", accelerator_null(),
 							ReferenceCaller<camera_t, Camera_MoveDown_KeyDown>( camwnd.getCamera() ),
 							ReferenceCaller<camera_t, Camera_MoveDown_KeyUp>( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraAngleDown", Accelerator( 'A' ),
-							ReferenceCaller<camera_t, Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
-							ReferenceCaller<camera_t, Camera_PitchDown_KeyUp>( camwnd.getCamera() )
-							);
-	GlobalKeyEvents_insert( "CameraAngleUp", Accelerator( 'Z' ),
+	GlobalKeyEvents_insert( "CameraAngleUp", accelerator_null(),
 							ReferenceCaller<camera_t, Camera_PitchUp_KeyDown>( camwnd.getCamera() ),
 							ReferenceCaller<camera_t, Camera_PitchUp_KeyUp>( camwnd.getCamera() )
 							);
+	GlobalKeyEvents_insert( "CameraAngleDown", accelerator_null(),
+							ReferenceCaller<camera_t, Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
+							ReferenceCaller<camera_t, Camera_PitchDown_KeyUp>( camwnd.getCamera() )
+							);
 
-	GlobalKeyEvents_insert( "CameraFreeMoveForward", Accelerator( 'W' ),
+	GlobalKeyEvents_insert( "CameraFreeMoveForward", accelerator_null(),
 							FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraFreeMoveBack", Accelerator( 'S' ),
+	GlobalKeyEvents_insert( "CameraFreeMoveBack", accelerator_null(),
 							FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraFreeMoveLeft", Accelerator( 'A' ),
+	GlobalKeyEvents_insert( "CameraFreeMoveLeft", accelerator_null(),
 							FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraFreeMoveRight", Accelerator( 'D' ),
+	GlobalKeyEvents_insert( "CameraFreeMoveRight", accelerator_null(),
 							FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() )
 							);
 
-	GlobalKeyEvents_insert( "CameraFreeMoveForward2", Accelerator( GDK_Up ),
+	GlobalKeyEvents_insert( "CameraFreeMoveForward2", accelerator_null(),
 							FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraFreeMoveBack2", Accelerator( GDK_Down ),
+	GlobalKeyEvents_insert( "CameraFreeMoveBack2", accelerator_null(),
 							FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraFreeMoveLeft2", Accelerator( GDK_Left ),
+	GlobalKeyEvents_insert( "CameraFreeMoveLeft2", accelerator_null(),
 							FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraFreeMoveRight2", Accelerator( GDK_Right ),
+	GlobalKeyEvents_insert( "CameraFreeMoveRight2", accelerator_null(),
 							FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() )
 							);
 
-	GlobalKeyEvents_insert( "CameraFreeMoveUp", Accelerator( GDK_period ),
+	GlobalKeyEvents_insert( "CameraFreeMoveUp", accelerator_null(),
 							FreeMoveCameraMoveUpKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveUpKeyUpCaller( camwnd.getCamera() )
 							);
-	GlobalKeyEvents_insert( "CameraFreeMoveDown", Accelerator( GDK_comma ),
+	GlobalKeyEvents_insert( "CameraFreeMoveDown", accelerator_null(),
 							FreeMoveCameraMoveDownKeyDownCaller( camwnd.getCamera() ),
 							FreeMoveCameraMoveDownKeyUpCaller( camwnd.getCamera() )
 							);
 
-	GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, Camera_MoveForward_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Up ) );
-	GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, Camera_MoveBack_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Down ) );
-	GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, Camera_RotateLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Left ) );
-	GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, Camera_RotateRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Right ) );
-	GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, Camera_MoveRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_period ) );
-	GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, Camera_MoveLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_comma ) );
+	GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, Camera_MoveForward_Discrete>( camwnd.getCamera() ) );
+	GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, Camera_MoveBack_Discrete>( camwnd.getCamera() ) );
+	GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, Camera_RotateLeft_Discrete>( camwnd.getCamera() ) );
+	GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, Camera_RotateRight_Discrete>( camwnd.getCamera() ) );
+	GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, Camera_MoveRight_Discrete>( camwnd.getCamera() ) );
+	GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, Camera_MoveLeft_Discrete>( camwnd.getCamera() ) );
 
-	GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, Camera_MoveUp_Discrete>( camwnd.getCamera() ), Accelerator( 'D' ) );
-	GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, Camera_MoveDown_Discrete>( camwnd.getCamera() ), Accelerator( 'C' ) );
-	GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, Camera_PitchUp_Discrete>( camwnd.getCamera() ), Accelerator( 'A' ) );
-	GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, Camera_PitchDown_Discrete>( camwnd.getCamera() ), Accelerator( 'Z' ) );
+	GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, Camera_MoveUp_Discrete>( camwnd.getCamera() ) );
+	GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, Camera_MoveDown_Discrete>( camwnd.getCamera() ) );
+	GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, Camera_PitchUp_Discrete>( camwnd.getCamera() ) );
+	GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, Camera_PitchDown_Discrete>( camwnd.getCamera() ) );
 }
 
 void CamWnd_Move_Enable( CamWnd& camwnd ){
@@ -1997,6 +1997,9 @@ void CamWnd_Construct(){
 	GlobalShortcuts_insert( "CameraFreeMoveLeft2", Accelerator( GDK_Left ) );
 	GlobalShortcuts_insert( "CameraFreeMoveRight2", Accelerator( GDK_Right ) );
 
+	GlobalShortcuts_insert( "CameraFreeMoveUp", accelerator_null() );
+	GlobalShortcuts_insert( "CameraFreeMoveDown", accelerator_null() );
+
 	GlobalToggles_insert( "ShowStats", FreeCaller<ShowStatsToggle>(), ToggleItem::AddCallbackCaller( g_show_stats ) );
 
 	GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals_private.m_showStats ), BoolExportStringCaller( g_camwindow_globals_private.m_showStats ) );
diff --git a/radiant/select.cpp b/radiant/select.cpp
index 83435db0..240c05f4 100644
--- a/radiant/select.cpp
+++ b/radiant/select.cpp
@@ -1169,7 +1169,7 @@ void DoRotateDlg(){
 				}
 				{
 					GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
-					GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
+					GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 1 ) );
 					gtk_widget_show( GTK_WIDGET( spin ) );
 					gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1,
 									  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
@@ -1183,7 +1183,7 @@ void DoRotateDlg(){
 				}
 				{
 					GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
-					GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
+					GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 1 ) );
 					gtk_widget_show( GTK_WIDGET( spin ) );
 					gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2,
 									  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
@@ -1195,7 +1195,7 @@ void DoRotateDlg(){
 				}
 				{
 					GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
-					GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
+					GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 1 ) );
 					gtk_widget_show( GTK_WIDGET( spin ) );
 					gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3,
 									  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
diff --git a/radiant/selection.cpp b/radiant/selection.cpp
index e4364c10..13255cfc 100644
--- a/radiant/selection.cpp
+++ b/radiant/selection.cpp
@@ -193,7 +193,7 @@ class Manipulatable
 {
 public:
 virtual void Construct( const Matrix4& device2manip, const float x, const float y ) = 0;
-virtual void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ) = 0;
+virtual void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ) = 0;
 };
 
 void transform_local2object( Matrix4& object, const Matrix4& local, const Matrix4& local2object ){
@@ -221,12 +221,26 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
 	point_on_sphere( m_start, device2manip, x, y );
 	vector3_normalise( m_start );
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
 	Vector3 current;
-
 	point_on_sphere( current, device2manip, x, y );
-	vector3_normalise( current );
 
+	if( snap ){
+		Vector3 axis( 0, 0, 0 );
+		for( std::size_t i = 0; i < 3; ++i ){
+			if( current[i] == 0.0f ){
+				axis[i] = 1.0f;
+				break;
+			}
+		}
+		if( vector3_length_squared( axis ) != 0 ){
+			constrain_to_axis( current, axis );
+			m_rotatable.rotate( quaternion_for_axisangle( axis, float_snapped( angle_for_axis( m_start, current, axis ), static_cast<float>( c_pi / 12.0 ) ) ) );
+			return;
+		}
+	}
+
+	vector3_normalise( current );
 	m_rotatable.rotate( quaternion_for_unit_vectors( m_start, current ) );
 }
 };
@@ -245,12 +259,17 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
 	constrain_to_axis( m_start, m_axis );
 }
 /// \brief Converts current position to a normalised vector orthogonal to axis.
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
 	Vector3 current;
 	point_on_sphere( current, device2manip, x, y );
 	constrain_to_axis( current, m_axis );
 
-	m_rotatable.rotate( quaternion_for_axisangle( m_axis, angle_for_axis( m_start, current, m_axis ) ) );
+	if( snap ){
+		m_rotatable.rotate( quaternion_for_axisangle( m_axis, float_snapped( angle_for_axis( m_start, current, m_axis ), static_cast<float>( c_pi / 12.0 ) ) ) );
+	}
+	else{
+		m_rotatable.rotate( quaternion_for_axisangle( m_axis, angle_for_axis( m_start, current, m_axis ) ) );
+	}
 }
 
 void SetAxis( const Vector3& axis ){
@@ -285,7 +304,7 @@ TranslateAxis( Translatable& translatable )
 void Construct( const Matrix4& device2manip, const float x, const float y ){
 	point_on_axis( m_start, m_axis, device2manip, x, y );
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
 	Vector3 current;
 	point_on_axis( current, m_axis, device2manip, x, y );
 	current = vector3_scaled( m_axis, distance_for_axis( m_start, current, m_axis ) );
@@ -313,11 +332,22 @@ TranslateFree( Translatable& translatable )
 void Construct( const Matrix4& device2manip, const float x, const float y ){
 	point_on_plane( m_start, device2manip, x, y );
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
 	Vector3 current;
 	point_on_plane( current, device2manip, x, y );
 	current = vector3_subtracted( current, m_start );
 
+	if( snap ){
+		for ( std::size_t i = 0; i < 3 ; ++i ){
+			if( fabs( current[i] ) >= fabs( current[(i + 1) % 3] ) ){
+				current[(i + 1) % 3] = 0.0f;
+			}
+			else{
+				current[i] = 0.0f;
+			}
+		}
+	}
+
 	translation_local2object( current, current, manip2object );
 	vector3_snap( current, GetSnapGridSize() );
 
@@ -326,7 +356,7 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
 };
 
 void GetSelectionAABB( AABB& bounds );
-const Matrix4& ssGetPivot2World();
+const Matrix4& SelectionSystem_GetPivot2World();
 
 class Scalable
 {
@@ -353,14 +383,15 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
 
 	AABB aabb;
 	GetSelectionAABB( aabb );
-	Vector3 transform_origin = vector4_to_vector3( ssGetPivot2World().t() );
-	m_choosen_extent = Vector3( std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
+	Vector3 transform_origin = vector4_to_vector3( SelectionSystem_GetPivot2World().t() );
+	m_choosen_extent = Vector3(
+					std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
 					std::max( aabb.origin[1] + aabb.extents[1] - transform_origin[1], - aabb.origin[1] + aabb.extents[1] + transform_origin[1] ),
 					std::max( aabb.origin[2] + aabb.extents[2] - transform_origin[2], - aabb.origin[2] + aabb.extents[2] + transform_origin[2] )
 							);
 
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
 	//globalOutputStream() << "manip2object: " << manip2object << "  device2manip: " << device2manip << "  x: " << x << "  y:" << y <<"\n";
 	Vector3 current;
 	point_on_axis( current, m_axis, device2manip, x, y );
@@ -369,8 +400,13 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
 	translation_local2object( delta, delta, manip2object );
 	vector3_snap( delta, GetSnapGridSize() );
 
-	Vector3 start( vector3_snapped( m_start, GetSnapGridSize() ) );
-	//globalOutputStream() << "start: " << start << "   delta: " << delta <<"\n";
+	Vector3 start( vector3_snapped( m_start, GetSnapGridSize() != 0.0f ? GetSnapGridSize() : 0.001f ) );
+	for ( std::size_t i = 0; i < 3 ; ++i ){ //prevent snapping to 0 with big gridsize
+		if( float_snapped( m_start[i], 0.001f ) != 0.0f && start[i] == 0.0f ){
+			start[i] = GetSnapGridSize();
+		}
+	}
+	//globalOutputStream() << "m_start: " << m_start << "   start: " << start << "   delta: " << delta <<"\n";
 	Vector3 scale(
 		start[0] == 0 ? 1 : 1 + delta[0] / start[0],
 		start[1] == 0 ? 1 : 1 + delta[1] / start[1],
@@ -378,11 +414,18 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
 		);
 
 	for( std::size_t i = 0; i < 3; i++ ){
-		if( m_choosen_extent[i] > 0.0625 ){ //epsilon to prevent too high scale for set of models, having really small extent, formed by origins
+		if( m_choosen_extent[i] > 0.0625f ){ //epsilon to prevent super high scale for set of models, having really small extent, formed by origins
 			scale[i] = ( m_choosen_extent[i] + delta[i] ) / m_choosen_extent[i];
 		}
 	}
-
+	if( snap ){
+		for( std::size_t i = 0; i < 3; i++ ){
+			if( scale[i] == 1.0f ){
+				scale[i] = vector3_dot( scale, m_axis );
+			}
+		}
+	}
+	//globalOutputStream() << "scale: " << scale <<"\n";
 	m_scalable.scale( scale );
 }
 
@@ -408,13 +451,14 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
 
 	AABB aabb;
 	GetSelectionAABB( aabb );
-	Vector3 transform_origin = vector4_to_vector3( ssGetPivot2World().t() );
-	m_choosen_extent = Vector3( std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
+	Vector3 transform_origin = vector4_to_vector3( SelectionSystem_GetPivot2World().t() );
+	m_choosen_extent = Vector3(
+					std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
 					std::max( aabb.origin[1] + aabb.extents[1] - transform_origin[1], - aabb.origin[1] + aabb.extents[1] + transform_origin[1] ),
 					std::max( aabb.origin[2] + aabb.extents[2] - transform_origin[2], - aabb.origin[2] + aabb.extents[2] + transform_origin[2] )
 							);
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
 	Vector3 current;
 	point_on_plane( current, device2manip, x, y );
 	Vector3 delta = vector3_subtracted( current, m_start );
@@ -422,19 +466,41 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
 	translation_local2object( delta, delta, manip2object );
 	vector3_snap( delta, GetSnapGridSize() );
 
-	Vector3 start( vector3_snapped( m_start, GetSnapGridSize() ) );
+	Vector3 start( vector3_snapped( m_start, GetSnapGridSize() != 0.0f ? GetSnapGridSize() : 0.001f ) );
+	for ( std::size_t i = 0; i < 3 ; ++i ){ //prevent snapping to 0 with big gridsize
+		if( float_snapped( m_start[i], 0.001f ) != 0.0f && start[i] == 0.0f ){
+			start[i] = GetSnapGridSize();
+		}
+	}
 	Vector3 scale(
 		start[0] == 0 ? 1 : 1 + delta[0] / start[0],
 		start[1] == 0 ? 1 : 1 + delta[1] / start[1],
 		start[2] == 0 ? 1 : 1 + delta[2] / start[2]
 		);
 
+	//globalOutputStream() << "m_start: " << m_start << "   start: " << start << "   delta: " << delta <<"\n";
 	for( std::size_t i = 0; i < 3; i++ ){
-		if( m_choosen_extent[i] > 0.0625 ){
+		if( m_choosen_extent[i] > 0.0625f ){
 			scale[i] = ( m_choosen_extent[i] + delta[i] ) / m_choosen_extent[i];
 		}
 	}
-
+	//globalOutputStream() << "pre snap scale: " << scale <<"\n";
+	if( snap ){
+		float bestscale = scale[0];
+		for( std::size_t i = 1; i < 3; i++ ){
+			//if( fabs( 1.0f - fabs( scale[i] ) ) > fabs( 1.0f - fabs( bestscale ) ) ){
+			if( fabs( scale[i] ) > fabs( bestscale ) && scale[i] != 1.0f ){ //harder to scale down with this, but glitchier with upper one
+				bestscale = scale[i];
+			}
+			//globalOutputStream() << "bestscale: " << bestscale <<"\n";
+		}
+		for( std::size_t i = 0; i < 3; i++ ){
+			if( start[i] != 0.0f ){ // !!!!check grid == 0 case
+				scale[i] = ( scale[i] < 0.0f ) ? -fabs( bestscale ) : fabs( bestscale );
+			}
+		}
+	}
+	//globalOutputStream() << "scale: " << scale <<"\n";
 	m_scalable.scale( scale );
 }
 };
@@ -940,6 +1006,8 @@ RotateManipulator( Rotatable& rotatable, std::size_t segments, float radius ) :
 
 	draw_circle( segments, radius * 1.15f, m_circle_screen.m_vertices.data(), RemapXYZ() );
 	draw_circle( segments, radius, m_circle_sphere.m_vertices.data(), RemapXYZ() );
+
+	m_selectable_sphere.setSelected( true );
 }
 
 
@@ -3216,7 +3284,7 @@ void scaleSelected( const Vector3& scaling ){
 	freezeTransforms();
 }
 
-void MoveSelected( const View& view, const float device_point[2] ){
+void MoveSelected( const View& view, const float device_point[2], bool snap ){
 	if ( m_manipulator->isSelected() ) {
 		if ( !m_undo_begun ) {
 			m_undo_begun = true;
@@ -3225,7 +3293,7 @@ void MoveSelected( const View& view, const float device_point[2] ){
 
 		Matrix4 device2manip;
 		ConstructDevice2Manip( device2manip, m_pivot2world_start, view.GetModelview(), view.GetProjection(), view.GetViewport() );
-		m_manipulator->GetManipulatable()->Transform( m_manip2pivot_start, device2manip, device_point[0], device_point[1] );
+		m_manipulator->GetManipulatable()->Transform( m_manip2pivot_start, device2manip, device_point[0], device_point[1], snap );
 	}
 }
 
@@ -3617,11 +3685,6 @@ void RadiantSelectionSystem::ConstructPivot() const {
 }
 
 void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
-	/*if ( !m_pivotChanged || m_pivot_moving ) {
-		return;
-	}*/
-	//m_pivotChanged = false;
-
 	if ( !nothingSelected() && ( m_manipulator_mode == eTranslate || m_manipulator_mode == eRotate || m_manipulator_mode == eScale ) ) {
 		AABB bounds;
 		if ( Mode() == eComponent ) {
@@ -3632,11 +3695,8 @@ void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
 			Scene_BoundsSelected( GlobalSceneGraph(), bounds );
 		}
 		//globalOutputStream() << point << "\n";
-		const float gridsize = GetSnapGridSize();
-		//const float bbox_epsilon = gridsize / 4.0;
-
 		for( std::size_t i = 0; i < 3; i++ ){
-			if( point[i] < 900000 ){
+			if( point[i] < 900000.0f ){
 				float bestsnapDist = fabs( bounds.origin[i] - point[i] );
 				float bestsnapTo = bounds.origin[i];
 				float othersnapDist = fabs( bounds.origin[i] + bounds.extents[i] - point[i] );
@@ -3649,20 +3709,13 @@ void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
 					bestsnapDist = othersnapDist;
 					bestsnapTo = bounds.origin[i] - bounds.extents[i];
 				}
-				othersnapDist = fabs( float_snapped( point[i], gridsize ) - point[i] );
+				othersnapDist = fabs( float_snapped( point[i], GetSnapGridSize() ) - point[i] );
 				if( othersnapDist < bestsnapDist ){
 					bestsnapDist = othersnapDist;
-					bestsnapTo = float_snapped( point[i], gridsize );
+					bestsnapTo = float_snapped( point[i], GetSnapGridSize() );
 				}
 				point[i] = bestsnapTo;
 
-/*				if( float_equal_epsilon( point[i], bestsnapTo, bbox_epsilon ) ){
-					point[i] = bestsnapTo;
-				}
-				else{
-					point[i] = float_snapped( point[i], gridsize );
-				}
-				*/
 				m_pivot2world[i + 12] = point[i]; //m_pivot2world.tx() .ty() .tz()
 			}
 		}
@@ -3692,8 +3745,9 @@ void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
 		default:
 			break;
 		}
+
+		m_pivotIsCustom = true;
 	}
-	m_pivotIsCustom = true;
 }
 
 void RadiantSelectionSystem::getSelectionAABB( AABB& bounds ) const {
@@ -3712,7 +3766,7 @@ void GetSelectionAABB( AABB& bounds ){
 	getSelectionSystem().getSelectionAABB( bounds );
 }
 
-const Matrix4& ssGetPivot2World(){
+const Matrix4& SelectionSystem_GetPivot2World(){
 	return getSelectionSystem().GetPivot2World();
 }
 
@@ -3979,13 +4033,17 @@ class Manipulator_
 public:
 DeviceVector m_epsilon;
 const View* m_view;
+ModifierFlags m_state;
+
+Manipulator_() : m_state( c_modifierNone ){
+}
 
 bool mouseDown( DeviceVector position ){
 	return getSelectionSystem().SelectManipulator( *m_view, &position[0], &m_epsilon[0] );
 }
 
 void mouseMoved( DeviceVector position ){
-	getSelectionSystem().MoveSelected( *m_view, &position[0] );
+	getSelectionSystem().MoveSelected( *m_view, &position[0], ( m_state & c_modifierShift ) == c_modifierShift );
 }
 typedef MemberCaller1<Manipulator_, DeviceVector, &Manipulator_::mouseMoved> MouseMovedCaller;
 
@@ -3995,6 +4053,21 @@ void mouseUp( DeviceVector position ){
 	g_mouseUpCallback.clear();
 }
 typedef MemberCaller1<Manipulator_, DeviceVector, &Manipulator_::mouseUp> MouseUpCaller;
+
+void setState( ModifierFlags state ){
+	m_state = state;
+}
+
+ModifierFlags getState() const {
+	return m_state;
+}
+
+void modifierEnable( ModifierFlags type ){
+	setState( bitfield_enable( getState(), type ) );
+}
+void modifierDisable( ModifierFlags type ){
+	setState( bitfield_disable( getState(), type ) );
+}
 };
 
 void Scene_copyClosestTexture( SelectionTest& test );
@@ -4099,9 +4172,11 @@ void onMouseUp( const WindowVector& position, ButtonIdentifier button, ModifierF
 }
 void onModifierDown( ModifierFlags type ){
 	m_selector.modifierEnable( type );
+	m_manipulator.modifierEnable( type );
 }
 void onModifierUp( ModifierFlags type ){
 	m_selector.modifierDisable( type );
+	m_manipulator.modifierDisable( type );
 }
 };
 
diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp
index ba6c59e4..819d4bc3 100644
--- a/radiant/texwindow.cpp
+++ b/radiant/texwindow.cpp
@@ -276,6 +276,8 @@ bool m_move_started;
 // The uniform size (in pixels) that textures are resized to when m_resizeTextures is true.
 int m_uniformTextureSize;
 int m_uniformTextureMinSize;
+
+bool m_hideNonShadersInCommon;
 // Return the display width of a texture in the texture browser
 void getTextureWH( qtexture_t* tex, int &W, int &H ){
 		// Don't use uniform size
@@ -335,6 +337,7 @@ TextureBrowser() :
 	m_tags( false ),
 	m_uniformTextureSize( 160 ),
 	m_uniformTextureMinSize( 48 ),
+	m_hideNonShadersInCommon( true ),
 	m_move_started( false ){
 }
 };
@@ -476,7 +479,7 @@ CopiedString g_notex;
 CopiedString g_shadernotex;
 
 // if texture_showinuse jump over non in-use textures
-bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bool hideUnused ){
+bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bool hideUnused, bool hideNonShadersInCommon ){
 	// filter notex / shadernotex images
 	if ( g_TextureBrowser_filterNotex && ( string_equal( g_notex.c_str(), shader->getTexture()->name ) || string_equal( g_shadernotex.c_str(), shader->getTexture()->name ) ) ) {
 		return false;
@@ -511,6 +514,11 @@ bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bo
 		return false;
 	}
 
+	if( hideNonShadersInCommon && shader->IsDefault() && !shader->IsInUse() //&& g_TextureBrowser_currentDirectory != ""
+		&& shader_equal_prefix( shader_get_textureName( shader->getName() ), TextureBrowser_getComonShadersDir() ) ){
+		return false;
+	}
+
 	if ( GlobalTextureBrowser().m_searchedTags ) {
 		if ( !TextureSearch_IsShown( shader->getName() ) ) {
 			return false;
@@ -547,7 +555,7 @@ void TextureBrowser_evaluateHeight( TextureBrowser& textureBrowser ){
 		{
 			IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
 
-			if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused ) ) {
+			if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) {
 				continue;
 			}
 
@@ -864,13 +872,7 @@ void TextureBrowser_enableAlpha( const BoolImportCallback& importer ){
 typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
 
 void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ){
-	if ( hideUnused ) {
-		textureBrowser.m_hideUnused = true;
-	}
-	else
-	{
-		textureBrowser.m_hideUnused = false;
-	}
+	textureBrowser.m_hideUnused = hideUnused;
 
 	textureBrowser.m_hideunused_item.update();
 
@@ -898,7 +900,7 @@ void TextureBrowser_Focus( TextureBrowser& textureBrowser, const char* name ){
 	{
 		IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
 
-		if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused ) ) {
+		if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) {
 			continue;
 		}
 
@@ -942,7 +944,7 @@ IShader* Texture_At( TextureBrowser& textureBrowser, int mx, int my ){
 	{
 		IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
 
-		if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused ) ) {
+		if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) {
 			continue;
 		}
 
@@ -1086,7 +1088,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
 	{
 		IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
 
-		if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused ) ) {
+		if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) {
 			continue;
 		}
 
@@ -2717,6 +2719,14 @@ void TextureBrowser_constructPreferences( PreferencesPage& page ){
 		const char* startup_shaders[] = { "None", TextureBrowser_getComonShadersName() };
 		page.appendCombo( "Load Shaders at Startup", reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ), STRING_ARRAY_RANGE( startup_shaders ) );
 	}
+	{
+		StringOutputStream sstream( 256 );
+		sstream << "Hide nonShaders in " << TextureBrowser_getComonShadersDir() << " folder";
+		page.appendCheckBox(
+			"", sstream.c_str(),
+			GlobalTextureBrowser().m_hideNonShadersInCommon
+			);
+	}
 }
 void TextureBrowser_constructPage( PreferenceGroup& group ){
 	PreferencesPage page( group.createPage( "Texture Browser", "Texture Browser Preferences" ) );
@@ -2778,6 +2788,7 @@ void TextureBrowser_Construct(){
 	GlobalPreferenceSystem().registerPreference( "LoadShaders", IntImportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ), IntExportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ) );
 	GlobalPreferenceSystem().registerPreference( "WheelMouseInc", SizeImportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ), SizeExportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ) );
 	GlobalPreferenceSystem().registerPreference( "SI_Colors0", Vector3ImportStringCaller( GlobalTextureBrowser().color_textureback ), Vector3ExportStringCaller( GlobalTextureBrowser().color_textureback ) );
+	GlobalPreferenceSystem().registerPreference( "HideNonShadersInCommon", BoolImportStringCaller( GlobalTextureBrowser().m_hideNonShadersInCommon ), BoolExportStringCaller( GlobalTextureBrowser().m_hideNonShadersInCommon ) );
 
 	g_TextureBrowser.shader = texdef_name_default();
 
diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp
index 0f785741..bab35a07 100644
--- a/radiant/xywindow.cpp
+++ b/radiant/xywindow.cpp
@@ -2155,6 +2155,7 @@ void XYWnd::UpdateCameraIcon( void ){
 				XYWnd::DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
 
 				glDisable( GL_BLEND );
+				glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
 			}
 
 			glDrawBuffer( GL_BACK );
@@ -2601,6 +2602,7 @@ void XYWnd::XY_Draw(){
 	glEnable( GL_BLEND );
 	glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
 	DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
+	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
 	glDisable( GL_BLEND );
 
 	Feedback_draw2D( m_viewType );
-- 
2.39.5