]> git.sesse.net Git - vlc/commitdiff
* beginning of tooltips (only in the console at the moment ;)
authorCyril Deguet <asmax@videolan.org>
Sat, 7 Jun 2003 12:19:23 +0000 (12:19 +0000)
committerCyril Deguet <asmax@videolan.org>
Sat, 7 Jun 2003 12:19:23 +0000 (12:19 +0000)
modules/gui/skins/controls/text.cpp
modules/gui/skins/x11/x11_run.cpp
modules/gui/skins/x11/x11_timer.cpp
modules/gui/skins/x11/x11_timer.h
modules/gui/skins/x11/x11_window.cpp
modules/gui/skins/x11/x11_window.h

index 676975e72c1fc52debaeb4b2d80e4ebb192abc28..763f11c9695a0ff899dcde4780ec4c3d1d53856c 100644 (file)
@@ -2,7 +2,7 @@
  * text.cpp: Text control
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: text.cpp,v 1.10 2003/06/05 22:16:15 asmax Exp $
+ * $Id: text.cpp,v 1.11 2003/06/07 12:19:23 asmax Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
@@ -121,13 +121,14 @@ extern intf_thread_t *g_pIntf;
     //-----------------------------------------------------------------------
     // X11 methods
     //----------------------------------------------------------------------- 
-    void ScrollingTextTimer( void *data )
+    bool ScrollingTextTimer( void *data )
     { 
         if( (ControlText *)data != NULL
             && !( (ControlText *)data )->GetSelected() )
         {
             ( (ControlText *)data )->DoScroll();
         }
+        return True;
     }
 
     //-----------------------------------------------------------------------
index 3ddacfc6963440585074dae60009fc209f5c05fa..22095dd9ff1e9ef50cf0abd5284ec93803388819 100644 (file)
@@ -2,7 +2,7 @@
  * x11_run.cpp:
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_run.cpp,v 1.16 2003/06/06 19:40:37 asmax Exp $
+ * $Id: x11_run.cpp,v 1.17 2003/06/07 12:19:23 asmax Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -150,9 +150,10 @@ int ProcessEvent( intf_thread_t *p_intf, VlcProc *proc, XEvent *event )
 }
 
 
-void RefreshCallback( void *data )
+bool RefreshCallback( void *data )
 {
     SkinManage( (intf_thread_t*)data );
+    return True;
 }
 
 
index 71e7461c16bb6ba6ea746a0582ad3ddf304fff8a..06b0c5892a3e2c20cdcabe96e74a300f87deb855 100644 (file)
@@ -2,7 +2,7 @@
  * x11_timer.cpp: helper class to implement timers
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_timer.cpp,v 1.1 2003/06/05 22:16:15 asmax Exp $
+ * $Id: x11_timer.cpp,v 1.2 2003/06/07 12:19:23 asmax Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -55,9 +55,9 @@ mtime_t X11Timer::getNextDate( mtime_t current )
 }
 
 
-void X11Timer::Execute()
+bool X11Timer::Execute()
 {
-    (*_callback)( _data );
+    return (*_callback)( _data );
 }
 
 //---------------------------------------------------------------------------
@@ -112,6 +112,7 @@ void X11TimerManager::Destroy()
 void *X11TimerManager::Thread( void *p_timer )
 {
     vlc_thread_ready( (vlc_object_t*) p_timer );
+
     while( !((timer_thread_t*)p_timer)->die )
     {
         list<X11Timer*>::iterator timer;
@@ -119,11 +120,14 @@ void *X11TimerManager::Thread( void *p_timer )
         for( timer = _instance->_timers.begin(); 
              timer != _instance->_timers.end(); timer++ )
         {
-            (*timer)->Execute();
+            bool ret = (*timer)->Execute();
+            if( !ret ) 
+            {   _instance->_timers.remove( *timer );
+                break;
+            }
         }
         msleep( 100000 );
     }
-    
 }
 
 #endif
index 788a90578364bc49444228cb953fd1b0079343c4..ea181c9942005f8516b89b2c5c239cbe2f7c2ae8 100644 (file)
@@ -2,7 +2,7 @@
  * x11_timer.h: helper class to implement timers
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_timer.h,v 1.1 2003/06/05 22:16:15 asmax Exp $
+ * $Id: x11_timer.h,v 1.2 2003/06/07 12:19:23 asmax Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -36,7 +36,7 @@ typedef struct
 
 class X11Timer;  // forward declaration
 
-typedef void(*callback_t)( void* );
+typedef bool(*callback_t)( void* );
 
 //---------------------------------------------------------------------------
 class X11Timer
@@ -53,7 +53,7 @@ class X11Timer
         ~X11Timer();
 
         mtime_t getNextDate( mtime_t current );
-        void Execute();
+        bool Execute();
 };
 //---------------------------------------------------------------------------
 class X11TimerManager
@@ -74,6 +74,7 @@ class X11TimerManager
         void Destroy();
 
         void addTimer( X11Timer *timer ) { _timers.push_back( timer ); }
+        void removeTimer( X11Timer *timer ) { _timers.remove( timer ); }
 
 };
 //---------------------------------------------------------------------------
index ed3153faa84ef4dd9a0461c911653b88605443b1..97daaf907c7c5d29c56572ce0b590eb94ea6fa5c 100644 (file)
@@ -2,7 +2,7 @@
  * x11_window.cpp: X11 implementation of the Window class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_window.cpp,v 1.11 2003/06/07 00:36:28 asmax Exp $
+ * $Id: x11_window.cpp,v 1.12 2003/06/07 12:19:23 asmax Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
 #include "../src/skin_common.h"
 #include "../src/theme.h"
 #include "../os_theme.h"
+#include "x11_timer.h"
+
+
+bool ToolTipCallback( void *data );
 
 
 //---------------------------------------------------------------------------
@@ -78,24 +82,6 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y,
     CursorPos    = new POINT;
     WindowPos    = new POINT;
 
-    // Create Tool Tip Window
-    ToolTipWindow = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
-        WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
-        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
-        hWnd, 0, GetModuleHandle( NULL ), 0);
-
-    // Create Tool Tip infos
-    ToolTipInfo.cbSize = sizeof(TOOLINFO);
-    ToolTipInfo.uFlags = TTF_SUBCLASS|TTF_IDISHWND;
-    ToolTipInfo.hwnd = hWnd;
-    ToolTipInfo.hinst = GetModuleHandle( NULL );
-    ToolTipInfo.uId = (unsigned int)hWnd;
-    ToolTipInfo.lpszText = NULL;
-    ToolTipInfo.rect.left = ToolTipInfo.rect.top = 0;
-        ToolTipInfo.rect.right = ToolTipInfo.rect.bottom = 0;
-
-    SendMessage( ToolTipWindow, TTM_ADDTOOL, 0,
-                    (LPARAM)(LPTOOLINFO) &ToolTipInfo );
 */
 
     if( DragDrop )
@@ -107,6 +93,9 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y,
 
     // Create Tool Tip window
     ToolTipWindow = XCreateSimpleWindow( display, wnd, 0, 0, 1, 1, 0, 0, 0 );
+    X11Timer *timer = new X11Timer( p_intf, 100, ToolTipCallback, &ToolTipInfo );
+    ToolTipInfo.p_intf = p_intf;
+    ToolTipInfo.timer = timer;
 
     // Double-click handling
     ClickedX = 0;
@@ -369,6 +358,15 @@ void X11Window::Size( int width, int height )
     XResizeWindow( display, Wnd, width, height );
 }
 //---------------------------------------------------------------------------
+
+
+bool ToolTipCallback( void *data )
+{
+    fprintf(stderr," TOOLTIP: %s\n", ((tooltip_t*)data)->text.c_str());
+    return False;
+}
+
+
 void X11Window::ChangeToolTipText( string text )
 {
     if( text == "none" )
@@ -385,10 +383,10 @@ void X11Window::ChangeToolTipText( string text )
         if( text != ToolTipText )
         {
             ToolTipText = text;
+            ToolTipInfo.text = text;
+            X11TimerManager *timerManager = X11TimerManager::Instance( p_intf );
+            timerManager->addTimer( ToolTipInfo.timer );
   //          ToolTipInfo.lpszText = (char *)ToolTipText.c_str();
-  /*          SendMessage( ToolTipWindow, TTM_ACTIVATE, 1 , 0 );
-            SendMessage( ToolTipWindow, TTM_UPDATETIPTEXT, 0,
-                             (LPARAM)(LPTOOLINFO)&ToolTipInfo );*/
         }
     }
 }
index 9af118a0d6224625b082b693388f1ccec0a32b08..a43072b07ba2ef80572cb70a8798e14f579676f0 100644 (file)
@@ -2,7 +2,7 @@
  * x11_window.h: X11 implementation of the Window class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_window.h,v 1.3 2003/06/07 00:36:28 asmax Exp $
+ * $Id: x11_window.h,v 1.4 2003/06/07 12:19:23 asmax Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
 //--- X11 -------------------------------------------------------------------
 #include <X11/Xlib.h>
 
+#include "x11_timer.h"
+
 //---------------------------------------------------------------------------
 class Graphics;
 class Event;
 
+
+typedef struct
+{
+    intf_thread_t *p_intf;
+    X11Timer *timer;
+    string text;
+} tooltip_t;
+
+
 //---------------------------------------------------------------------------
 class X11Window : public SkinWindow
 {
@@ -52,7 +63,7 @@ class X11Window : public SkinWindow
 
         // Tooltip texts
         Window ToolTipWindow;
-//        TOOLINFO ToolTipInfo;
+        tooltip_t ToolTipInfo;
 
         // Double-click handling
         int ClickedX;