add_visb_object_from_definition(visb_objects,SVG_ID, AttrList, Desc, DefName, DefPos) :- !,
(select(svg_attribute(svg_class,SVG_Class),AttrList,AttrList2)
-> true % maybe we should call svg_class svg_shape
; add_warning(visb_visualiser,'SVG objects have no svg_class field:',DefName,DefPos),
fail
),
assert_visb_svg_object(SVG_ID,SVG_Class,AttrList2,Desc,DefPos).
add_visb_object_from_definition(visb_hovers,SVG_ID, AttrList, _Desc, _DefName, DefPos) :-
(select(svg_attribute(trigger_id,TriggerID),AttrList,AttrList2) -> true
; select(svg_attribute('trigger-id',TriggerID),AttrList,AttrList2) -> true
; TriggerID = SVG_ID, AttrList2=AttrList),
member(svg_attribute(Attr,EnterVal),AttrList2),
(visb_svg_object(SVG_ID,_,StaticAttrList,_,ExitPos)
-> (member(svg_attribute(Attr,ExitVal),StaticAttrList) -> true
; Attr = 'svg_class'
-> add_warning(visb_visualiser,
'svg_class cannot be set in hover for: ',SVG_ID,ExitPos),
ExitVal=EnterVal
; add_warning(visb_visualiser,
'No static (exit) value can be retrieved for hover for attribute: ',Attr,ExitPos),
ExitVal=EnterVal
)
; add_warning(visb_visualiser,'No VISB_SVG_OBJECT, cannot retrieve hover exit value: ',SVG_ID:Attr,DefPos),
ExitVal=EnterVal
),
assert_visb_hover(TriggerID,SVG_ID,Attr,EnterVal,ExitVal,DefPos).
add_visb_object_from_definition(visb_events,SVG_ID, AttrList, _Desc, DefName, DefPos) :- !,
( select(svg_attribute(event,Event),AttrList,AttrList1) -> true
; select(svg_attribute(events,Events),AttrList,AttrList1) -> % we have events attributes with multiple events
flex_member(EvVal,Events,DefName,DefPos),
extract_attr_value(event,EvVal,Event,DefPos)
; AttrList = [_|_], % at least one other attribute than id; otherwise it may stem from separating VISB_SVG_OBJECTS
add_warning(visb_visualiser,'Missing event attribute in VisB definition: ',DefName,DefPos),
fail
),
(select(svg_attribute(predicate,Pred),AttrList1,_AttrList2) -> Preds=[Pred]
; member(P,[preds,predicates]),
select(svg_attribute(P,Pred),AttrList1,_AttrList2)
-> Preds=[Pred], add_warning(visb_visualiser,'Use predicate as attribute for VisB events instead of: ',P,DefPos)
; Preds=[] %, AttrList2=AttrList1
),
EnableItems=[],
% TODO extract from AttrList2: visb_enable_item(SvgID,Attr,EnabledValExpr,DisabledValExpr,PosAttr)
(error_manager:extract_file_number_and_name(DefPos,_,File) -> true ; File='?'),
add_visb_event(SVG_ID,Event,Preds,[],EnableItems,File,DefPos,[]).