]> git.vomp.tv Git - vompclient-marten.git/commitdiff
A _very_ simple screensaver.
authorChris Tallon <chris@vomp.tv>
Wed, 28 Mar 2007 22:46:09 +0000 (22:46 +0000)
committerChris Tallon <chris@vomp.tv>
Wed, 28 Mar 2007 22:46:09 +0000 (22:46 +0000)
objects.mk
vscreensaver.cc [new file with mode: 0644]
vscreensaver.h [new file with mode: 0644]
vwelcome.cc
vwelcome.h

index f86dcaac401c0b3b15ec460f9c9d3638a0d6e6bc..8e4bef7bbe79d75813339d3e982a8d1ac35342fe 100644 (file)
@@ -10,7 +10,7 @@ OBJECTS1 = command.o log.o tcp.o dsock.o thread.o timers.o i18n.o mutex.o     \
            vtimerlist.o vtimeredit.o voptionsmenu.o vrecordingmenu.o          \
            vchannellist.o vwelcome.o vvideolive.o vvideorec.o vepgsettimer.o  \
            vchannelselect.o vserverselect.o vconnect.o vepg.o vrecmove.o      \
-           vradiorec.o vaudioselector.o                                       \
+           vradiorec.o vaudioselector.o vscreensaver.o                        \
            vtabsviewman.o vremoteconfig.o                                     \
            widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o                 \
            woptionbox.o wtextbox.o wwss.o                                     \
diff --git a/vscreensaver.cc b/vscreensaver.cc
new file mode 100644 (file)
index 0000000..c51b714
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+    Copyright 2004-2005 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include "vscreensaver.h"
+
+VScreensaver::VScreensaver()
+{
+  setScreenPos(0, 0);
+  Video* video = Video::getInstance();
+  screenWidth = video->getScreenWidth();
+  screenHeight = video->getScreenHeight();
+  area.w = screenWidth;
+  area.h = screenHeight;
+  surface = Surface::getScreen();
+}
+
+VScreensaver::~VScreensaver()
+{
+  surface = NULL; // it's the screen. stop view base from killing it.
+  threadCancel();
+}
+
+void VScreensaver::draw()
+{
+  setBackgroundColour(Colour::BLACK);
+  View::draw();
+  threadStart();
+}
+
+int VScreensaver::handleCommand(int command)
+{
+  threadCancel();
+
+  return 4;
+}
+
+void VScreensaver::threadMethod()
+{
+  threadSetKillable();
+
+  // Config
+  int h = 50;  // length of line
+  float deviation = 0.2;  // how quickly can it change direction
+
+
+
+  int x[h];
+  int y[h];
+  int i;
+  float direction = 0;
+  float fx;
+  float fy;
+  float dd;
+  const float pi = 3.14159;
+  const float pi2 = 6.28318;
+  float halfdeviation = deviation / 2;
+
+  for(i = 1; i < h; i++)
+  {
+    x[i] = -1;
+    y[i] = -1;
+  }
+
+  fx = x[0] = 50;
+  fy = y[0] = 50;
+
+  while(1)
+  {
+    // Undraw oldest pixel
+    if ((x[h-1] != -1) && (y[h-1] != -1))
+    {
+      surface->drawPixel(x[h-1], y[h-1], Colour::BLACK.rgba());
+    }
+
+    for(i = h - 1; i > 0; i--)
+    {
+      x[i] = x[i-1];
+      y[i] = y[i-1];
+    }
+
+    dd = ((rand() / (double)RAND_MAX) * deviation) - halfdeviation;
+    direction += dd;
+
+    if (direction >= pi2) direction -= pi2;
+    if (direction < 0) direction += pi2;
+
+    fx += sin(direction);
+    fy += cos(direction);
+
+    if (fx < 0){ printf("AAA\n"); fx += screenWidth; }
+    if (fx >= screenWidth){ printf("BBB\n");  fx -= screenWidth; }
+    if (fy < 0){ printf("CCC\n");  fy += screenHeight; }
+    if (fy >= screenHeight){ printf("DDD\n");  fy -= screenHeight; }
+
+    x[0] = (int)fx;
+    y[0] = (int)fy;
+
+    surface->drawPixel(x[0], y[0], Colour::SELECTHIGHLIGHT.rgba());
+    MILLISLEEP(10);
+  }
+}
diff --git a/vscreensaver.h b/vscreensaver.h
new file mode 100644 (file)
index 0000000..4d3330e
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+    Copyright 2007 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef VSCREENSAVER_H
+#define VSCREENSAVER_H
+
+#include <stdlib.h>
+#include <time.h>
+#include <math.h>
+
+#include "defines.h"
+#include "log.h"
+#include "view.h"
+#include "remote.h"
+#include "colour.h"
+#include "video.h"
+#include "video.h"
+
+#ifdef WIN32
+#include "threadwin.h"
+#else
+#include "threadp.h"
+#endif
+
+
+class VScreensaver : public View, public Thread_TYPE
+{
+  public:
+    VScreensaver();
+    ~VScreensaver();
+
+    int handleCommand(int command);
+    void draw();
+
+  private:
+
+    virtual void threadMethod();
+    virtual void threadPostStopCleanup() {};
+
+    int screenHeight;
+    int screenWidth;
+};
+
+#endif
index dd4d334f65afcf09e6c4772054a1fd2cee8c48af..7bfd9cb5b93f0b3b1592a9320b3b653a014197e2 100644 (file)
@@ -192,6 +192,11 @@ int VWelcome::handleCommand(int command)
 #ifdef DEV
     case Remote::NINE:
     {
+      VScreensaver* vscreensaver = new VScreensaver();
+      viewman->add(vscreensaver);
+      vscreensaver->draw();
+//      viewman->updateView(vscreensaver);
+
       return 2;
     }
 #endif
index 3f8be28aa47ff321d6501a8edd9cbaf69bfb59e0..320cc0f68a4276cd0dc29b40d5eadc54da33bbd9 100644 (file)
@@ -40,6 +40,7 @@
 #include "voptionsmenu.h"
 #include "i18n.h"
 #include "timers.h"
+#include "vscreensaver.h"
 
 class VWelcome : public View, public TimerReceiver
 {