Ignore:
Timestamp:
Dec 12, 2013, 3:58:02 PM (11 years ago)
Author:
sommeria
Message:

mouse indication improved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_motion.m

    r693 r699  
    109109    test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal');
    110110    test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject);
    111     if ~test_edit_object  && ~test_ruler && ~CheckZoom
    112         pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
     111    if ~test_edit_object  && ~test_ruler
     112        if CheckZoom
     113           pointershape='zoom';
     114        elseif CheckZoomFig
     115            pointershape='zoomfig';
     116        elseif test_draw
     117            pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
     118        else
     119        pointershape='fullcross';%set pointer with cross shape (default when mouse is over an axis)
     120        end
    113121    end
    114122    FigData=get(hCurrentFig,'UserData');
     
    445453
    446454%% update the mouse pointer
     455if strcmp(pointershape,'zoom')||strcmp(pointershape,'zoomfig')
     456    CData=set_pointershape(pointershape);
     457    set(hCurrentFig,'Pointer','custom','PointerShapeCData',CData,'PointerShapeHotSpot',[9 9])
     458else
    447459set(hCurrentFig,'Pointer',pointershape);
     460end
     461
     462function CData=set_pointershape(pointershape)
     463        CData=ones(16,16);
     464        [ind_x,ind_y]=meshgrid([1:16],[1:16]);
     465        if strcmp(pointershape,'zoom')
     466        radius=(ind_x-9).*(ind_x-9)+(ind_y-8.5).*(ind_y-9);
     467        CData(radius<25 & radius>16)=2; %make white circle
     468        CData(radius<16 | radius>40)=NaN; %make the centre transparent
     469        CData(16,16)=1; CData(15,16)=2;
     470        CData(15,15)=1; CData(14,15)=2;
     471        CData(14,14)=1; CData(13,14)=2;
     472        CData(13,13)=1; CData(12,13)=2;
     473        elseif strcmp(pointershape,'zoomfig')
     474            CData(:,1:3)=2;
     475            CData(:,14:16)=2;
     476                        CData(1:3,:)=2;
     477            CData(14:16,:)=2;
     478            CData(CData==1)=NaN;
     479        end
Note: See TracChangeset for help on using the changeset viewer.