Commit 346673f0 authored by Claes Sjofors's avatar Claes Sjofors

Ge slider dynamics, property ReleaseAttr added to detect when slider is released

parent f5868982
...@@ -22,7 +22,7 @@ Build with ...@@ -22,7 +22,7 @@ Build with
Eclipse Eclipse
The application PwrXtt can be imported to eclipse by stating The application PwrXtt can be imported to eclipse by stating
$pwre_sroot/os_linux/hw_x86/bld/aapp as work directory. Import the project with $pwre_broot/os_linux/hw_x86/bld/aapp as work directory. Import the project with
File/Import/General/Existing Projects... Activate Android Tools/Fix Project Properties File/Import/General/Existing Projects... Activate Android Tools/Fix Project Properties
in the popup menu for the project. After this the application can be run and debugged. in the popup menu for the project. After this the application can be run and debugged.
Any changes in the java code should be copied back to source code in java/jpwr and Any changes in the java code should be copied back to source code in java/jpwr and
......
...@@ -472,6 +472,7 @@ public class Dyn { ...@@ -472,6 +472,7 @@ public class Dyn {
public static final int eSave_Slider_minvalue_attr = 6001; public static final int eSave_Slider_minvalue_attr = 6001;
public static final int eSave_Slider_maxvalue_attr = 6002; public static final int eSave_Slider_maxvalue_attr = 6002;
public static final int eSave_Slider_insensitive_attr = 6003; public static final int eSave_Slider_insensitive_attr = 6003;
public static final int eSave_Slider_release_attr = 6004;
public static final int eSave_AnalogColor_attribute = 6100; public static final int eSave_AnalogColor_attribute = 6100;
public static final int eSave_AnalogColor_limit = 6101; public static final int eSave_AnalogColor_limit = 6101;
public static final int eSave_AnalogColor_limit_type = 6102; public static final int eSave_AnalogColor_limit_type = 6102;
...@@ -9032,6 +9033,7 @@ public class Dyn { ...@@ -9032,6 +9033,7 @@ public class Dyn {
String minvalue_attr; String minvalue_attr;
String maxvalue_attr; String maxvalue_attr;
String insensitive_attr; String insensitive_attr;
String release_attr;
PwrtRefId subid; PwrtRefId subid;
int p; int p;
int database; int database;
...@@ -9067,6 +9069,7 @@ public class Dyn { ...@@ -9067,6 +9069,7 @@ public class Dyn {
minvalue_attr = x.minvalue_attr; minvalue_attr = x.minvalue_attr;
maxvalue_attr = x.maxvalue_attr; maxvalue_attr = x.maxvalue_attr;
insensitive_attr = x.insensitive_attr; insensitive_attr = x.insensitive_attr;
release_attr = x.release_attr;
} }
public int connect(GlowArrayElem o) { public int connect(GlowArrayElem o) {
...@@ -9376,6 +9379,21 @@ public class Dyn { ...@@ -9376,6 +9379,21 @@ public class Dyn {
return 1; return 1;
switch ( e.event) { switch ( e.event) {
case Glow.eEvent_SliderMoveEnd: {
DynParsedAttrName pname = dyn.parseAttrName(release_attr);
if ( !(pname == null || pname.name.equals(""))) {
switch ( pname.type) {
case Pwr.eType_Boolean: {
PwrtStatus sts = dyn.graph.getGdh().setObjectInfo( pname.name, 1);
break;
}
default: ;
}
}
if ( dyn.graph.getCurrentSlider() == object)
dyn.graph.setCurrentSlider(null);
break;
}
case Glow.eEvent_SliderMoveStart: { case Glow.eEvent_SliderMoveStart: {
if ( !dyn.graph.isAuthorized( dyn.access) || if ( !dyn.graph.isAuthorized( dyn.access) ||
slider_disabled) { slider_disabled) {
...@@ -9384,7 +9402,6 @@ public class Dyn { ...@@ -9384,7 +9402,6 @@ public class Dyn {
break; break;
} }
GlowSliderInfo info = ((GrowSlider)object).get_info(); GlowSliderInfo info = ((GrowSlider)object).get_info();
System.out.println("Slider start direction " + info.direction);
if ( direction == Glow.eDirection_Right || if ( direction == Glow.eDirection_Right ||
direction == Glow.eDirection_Left) direction == Glow.eDirection_Left)
dyn.graph.getCtx().setMoveRestrictions( Glow.eMoveRestriction_HorizontalSlider, dyn.graph.getCtx().setMoveRestrictions( Glow.eMoveRestriction_HorizontalSlider,
...@@ -9396,11 +9413,6 @@ public class Dyn { ...@@ -9396,11 +9413,6 @@ public class Dyn {
dyn.graph.setCurrentSlider((GrowSlider)object); dyn.graph.setCurrentSlider((GrowSlider)object);
break; break;
} }
case Glow.eEvent_SliderMoveEnd: {
if ( dyn.graph.getCurrentSlider() == object)
dyn.graph.setCurrentSlider(null);
break;
}
case Glow.eEvent_SliderMoved: { case Glow.eEvent_SliderMoved: {
float value; float value;
...@@ -9429,7 +9441,6 @@ public class Dyn { ...@@ -9429,7 +9441,6 @@ public class Dyn {
value = (float)( (g.ll_y - info.min_position) / (info.max_position - info.min_position) * value = (float)( (g.ll_y - info.min_position) / (info.max_position - info.min_position) *
(max_value - min_value) + min_value); (max_value - min_value) + min_value);
} }
System.out.println("Slider value " + value + " minpos " + info.min_position + " maxpos " + info.max_position);
if ( value > max_value) if ( value > max_value)
value = max_value; value = max_value;
if ( value < min_value) if ( value < min_value)
...@@ -9495,6 +9506,10 @@ public class Dyn { ...@@ -9495,6 +9506,10 @@ public class Dyn {
if ( token.hasMoreTokens()) if ( token.hasMoreTokens())
insensitive_attr = token.nextToken(); insensitive_attr = token.nextToken();
break; break;
case Dyn.eSave_Slider_release_attr:
if ( token.hasMoreTokens())
release_attr = token.nextToken();
break;
case Dyn.eSave_End: case Dyn.eSave_End:
end_found = true; end_found = true;
break; break;
......
...@@ -152,7 +152,6 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -152,7 +152,6 @@ public class Graph implements GraphIfc, GrowApplIfc {
int idx; int idx;
if ( (idx = str.indexOf('#')) != -1) if ( (idx = str.indexOf('#')) != -1)
str = str.substring(0, idx); str = str.substring(0, idx);
System.out.println("type: " + str);
if ( str.equalsIgnoreCase("boolean")) if ( str.equalsIgnoreCase("boolean"))
return Pwr.eType_Boolean; return Pwr.eType_Boolean;
if ( str.equalsIgnoreCase("float32")) if ( str.equalsIgnoreCase("float32"))
...@@ -292,7 +291,6 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -292,7 +291,6 @@ public class Graph implements GraphIfc, GrowApplIfc {
if ( appl != null) { if ( appl != null) {
String oname = cmn.getOwner(); String oname = cmn.getOwner();
str = str.substring(0, idx) + oname + str.substring(idx+7); str = str.substring(0, idx) + oname + str.substring(idx+7);
System.out.println("Parse name $object " + oname + " str " + str);
} }
} }
...@@ -344,7 +342,8 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -344,7 +342,8 @@ public class Graph implements GraphIfc, GrowApplIfc {
pname.database = Graph.eDatabase_Gdh; pname.database = Graph.eDatabase_Gdh;
pname.name = str; pname.name = str;
System.out.println( "ParsedName: " + name + " " + pname.name + " type: " + pname.type + " elements: " + pname.elements + " bitm: " + pname.bitmask); if ( Dyn.debug)
System.out.println( "ParsedName: " + name + " " + pname.name + " type: " + pname.type + " elements: " + pname.elements + " bitm: " + pname.bitmask);
return pname; return pname;
} }
......
...@@ -460,7 +460,6 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -460,7 +460,6 @@ public class GrowCtx implements GrowCtxIfc {
switch ( e.event) { switch ( e.event) {
case Glow.eEvent_MB1Down: case Glow.eEvent_MB1Down:
if ( sts == 1 && cmn.callback_object != null && cmn.callback_object.type() == Glow.eObjectType_GrowSlider) { if ( sts == 1 && cmn.callback_object != null && cmn.callback_object.type() == Glow.eObjectType_GrowSlider) {
System.out.println("Slider start");
sliderActive = true; sliderActive = true;
sliderObject = (GrowSlider)cmn.callback_object; sliderObject = (GrowSlider)cmn.callback_object;
...@@ -487,7 +486,6 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -487,7 +486,6 @@ public class GrowCtx implements GrowCtxIfc {
case Glow.eEvent_MB1Up: case Glow.eEvent_MB1Up:
if ( sliderActive) { if ( sliderActive) {
if ( cmn.restriction_object != null) { if ( cmn.restriction_object != null) {
System.out.println("Slider end");
GlowEvent se = new GlowEvent(); GlowEvent se = new GlowEvent();
se.event = Glow.eEvent_SliderMoveEnd; se.event = Glow.eEvent_SliderMoveEnd;
...@@ -519,7 +517,6 @@ public class GrowCtx implements GrowCtxIfc { ...@@ -519,7 +517,6 @@ public class GrowCtx implements GrowCtxIfc {
else { else {
move_y = cmn.restriction_max_limit - node_move_last_y - move_y = cmn.restriction_max_limit - node_move_last_y -
slider_cursor_offset; slider_cursor_offset;
System.out.println("Slider max limit: " + move_y + " limit " + cmn.restriction_max_limit);
} }
} }
else if ( cursor_y + slider_cursor_offset < cmn.restriction_min_limit) { else if ( cursor_y + slider_cursor_offset < cmn.restriction_min_limit) {
......
...@@ -13916,6 +13916,11 @@ void GeSlider::get_attributes( attr_sItem *attrinfo, int *item_count) ...@@ -13916,6 +13916,11 @@ void GeSlider::get_attributes( attr_sItem *attrinfo, int *item_count)
attrinfo[i].type = glow_eType_String; attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( insensitive_attr); attrinfo[i++].size = sizeof( insensitive_attr);
strcpy( attrinfo[i].name, "Slider.ReleaseAttr");
attrinfo[i].value = release_attr;
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( release_attr);
dyn->display_access = true; dyn->display_access = true;
*item_count = i; *item_count = i;
} }
...@@ -13939,6 +13944,7 @@ void GeSlider::replace_attribute( char *from, char *to, int *cnt, int strict) ...@@ -13939,6 +13944,7 @@ void GeSlider::replace_attribute( char *from, char *to, int *cnt, int strict)
GeDyn::replace_attribute( minvalue_attr, sizeof(minvalue_attr), from, to, cnt, strict); GeDyn::replace_attribute( minvalue_attr, sizeof(minvalue_attr), from, to, cnt, strict);
GeDyn::replace_attribute( maxvalue_attr, sizeof(maxvalue_attr), from, to, cnt, strict); GeDyn::replace_attribute( maxvalue_attr, sizeof(maxvalue_attr), from, to, cnt, strict);
GeDyn::replace_attribute( insensitive_attr, sizeof(insensitive_attr), from, to, cnt, strict); GeDyn::replace_attribute( insensitive_attr, sizeof(insensitive_attr), from, to, cnt, strict);
GeDyn::replace_attribute( release_attr, sizeof(release_attr), from, to, cnt, strict);
} }
void GeSlider::save( ofstream& fp) void GeSlider::save( ofstream& fp)
...@@ -13948,6 +13954,7 @@ void GeSlider::save( ofstream& fp) ...@@ -13948,6 +13954,7 @@ void GeSlider::save( ofstream& fp)
fp << int(ge_eSave_Slider_minvalue_attr) << FSPACE << minvalue_attr << endl; fp << int(ge_eSave_Slider_minvalue_attr) << FSPACE << minvalue_attr << endl;
fp << int(ge_eSave_Slider_maxvalue_attr) << FSPACE << maxvalue_attr << endl; fp << int(ge_eSave_Slider_maxvalue_attr) << FSPACE << maxvalue_attr << endl;
fp << int(ge_eSave_Slider_insensitive_attr) << FSPACE << insensitive_attr << endl; fp << int(ge_eSave_Slider_insensitive_attr) << FSPACE << insensitive_attr << endl;
fp << int(ge_eSave_Slider_release_attr) << FSPACE << release_attr << endl;
fp << int(ge_eSave_End) << endl; fp << int(ge_eSave_End) << endl;
} }
...@@ -13985,6 +13992,10 @@ void GeSlider::open( ifstream& fp) ...@@ -13985,6 +13992,10 @@ void GeSlider::open( ifstream& fp)
fp.get(); fp.get();
fp.getline( insensitive_attr, sizeof(insensitive_attr)); fp.getline( insensitive_attr, sizeof(insensitive_attr));
break; break;
case ge_eSave_Slider_release_attr:
fp.get();
fp.getline( release_attr, sizeof(release_attr));
break;
case ge_eSave_End: end_found = 1; break; case ge_eSave_End: end_found = 1; break;
default: default:
cout << "GeSlider:open syntax error" << endl; cout << "GeSlider:open syntax error" << endl;
...@@ -14273,6 +14284,25 @@ int GeSlider::action( grow_tObject object, glow_tEvent event) ...@@ -14273,6 +14284,25 @@ int GeSlider::action( grow_tObject object, glow_tEvent event)
case glow_eEvent_MB1Down: case glow_eEvent_MB1Down:
grow_SetClickSensitivity( dyn->graph->grow->ctx, glow_mSensitivity_MB1Press); grow_SetClickSensitivity( dyn->graph->grow->ctx, glow_mSensitivity_MB1Press);
break; break;
case glow_eEvent_SliderMoveEnd: {
pwr_tAName parsed_name;
int inverted;
int attr_type, attr_size;
pwr_tBoolean val = 1;
pwr_tStatus sts;
if ( strcmp( release_attr, "") != 0) {
dyn->parse_attr_name( release_attr, parsed_name, &inverted, &attr_type, &attr_size);
switch ( attr_type) {
case pwr_eType_Boolean: {
sts = gdh_SetObjectInfo( parsed_name, &val, sizeof(val));
break;
}
default: ;
}
}
break;
}
case glow_eEvent_SliderMoveStart: { case glow_eEvent_SliderMoveStart: {
double max_value, min_value, max_pos, min_pos; double max_value, min_value, max_pos, min_pos;
glow_eDirection direction; glow_eDirection direction;
......
...@@ -566,6 +566,7 @@ ...@@ -566,6 +566,7 @@
ge_eSave_Slider_minvalue_attr = 6001, ge_eSave_Slider_minvalue_attr = 6001,
ge_eSave_Slider_maxvalue_attr = 6002, ge_eSave_Slider_maxvalue_attr = 6002,
ge_eSave_Slider_insensitive_attr = 6003, ge_eSave_Slider_insensitive_attr = 6003,
ge_eSave_Slider_release_attr = 6004,
ge_eSave_AnalogColor_attribute = 6100, ge_eSave_AnalogColor_attribute = 6100,
ge_eSave_AnalogColor_limit = 6101, ge_eSave_AnalogColor_limit = 6101,
ge_eSave_AnalogColor_limit_type = 6102, ge_eSave_AnalogColor_limit_type = 6102,
...@@ -2214,6 +2215,7 @@ class GeSlider : public GeDynElem { ...@@ -2214,6 +2215,7 @@ class GeSlider : public GeDynElem {
pwr_tAName minvalue_attr; pwr_tAName minvalue_attr;
pwr_tAName maxvalue_attr; pwr_tAName maxvalue_attr;
pwr_tAName insensitive_attr; pwr_tAName insensitive_attr;
pwr_tAName release_attr;
int slider_disabled; int slider_disabled;
pwr_tFloat32 *p; pwr_tFloat32 *p;
...@@ -2240,12 +2242,13 @@ class GeSlider : public GeDynElem { ...@@ -2240,12 +2242,13 @@ class GeSlider : public GeDynElem {
GeDynElem(e_dyn, ge_mDynType1_No, ge_mDynType2_No, ge_mActionType1_Slider, ge_mActionType2_No, ge_eDynPrio_Slider), GeDynElem(e_dyn, ge_mDynType1_No, ge_mDynType2_No, ge_mActionType1_Slider, ge_mActionType2_No, ge_eDynPrio_Slider),
min_value_p(0), max_value_p(0), old_min_value(0), old_max_value(0), insensitive_p(0) min_value_p(0), max_value_p(0), old_min_value(0), old_max_value(0), insensitive_p(0)
{ strcpy( attribute, ""); strcpy( minvalue_attr, ""); strcpy( maxvalue_attr, ""); { strcpy( attribute, ""); strcpy( minvalue_attr, ""); strcpy( maxvalue_attr, "");
strcpy( insensitive_attr, "");} strcpy( insensitive_attr, ""); strcpy( release_attr, "");}
GeSlider( const GeSlider& x) : GeSlider( const GeSlider& x) :
GeDynElem(x.dyn,x.dyn_type1,x.dyn_type2,x.action_type1,x.action_type2,x.prio), GeDynElem(x.dyn,x.dyn_type1,x.dyn_type2,x.action_type1,x.action_type2,x.prio),
min_value_p(0), max_value_p(0), old_min_value(0), old_max_value(0), insensitive_p(0) min_value_p(0), max_value_p(0), old_min_value(0), old_max_value(0), insensitive_p(0)
{ strcpy( attribute, x.attribute); strcpy( minvalue_attr, x.minvalue_attr); { strcpy( attribute, x.attribute); strcpy( minvalue_attr, x.minvalue_attr);
strcpy( maxvalue_attr, x.maxvalue_attr); strcpy( insensitive_attr, x.insensitive_attr);} strcpy( maxvalue_attr, x.maxvalue_attr); strcpy( insensitive_attr, x.insensitive_attr);
strcpy( release_attr, x.release_attr);}
void get_attributes( attr_sItem *attrinfo, int *item_count); void get_attributes( attr_sItem *attrinfo, int *item_count);
void save( ofstream& fp); void save( ofstream& fp);
void open( ifstream& fp); void open( ifstream& fp);
......
...@@ -3295,6 +3295,8 @@ void GraphGrow::grow_trace_setup() ...@@ -3295,6 +3295,8 @@ void GraphGrow::grow_trace_setup()
graph_grow_cb); graph_grow_cb);
grow_EnableEvent( ctx, glow_eEvent_SliderMoveStart, glow_eEventType_CallBack, grow_EnableEvent( ctx, glow_eEvent_SliderMoveStart, glow_eEventType_CallBack,
graph_grow_cb); graph_grow_cb);
grow_EnableEvent( ctx, glow_eEvent_SliderMoveEnd, glow_eEventType_CallBack,
graph_grow_cb);
grow_EnableEvent( ctx, glow_eEvent_AnnotationInput, glow_eEventType_CallBack, grow_EnableEvent( ctx, glow_eEvent_AnnotationInput, glow_eEventType_CallBack,
graph_grow_cb); graph_grow_cb);
grow_EnableEvent( ctx, glow_eEvent_InputFocusLost, glow_eEventType_CallBack, grow_EnableEvent( ctx, glow_eEvent_InputFocusLost, glow_eEventType_CallBack,
...@@ -3843,22 +3845,25 @@ static int graph_trace_grow_cb( GlowCtx *ctx, glow_tEvent event) ...@@ -3843,22 +3845,25 @@ static int graph_trace_grow_cb( GlowCtx *ctx, glow_tEvent event)
} }
break; break;
} }
case glow_eEvent_SliderMoveStart: case glow_eEvent_SliderMoveEnd:
{ {
if ( event->object.object_type == glow_eObjectType_NoObject) GeDyn *dyn;
{
grow_SetMoveRestrictions( graph->grow->ctx, grow_GetUserData( event->object.object, (void **)&dyn);
glow_eMoveRestriction_Disable, 0, 0, NULL); dyn->action( event->object.object, event);
graph->current_slider = NULL;
}
else
{
GeDyn *dyn;
grow_GetUserData( event->object.object, (void **)&dyn); grow_SetMoveRestrictions( graph->grow->ctx,
dyn->action( event->object.object, event); glow_eMoveRestriction_Disable, 0, 0, NULL);
graph->current_slider = NULL;
break;
}
case glow_eEvent_SliderMoveStart:
{
GeDyn *dyn;
grow_GetUserData( event->object.object, (void **)&dyn);
dyn->action( event->object.object, event);
}
break; break;
} }
case glow_eEvent_SliderMoved: case glow_eEvent_SliderMoved:
......
...@@ -981,6 +981,7 @@ typedef enum { ...@@ -981,6 +981,7 @@ typedef enum {
glow_eEvent_CreateGrowObject, //!< Create grow object event glow_eEvent_CreateGrowObject, //!< Create grow object event
glow_eEvent_GrowDynamics, //!< Execute dynamics event glow_eEvent_GrowDynamics, //!< Execute dynamics event
glow_eEvent_SliderMoveStart, //!< Start of slider motion sequence event glow_eEvent_SliderMoveStart, //!< Start of slider motion sequence event
glow_eEvent_SliderMoveEnd, //!< End of slider motion sequence event
glow_eEvent_SliderMoved, //!< Slider move event glow_eEvent_SliderMoved, //!< Slider move event
glow_eEvent_HotRequest, //!< Hot request on object event glow_eEvent_HotRequest, //!< Hot request on object event
glow_eEvent_MB1Down, //!< MB1 down event glow_eEvent_MB1Down, //!< MB1 down event
......
...@@ -1551,15 +1551,15 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h) ...@@ -1551,15 +1551,15 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
event_callback[glow_eEvent_SliderMoved]( this, &e); event_callback[glow_eEvent_SliderMoved]( this, &e);
// Send slider movement end event // Send slider movement end event
e.event = glow_eEvent_SliderMoveStart; e.event = glow_eEvent_SliderMoveEnd;
e.any.type = glow_eEventType_Object; e.any.type = glow_eEventType_Object;
e.any.x_pixel = x; e.any.x_pixel = x;
e.any.y_pixel = y; e.any.y_pixel = y;
e.any.x = double (x + mw.offset_x) / mw.zoom_factor_x; e.any.x = double (x + mw.offset_x) / mw.zoom_factor_x;
e.any.y = double (y + mw.offset_y) / mw.zoom_factor_y; e.any.y = double (y + mw.offset_y) / mw.zoom_factor_y;
e.object.object = NULL; e.object.object = restriction_object;
e.object.object_type = glow_eObjectType_NoObject; e.object.object_type = restriction_object->type();
event_callback[glow_eEvent_SliderMoveStart]( this, &e); event_callback[glow_eEvent_SliderMoveEnd]( this, &e);
} }
node_move_last_x = x; node_move_last_x = x;
node_move_last_y = y; node_move_last_y = y;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment