OBJ = log.o document.o view.o screen.o
LIB_x86_64 = ../contrib/lib/libSDL2-2.0.so.0 -lGL
LIB_i386 = ../contrib/lib32/libSDL2-2.0.so.0 -lGL
+LIB_unknown = $(LIB_x86_64)
MAINRPATH_x86_64 = -Wl,-rpath,'$$ORIGIN/../contrib/lib'
MAINRPATH_i386 = -Wl,-rpath,'$$ORIGIN/../contrib/lib32'
TESTRPATH_x86_64 = -Wl,-rpath,'$$ORIGIN/../../contrib/lib'
DEPS := $(OBJPATHS:%.o=%.d)
CFLAGS_x86_64 := -I../contrib/include/SDL2 -I`pwd`
CFLAGS_i386 := -I../contrib/include32/SDL2 -I`pwd`
+CFLAGS_unknown = $(CFLAGS_x86_64)
+
LIB := $(LIB_$(ARCH))
MAINRPATH := $(MAINRPATH_$(ARCH))
TESTRPATH := $(TESTRPATH_$(ARCH))
CFLAGS := $(CFLAGS_$(ARCH))
+
LINKOBJ = $(OBJPATHS)
RM = rm -f
}
oldx = x;
oldy = y;
+
+ if (wheel)
+ {
+ view.ScaleAroundPoint(Real(x)/Real(scr.ViewportWidth()),Real(y)/Real(scr.ViewportHeight()), expf(-wheel/20.f));
+ }
}
);
while (scr.PumpEvents())
namespace IPDF
{
-//#define REAL_FLOAT
+#define REAL_SINGLE
//#define REAL_DOUBLE
-#define REAL_HALF
+//#define REAL_HALF
#ifdef REAL_SINGLE
typedef float Real;
}
break;
case SDL_MOUSEMOTION:
+ m_last_mouse_x = evt.motion.x;
+ m_last_mouse_y = evt.motion.y;
if (m_mouse_handler)
{
m_mouse_handler(evt.motion.x, evt.motion.y,evt.motion.state, 0);
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
+ m_last_mouse_x = evt.button.x;
+ m_last_mouse_y = evt.button.y;
if (m_mouse_handler)
{
m_mouse_handler(evt.button.x, evt.button.y, evt.button.state, 0);
}
break;
+ case SDL_MOUSEWHEEL:
+ if (m_mouse_handler)
+ {
+ m_mouse_handler(m_last_mouse_x, m_last_mouse_y, 0, evt.wheel.y);
+ }
+ break;
default:
break;
}
void ResizeViewport(int width, int height);
MouseHandler m_mouse_handler;
+ int m_last_mouse_x;
+ int m_last_mouse_y;
int m_viewport_width;
int m_viewport_height;
{
float test = test_min + (test_max-test_min)*((float)(rand() % (int)1e6)/1e6);
Real real(test);
- float thiserror = abs(test - real.value);
+ float thiserror = abs(test - Float(real));
error += thiserror;
- Debug("#%u: |test %.20f - real %.20f| = %.20f [mean %f]", i, test, real.value, thiserror, error/(i+1));
+ Debug("#%u: |test %.20f - real %.20f| = %.20f [mean %f]", i, test, Float(real), thiserror, error/(i+1));
}
if (error/test_count > error_thresh)
void View::Translate(Real x, Real y)
{
+ x *= m_bounds.w;
+ y *= m_bounds.h;
m_bounds.x += x;
m_bounds.y += y;
}
+void View::ScaleAroundPoint(Real x, Real y, Real scaleAmt)
+{
+ // Convert to local coords.
+ x *= m_bounds.w;
+ y *= m_bounds.h;
+ x += m_bounds.x;
+ y += m_bounds.y;
+
+ Debug("Mouse wheel event %f %f %f\n", Float(x), Float(y), Float(scaleAmt));
+
+ Real top = y - m_bounds.y;
+ Real left = x - m_bounds.x;
+
+ top *= scaleAmt;
+ left *= scaleAmt;
+
+ m_bounds.x = x - left;
+ m_bounds.y = y - top;
+ m_bounds.w *= scaleAmt;
+ m_bounds.h *= scaleAmt;
+}
+
void View::Render()
{
static bool debug_output_done = false;
void Render();
void Translate(Real x, Real y);
+ void ScaleAroundPoint(Real x, Real y, Real scaleAmt);
private:
Document & m_document;