Skip to content

Instantly share code, notes, and snippets.

@qoh
Created June 23, 2012 04:48
Show Gist options
  • Save qoh/2976909 to your computer and use it in GitHub Desktop.
Save qoh/2976909 to your computer and use it in GitHub Desktop.
function HazeLauncher::onMouseMove( %this, %pos )
{
if ( getWord( %pos, 0 ) < getWord( %this.extent, 0 ) && getWord( %pos, 1 ) >= getWord( %this.position, 1 ) )
{
%this.prevMMInside = true;
%this.updateStatusAll();
}
else if ( %this.prevMMInside )
{
%this.prevMMInside = false;
%this.updateStatusAll();
}
}
function HazeLauncher::onMouseDragged( %this, %pos )
{
if ( !isObject( %this.clickItem ) )
{
return;
}
if ( !isObject( %this.dragBitmap ) )
{
%this.clickItem.dragHidden = true;
%this.clickItem.setVisible( false );
%posx = getWord( %pos, 0 ) - %this.clickOffset;
if ( %posx < 65 )
{
%posx = 65;
}
if ( %posx > ( getFieldCount( $HZ::PinnedApps ) ) * 65 - 11 )
{
%posx = ( getFieldCount( $HZ::PinnedApps ) ) * 65 - 11;
}
HazeLauncher.add( %this.dragBitmap = new guiBitmapCtrl()
{
position = %posx SPC 11;
extent = "32 32";
minExtent = "0 0";
visible = true;
bitmap = %this.clickItem.bitmap.bitmap;
} );
}
else
{
%posx = getWord( %pos, 0 ) - %this.clickOffset;
if ( %posx < 65 )
{
%posx = 65;
}
if ( %posx > ( getFieldCount( $HZ::PinnedApps ) + 1 ) * 65 - 11 )
{
%posx = ( getFieldCount( $HZ::PinnedApps ) + 1 ) * 65 - 11;
}
%this.dragBitmap.position = %posx SPC 11;
}
}
function HazeLauncher::onMouseDown( %this, %pos )
{
if ( %this.mouseDown )
{
return;
}
if ( getWord( %pos, 0 ) > 54 * ( getFieldCount( $HZ::PinnedApps ) + 2 ) )
{
return;
}
if ( getWord( %pos, 1 ) < getWord( %this.position, 1 ) )
{
return;
}
%this.mouseDown = true;
%this.clickIndex = mFloor( getWord( %pos, 0 ) / 54 ) - 1;
echo( %this.clickIndex );
%this.clickApp = ( %this.clickIndex >= 0 );
if ( %this.clickApp )
{
%this.clickItem = %this.item[ %this.clickIndex ];
%this.clickOffset = getWord( %pos, 0 ) - getWord( %this.clickItem.position, 0 ) - 11;
}
else
{
%this.clickItem = "";
%this.clickOffset = "";
}
%this.updateStatusAll();
}
function HazeLauncher::onMouseUp( %this, %pos )
{
if ( !%this.mouseDown )
{
return;
}
%this.mouseDown = false;
if ( getWord( %pos, 0 ) < getWord( %this.extent, 0 ) && getWord( %pos, 1 ) >= getWord( %this.position, 1 ) )
{
%this.updateStatusAll();
}
if ( isObject( %this.dragBitmap ) )
{
%count = getFieldCount( $HZ::PinnedApps );
for ( %i = 0 ; %i < %count ; %i++ )
{
%item = %this.item[ %i ];
if ( strLen( %item.originalPosition ) )
{
%item.position = %item.originalPosition;
%item.originalPosition = "";
}
if ( %item.dragHidden )
{
%item.setVisible( true );
%item.dragHidden = "";
}
}
%this.dragBitmap.delete();
}
else
{
if ( isObject( %this.clickItem ) )
{
messageBoxOK( "", "Should open app \"" @ %this.clickItem.handle @ "\"." );
}
else
{
messageBoxOK( "", "Should open app list." );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment