* button.cpp: Button control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: button.cpp,v 1.13 2003/05/26 02:09:27 gbazin Exp $
+ * $Id: button.cpp,v 1.14 2003/05/31 23:23:59 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
// General
Left = x;
Top = y;
- State = 1; // 1 = up - 0 = down
+ State = 1; // 1=up, 0=down
Selected = false;
Enabled = true;
CursorIn = false;
bool ControlButton::MouseUp( int x, int y, int button )
{
// If hit in the button
+ // XXX: we suppose here that the expected behaviour is to have the MouseUp
+ // event above the "up" image, and not above the "down" one. This can give
+ // strange results when the "up" and "down" images have different sizes...
if( Img[1]->Hit( x - Left, y - Top ) )
{
if( !Enabled )
if( !Enabled )
return false;
-
if( MouseOver( x, y ) && !CursorIn )
{
if( button == 1 && Selected )
CursorIn = true;
return true;
}
- else if( !MouseOver( x, y ) & CursorIn )
+ else if( !MouseOver( x, y ) && CursorIn )
{
-
if( button == 1 && Selected )
{
State = 1;
* generic.cpp: Generic control, parent of the others
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: generic.cpp,v 1.6 2003/04/28 12:25:34 asmax Exp $
+ * $Id: generic.cpp,v 1.7 2003/05/31 23:23:59 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
}
//---------------------------------------------------------------------------
-bool GenericControl::IsID( string id )
-{
- if( ID == "none" || ID != id )
- {
- return false;
- }
- else
- {
- return true;
- }
-}
-//---------------------------------------------------------------------------
void GenericControl::Init()
{
}
* generic.h: Generic control, parent of the others
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: generic.h,v 1.4 2003/04/28 12:25:34 asmax Exp $
+ * $Id: generic.h,v 1.5 2003/05/31 23:23:59 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
{
protected:
SkinWindow * ParentWindow;
+ intf_thread_t *p_intf;
bool Visible;
string ID;
string Help;
- intf_thread_t *p_intf;
+ int Left; // Left offset of the control
+ int Top; // Top offset of the control
+ int Width; // Width of the control
+ int Height; // Height of the control
+ int State; // Used to special state of the control
+ // (for button, sets whether down or up)
+ Bitmap **Img; // Array of bitmap used to draw control
private:
public:
// Constructor
- GenericControl( string id, bool visible, string help, SkinWindow *Parent );
+ GenericControl( string id, bool visible, string help,
+ SkinWindow *Parent );
// Destructor
virtual ~GenericControl();
// Create a region from a bitmap with transcolor as empty region
SkinRegion *CreateRegionFromBmp( Bitmap *bmp, int MoveX, int MoveY );
- int Left; // Left offset of the control
- int Top; // Top offset of the control
- int Width; // Width of the control
- int Height; // Height of the control
- int State; // Used to special state of the control
- // (for button, sets whether down or up)
- Bitmap **Img; // Array of bitmap used to draw control
// Enabling control
virtual void Enable( Event *event, bool enabled );
- // Found if ID matches
- bool IsID( string id );
+ // Self explanatory
+ bool IsVisible() { return Visible; }
+
+ // Getters
+ string GetId() { return ID; }
+ int GetLeft() { return Left; }
+ int GetTop() { return Top; }
+ int GetWidth() { return Width; }
+ int GetHeight() { return Height; }
};
//---------------------------------------------------------------------------
* playlist.cpp: Playlist control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: playlist.cpp,v 1.10 2003/04/28 12:25:34 asmax Exp $
+ * $Id: playlist.cpp,v 1.11 2003/05/31 23:23:59 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
delete[] y;
// Get size of control
- Left = Slider->Left;
- Top = Slider->Top;
- Width = Slider->Left + Slider->Width;
- Height = Slider->Top + Slider->Height;
+ Left = Slider->GetLeft();
+ Top = Slider->GetTop();
+ Width = Slider->GetLeft() + Slider->GetWidth();
+ Height = Slider->GetTop() + Slider->GetHeight();
if( TextLeft < Left )
Left = TextLeft;
if( TextTop < Top )
* playlist.h: Playlist control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: playlist.h,v 1.5 2003/04/28 12:25:34 asmax Exp $
+ * $Id: playlist.h,v 1.6 2003/05/31 23:23:59 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
{
private:
Event *UpdateEvent;
- SkinFont *TextFont;
- SkinFont *PlayFont;
+ SkinFont *TextFont;
+ SkinFont *PlayFont;
string FontName;
string PlayFontName;
bool Enabled;
* event.cpp: Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: event.cpp,v 1.15 2003/05/05 16:29:57 gbazin Exp $
+ * $Id: event.cpp,v 1.16 2003/05/31 23:23:59 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
else if( Desc == "VLC_NET_ADDUDP" )
return VLC_NET_ADDUDP;
- // Window event
+ // Window events
else if( Desc == "WINDOW_MOVE" )
return WINDOW_MOVE;
else if( Desc == "WINDOW_OPEN" )
else if( Desc == "WINDOW_FADE" )
return WINDOW_FADE;
- // Control event
+ // Control events
else if( Desc == "CTRL_ENABLED" )
return CTRL_ENABLED;
else if( Desc == "CTRL_VISIBLE" )
return CTRL_SET_SLIDER;
- // Control event by ID
+ // Control events by ID
else if( Desc == "CTRL_ID_VISIBLE" )
return CTRL_ID_VISIBLE;
else if( Desc == "CTRL_ID_ENABLED" )
{
for( i = 0; i < (*win)->ControlList.size(); i++ )
{
- if( (*win)->ControlList[i]->IsID( id ) )
+ if( (*win)->ControlList[i]->GetId() == id )
return (*win)->ControlList[i];
}
}
* window.cpp: Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: window.cpp,v 1.24 2003/05/26 02:09:27 gbazin Exp $
+ * $Id: window.cpp,v 1.25 2003/05/31 23:23:59 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
// Graphics *Buffer = (Graphics *)new OSGraphics( w, h, this );
// Draw every control
- for( i = 0; i < ControlList.size(); i++ )
- ControlList[i]->Draw( x, y, w, h, Buffer );
+ for( i = 0; i < ControlList.size(); i++ )
+ ControlList[i]->Draw( x, y, w, h, Buffer );
// Copy buffer in Image
Image->CopyFrom( x, y, w, h, Buffer, 0, 0, SRC_COPY );
// And copy buffer to window
RefreshFromImage( x, y, w, h );
-
}
//---------------------------------------------------------------------------
void SkinWindow::RefreshAll()
//---------------------------------------------------------------------------
void SkinWindow::MouseDown( int x, int y, int button )
{
-
// Checking event in controls
- for( int i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( int i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseDown( x, y, button ) )
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseDown( x, y, button ) )
{
- return;
+ msg_Dbg( p_intf, "Mouse down (ID=%s)",
+ ControlList[i]->GetId().c_str() );
+ break;
}
}
-
}
//---------------------------------------------------------------------------
void SkinWindow::MouseMove( int x, int y, int button )
}
// Checking event in controls
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- ControlList[i]->MouseMove( x, y, button );
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseMove( x, y, button ) )
+ {
+ break;
+ }
}
// Checking help text
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseOver( x, y ) )
+ if( ControlList[i]->IsVisible() && ControlList[i]->MouseOver( x, y ) )
{
- if( ControlList[i]->SendNewHelpText() )
- {
- break;
- }
+ ControlList[i]->SendNewHelpText();
+ break;
}
}
}
// Checking for change in Tool Tip
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->ToolTipTest( x, y ) )
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->ToolTipTest( x, y ) )
+ {
break;
+ }
}
// If no change, delete tooltip text
}
// Checking event in controls
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseUp( x, y, button ) )
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseUp( x, y, button ) )
{
- return;
+ msg_Dbg( p_intf, "Mouse up (ID=%s)",
+ ControlList[i]->GetId().c_str() );
+ break;
}
}
}
int i;
// Checking event in controls
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseDblClick( x, y, button ) )
- return;
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseDblClick( x, y, button ) )
+ {
+ msg_Dbg( p_intf, "Double click (ID=%s)",
+ ControlList[i]->GetId().c_str() );
+ }
}
}
//---------------------------------------------------------------------------
void SkinWindow::MouseScroll( int x, int y, int direction )
{
// Checking event in controls
- for( int i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( int i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseScroll( x, y, direction ) )
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseScroll( x, y, direction ) )
{
- return;
+ break;
}
}
}
{
#define min(a,b) ((a)<(b))?(a):(b)
#define max(a,b) ((a)>(b))?(a):(b)
- w = max( w, ControlList[i]->Left + ControlList[i]->Width );
- h = max( h, ControlList[i]->Top + ControlList[i]->Height );
- MinX = min( MinX, ControlList[i]->Left );
- MinY = min( MinY, ControlList[i]->Top );
+ w = max( w, ControlList[i]->GetLeft() + ControlList[i]->GetWidth() );
+ h = max( h, ControlList[i]->GetTop() + ControlList[i]->GetHeight() );
+ MinX = min( MinX, ControlList[i]->GetLeft() );
+ MinY = min( MinY, ControlList[i]->GetTop() );
#undef max
#undef min
}