]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/camwindow.cpp
Wean off #define
[xonotic/netradiant.git] / radiant / camwindow.cpp
index 0f729b40d34a56950380db5760e1e31e3ef5c317..d4dcd43b32168213236b32ef3f7432a725bb7136 100644 (file)
@@ -322,17 +322,8 @@ 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;
-       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;
+       float xf = (float)( x - camera.width / 2 ) / ( camera.width / 2 );
+       float yf = (float)( y - camera.height / 2 ) / ( camera.height / 2 );
 
        xf *= 1.0f - fabsf( yf );
        if ( xf < 0 ) {
@@ -536,11 +527,11 @@ typedef ReferenceCaller<camera_t, &Camera_MoveDown_KeyDown> FreeMoveCameraMoveDo
 typedef ReferenceCaller<camera_t, &Camera_MoveDown_KeyUp> FreeMoveCameraMoveDownKeyUpCaller;
 
 
-#define SPEED_MOVE 32
-#define SPEED_TURN 22.5
-#define MIN_CAM_SPEED 10
-#define MAX_CAM_SPEED 610
-#define CAM_SPEED_STEP 50
+const float SPEED_MOVE = 32;
+const float SPEED_TURN = 22.5;
+const float MIN_CAM_SPEED = 10;
+const float MAX_CAM_SPEED = 610;
+const float CAM_SPEED_STEP = 50;
 
 void Camera_MoveForward_Discrete( camera_t& camera ){
        Camera_Move_updateAxes( camera );
@@ -828,7 +819,7 @@ gboolean mousecontrol_button_press( ui::Widget widget, GdkEventButton* event, Ca
 #endif
 
 void camwnd_update_xor_rectangle( CamWnd& self, rect_t area ){
-       if ( gtk_widget_get_visible( self.m_gl_widget ) ) {
+       if ( self.m_gl_widget.visible() ) {
                self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.getCamera().width, self.getCamera().height ) );
        }
 }
@@ -854,8 +845,7 @@ void selection_motion( gdouble x, gdouble y, guint state, void* data ){
 }
 
 inline WindowVector windowvector_for_widget_centre( ui::Widget widget ){
-       GtkAllocation allocation;
-       gtk_widget_get_allocation(widget, &allocation);
+       auto allocation = widget.dimensions();
        return WindowVector( static_cast<float>( allocation.width / 2 ), static_cast<float>(allocation.height / 2 ) );
 }
 
@@ -1358,7 +1348,7 @@ void SetState( Shader* state, EStyle style ){
                m_state_stack.back().m_state = state;
        }
 }
-const EStyle getStyle() const {
+EStyle getStyle() const {
        return eFullMaterials;
 }
 void PushState(){