~ubuntu-branches/ubuntu/oneiric/cairo-dock-plug-ins/oneiric-updates

« back to all changes in this revision

Viewing changes to dock-rendering/src/rendering-diapo-simple.c

  • Committer: Kees Cook
  • Date: 2011-08-11 23:17:39 UTC
  • mfrom: (20.1.1 cairo-dock-plug-ins)
  • Revision ID: kees@outflux.net-20110811231739-cteedan51tmdg77v
Tags: 2.4.0~0beta2-0ubuntu1
releasing version 2.4.0~0beta2-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
325
325
        }
326
326
        else
327
327
        {
328
 
                iDockWidth = X_BORDER_SPACE * 2 + 1;
329
 
                iDockHeight = my_diapo_simple_lineWidth + my_diapo_simple_arrowHeight + ARROW_TIP + 1;
 
328
                iDockWidth = X_BORDER_SPACE * 2 + my_diapo_simple_arrowWidth + 10;
 
329
                iDockHeight = my_diapo_simple_lineWidth + my_diapo_simple_arrowHeight + ARROW_TIP + 10;
330
330
        }
331
331
        
332
332
        CDSlideData *pData = pDock->pRendererData;
376
376
        // On affecte ca aussi au cas ou.
377
377
        pDock->fFlatDockWidth = pDock->iMaxDockWidth;
378
378
        pDock->fMagnitudeMax = my_diapo_simple_fScaleMax / (1+myIconsParam.fAmplitude);
 
379
        
 
380
        pDock->iActiveWidth = pDock->iMaxDockWidth;
 
381
        pDock->iActiveHeight = pDock->iMaxDockHeight;
379
382
}
380
383
 
381
384
 
911
914
                pDock->iMousePositionType = CAIRO_DOCK_MOUSE_INSIDE;
912
915
        }
913
916
}
914
 
static void _cd_rendering_check_can_drop_linear (CairoDock *pDock)
915
 
{
916
 
        pDock->bCanDrop = pDock->bIsDragging;  /// calculer bCanDrop ...
 
917
#define make_icon_avoid_mouse(icon, sens) do { \
 
918
        cairo_dock_mark_icon_as_avoiding_mouse (icon);\
 
919
        icon->fAlpha = 0.75;\
 
920
        if (myIconsParam.fAmplitude != 0)\
 
921
                icon->fDrawX += icon->fWidth / 2 * (icon->fScale - 1) / myIconsParam.fAmplitude * sens; } while (0)
 
922
///TODO: make it work...
 
923
static inline gboolean _check_can_drop (CairoDock *pDock, CairoDockIconGroup iGroup, double fMargin)
 
924
{
 
925
        gboolean bUndefined = TRUE;
 
926
        gboolean bCanDrop = FALSE;
 
927
        Icon *icon;
 
928
        GList *ic;
 
929
        for (ic = pDock->icons; ic != NULL; ic = ic->next)
 
930
        {
 
931
                icon = ic->data;
 
932
                if (icon->bPointed)
 
933
                {
 
934
                        if (pDock->container.iMouseX < icon->fDrawX + icon->fWidth * icon->fScale * fMargin)  // on est a gauche.  // fDrawXAtRest
 
935
                        {
 
936
                                GList *prev_ic = ic->prev;
 
937
                                Icon *prev_icon = (prev_ic ? prev_ic->data : NULL);
 
938
                                if (cairo_dock_get_icon_order (icon) == cairo_dock_get_group_order (iGroup)
 
939
                                || (prev_icon && cairo_dock_get_icon_order (prev_icon) == cairo_dock_get_group_order (iGroup)) )
 
940
                                {
 
941
                                        make_icon_avoid_mouse (icon, 1);
 
942
                                        if (prev_icon)
 
943
                                                make_icon_avoid_mouse (prev_icon, -1);
 
944
                                        //g_print ("%s> <%s\n", prev_icon->cName, icon->cName);
 
945
                                        bCanDrop = TRUE;
 
946
                                        bUndefined = FALSE;
 
947
                                }
 
948
                        }
 
949
                        else if (pDock->container.iMouseX > icon->fDrawX + icon->fWidth * icon->fScale * (1 - fMargin))  // on est a droite.  // fDrawXAtRest
 
950
                        {
 
951
                                GList *next_ic = ic->next;
 
952
                                Icon *next_icon = (next_ic ? next_ic->data : NULL);
 
953
                                if (cairo_dock_get_icon_order (icon) == cairo_dock_get_group_order (iGroup)
 
954
                                || (next_icon && cairo_dock_get_icon_order (next_icon) == cairo_dock_get_group_order (iGroup)) )
 
955
                                {
 
956
                                        make_icon_avoid_mouse (icon, -1);
 
957
                                        if (next_icon)
 
958
                                                make_icon_avoid_mouse (next_icon, 1);
 
959
                                        bCanDrop = TRUE;
 
960
                                        bUndefined = FALSE;
 
961
                                }
 
962
                                ic = ic->next;  // on la saute pour ne pas la de-marquer.
 
963
                                if (ic == NULL)
 
964
                                        break;
 
965
                        }
 
966
                        else  // on the icon
 
967
                        {
 
968
                                bCanDrop = FALSE;
 
969
                                bUndefined = FALSE;
 
970
                        }
 
971
                }
 
972
                else
 
973
                        cairo_dock_stop_marking_icon_as_avoiding_mouse (icon);
 
974
        }
 
975
        
 
976
        if (bUndefined)  // no pointed icon, so we are either on the side, on between icons.
 
977
        {
 
978
                bCanDrop = (pDock->container.iMouseX > X_BORDER_SPACE && pDock->container.iMouseX < pDock->container.iWidth - X_BORDER_SPACE);  // no drop on the side.
 
979
        }
 
980
        return bCanDrop;
 
981
}
 
982
static void _cd_rendering_check_can_drop (CairoDock *pDock)
 
983
{
 
984
        if (! pDock->bIsDragging)  // not dragging, so no drop possible.
 
985
        {
 
986
                pDock->bCanDrop = FALSE;
 
987
        }
 
988
        else if (pDock->icons == NULL)  // dragging but no icons, so drop always possible.
 
989
        {
 
990
                pDock->bCanDrop = TRUE;
 
991
        }
 
992
        else  // dragging and some icons.
 
993
        {
 
994
                pDock->bCanDrop = _check_can_drop (pDock, pDock->iAvoidingMouseIconType, pDock->fAvoidingMouseMargin);
 
995
        }
917
996
}
918
997
Icon *cd_rendering_calculate_icons_diapo_simple (CairoDock *pDock)
919
998
{
925
1004
        // On recupere la configuration de la grille
926
1005
        gint nRowsX = pData->nRowsX;
927
1006
        gint nRowsY = pData->nRowsY;
 
1007
        if (nRowsX == 0 || nRowsY == 0)  // maybe a dock with no displayed icons (like 1 separator); anyway the grid is not valid, so discard.
 
1008
                return NULL;
928
1009
        
929
1010
        // On calcule les parametres des icones
930
1011
        Icon *pPointedIcon = _cd_rendering_calculate_icons_for_diapo_simple (pDock, nRowsX, nRowsY, pDock->container.iMouseX, pDock->container.iMouseY);
931
1012
        
932
1013
        _cd_rendering_check_if_mouse_inside_diapo_simple (pDock);
933
1014
        
934
 
        _cd_rendering_check_can_drop_linear (pDock);
 
1015
        _cd_rendering_check_can_drop (pDock);
935
1016
        
936
1017
        return pPointedIcon;
937
1018
}
1406
1487
        {
1407
1488
                pSubDock->fAlign = 0.5;
1408
1489
                pSubDock->iGapX = iX + pDock->container.iWindowPositionX - (pDock->container.bIsHorizontal ? pDock->iScreenOffsetX : pDock->iScreenOffsetY) - g_desktopGeometry.iScreenWidth[pDock->container.bIsHorizontal] / 2;  // ici les sous-dock ont un alignement egal a 0.5
1409
 
                pSubDock->iGapY = pDock->iGapY + pDock->iMaxDockHeight;
 
1490
                pSubDock->iGapY = pDock->iGapY + pDock->iActiveHeight;
1410
1491
        }
1411
1492
        else
1412
1493
        {
1413
1494
                pSubDock->fAlign = (pDock->container.bDirectionUp ? 1 : 0);
1414
 
                pSubDock->iGapX = (pDock->iGapY + pDock->iMaxDockHeight) * (pDock->container.bDirectionUp ? -1 : 1);
 
1495
                pSubDock->iGapX = (pDock->iGapY + pDock->iActiveHeight) * (pDock->container.bDirectionUp ? -1 : 1);
1415
1496
                if (pDock->container.bDirectionUp)
1416
1497
                        pSubDock->iGapY = g_desktopGeometry.iScreenWidth[pDock->container.bIsHorizontal] - (iX + pDock->container.iWindowPositionX - (pDock->container.bIsHorizontal ? pDock->iScreenOffsetX : pDock->iScreenOffsetY)) - pSubDock->iMaxDockHeight / 2;  // les sous-dock ont un alignement egal a 1.
1417
1498
                else