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
Eclipse
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
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
......
......@@ -472,6 +472,7 @@ public class Dyn {
public static final int eSave_Slider_minvalue_attr = 6001;
public static final int eSave_Slider_maxvalue_attr = 6002;
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_limit = 6101;
public static final int eSave_AnalogColor_limit_type = 6102;
......@@ -9032,6 +9033,7 @@ public class Dyn {
String minvalue_attr;
String maxvalue_attr;
String insensitive_attr;
String release_attr;
PwrtRefId subid;
int p;
int database;
......@@ -9067,6 +9069,7 @@ public class Dyn {
minvalue_attr = x.minvalue_attr;
maxvalue_attr = x.maxvalue_attr;
insensitive_attr = x.insensitive_attr;
release_attr = x.release_attr;
}
public int connect(GlowArrayElem o) {
......@@ -9376,6 +9379,21 @@ public class Dyn {
return 1;
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: {
if ( !dyn.graph.isAuthorized( dyn.access) ||
slider_disabled) {
......@@ -9384,7 +9402,6 @@ public class Dyn {
break;
}
GlowSliderInfo info = ((GrowSlider)object).get_info();
System.out.println("Slider start direction " + info.direction);
if ( direction == Glow.eDirection_Right ||
direction == Glow.eDirection_Left)
dyn.graph.getCtx().setMoveRestrictions( Glow.eMoveRestriction_HorizontalSlider,
......@@ -9396,11 +9413,6 @@ public class Dyn {
dyn.graph.setCurrentSlider((GrowSlider)object);
break;
}
case Glow.eEvent_SliderMoveEnd: {
if ( dyn.graph.getCurrentSlider() == object)
dyn.graph.setCurrentSlider(null);
break;
}
case Glow.eEvent_SliderMoved: {
float value;
......@@ -9429,7 +9441,6 @@ public class Dyn {
value = (float)( (g.ll_y - info.min_position) / (info.max_position - info.min_position) *
(max_value - min_value) + min_value);
}
System.out.println("Slider value " + value + " minpos " + info.min_position + " maxpos " + info.max_position);
if ( value > max_value)
value = max_value;
if ( value < min_value)
......@@ -9495,6 +9506,10 @@ public class Dyn {
if ( token.hasMoreTokens())
insensitive_attr = token.nextToken();
break;
case Dyn.eSave_Slider_release_attr:
if ( token.hasMoreTokens())
release_attr = token.nextToken();
break;
case Dyn.eSave_End:
end_found = true;
break;
......
......@@ -152,7 +152,6 @@ public class Graph implements GraphIfc, GrowApplIfc {
int idx;
if ( (idx = str.indexOf('#')) != -1)
str = str.substring(0, idx);
System.out.println("type: " + str);
if ( str.equalsIgnoreCase("boolean"))
return Pwr.eType_Boolean;
if ( str.equalsIgnoreCase("float32"))
......@@ -292,7 +291,6 @@ public class Graph implements GraphIfc, GrowApplIfc {
if ( appl != null) {
String oname = cmn.getOwner();
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 {
pname.database = Graph.eDatabase_Gdh;
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;
}
......
......@@ -460,7 +460,6 @@ public class GrowCtx implements GrowCtxIfc {
switch ( e.event) {
case Glow.eEvent_MB1Down:
if ( sts == 1 && cmn.callback_object != null && cmn.callback_object.type() == Glow.eObjectType_GrowSlider) {
System.out.println("Slider start");
sliderActive = true;
sliderObject = (GrowSlider)cmn.callback_object;
......@@ -487,7 +486,6 @@ public class GrowCtx implements GrowCtxIfc {
case Glow.eEvent_MB1Up:
if ( sliderActive) {
if ( cmn.restriction_object != null) {
System.out.println("Slider end");
GlowEvent se = new GlowEvent();
se.event = Glow.eEvent_SliderMoveEnd;
......@@ -519,7 +517,6 @@ public class GrowCtx implements GrowCtxIfc {
else {
move_y = cmn.restriction_max_limit - node_move_last_y -
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) {
......
......@@ -13916,6 +13916,11 @@ void GeSlider::get_attributes( attr_sItem *attrinfo, int *item_count)
attrinfo[i].type = glow_eType_String;
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;
*item_count = i;
}
......@@ -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( maxvalue_attr, sizeof(maxvalue_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)
......@@ -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_maxvalue_attr) << FSPACE << maxvalue_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;
}
......@@ -13985,6 +13992,10 @@ void GeSlider::open( ifstream& fp)
fp.get();
fp.getline( insensitive_attr, sizeof(insensitive_attr));
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;
default:
cout << "GeSlider:open syntax error" << endl;
......@@ -14273,6 +14284,25 @@ int GeSlider::action( grow_tObject object, glow_tEvent event)
case glow_eEvent_MB1Down:
grow_SetClickSensitivity( dyn->graph->grow->ctx, glow_mSensitivity_MB1Press);
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: {
double max_value, min_value, max_pos, min_pos;
glow_eDirection direction;
......
......@@ -566,6 +566,7 @@
ge_eSave_Slider_minvalue_attr = 6001,
ge_eSave_Slider_maxvalue_attr = 6002,
ge_eSave_Slider_insensitive_attr = 6003,
ge_eSave_Slider_release_attr = 6004,
ge_eSave_AnalogColor_attribute = 6100,
ge_eSave_AnalogColor_limit = 6101,
ge_eSave_AnalogColor_limit_type = 6102,
......@@ -2214,6 +2215,7 @@ class GeSlider : public GeDynElem {
pwr_tAName minvalue_attr;
pwr_tAName maxvalue_attr;
pwr_tAName insensitive_attr;
pwr_tAName release_attr;
int slider_disabled;
pwr_tFloat32 *p;
......@@ -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),
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( insensitive_attr, "");}
strcpy( insensitive_attr, ""); strcpy( release_attr, "");}
GeSlider( const GeSlider& x) :
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)
{ 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 save( ofstream& fp);
void open( ifstream& fp);
......
......@@ -3295,6 +3295,8 @@ void GraphGrow::grow_trace_setup()
graph_grow_cb);
grow_EnableEvent( ctx, glow_eEvent_SliderMoveStart, glow_eEventType_CallBack,
graph_grow_cb);
grow_EnableEvent( ctx, glow_eEvent_SliderMoveEnd, glow_eEventType_CallBack,
graph_grow_cb);
grow_EnableEvent( ctx, glow_eEvent_AnnotationInput, glow_eEventType_CallBack,
graph_grow_cb);
grow_EnableEvent( ctx, glow_eEvent_InputFocusLost, glow_eEventType_CallBack,
......@@ -3843,22 +3845,25 @@ static int graph_trace_grow_cb( GlowCtx *ctx, glow_tEvent event)
}
break;
}
case glow_eEvent_SliderMoveStart:
case glow_eEvent_SliderMoveEnd:
{
if ( event->object.object_type == glow_eObjectType_NoObject)
{
grow_SetMoveRestrictions( graph->grow->ctx,
glow_eMoveRestriction_Disable, 0, 0, NULL);
graph->current_slider = NULL;
}
else
{
GeDyn *dyn;
GeDyn *dyn;
grow_GetUserData( event->object.object, (void **)&dyn);
dyn->action( event->object.object, event);
grow_GetUserData( event->object.object, (void **)&dyn);
dyn->action( event->object.object, event);
grow_SetMoveRestrictions( graph->grow->ctx,
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;
}
case glow_eEvent_SliderMoved:
......
......@@ -981,6 +981,7 @@ typedef enum {
glow_eEvent_CreateGrowObject, //!< Create grow object event
glow_eEvent_GrowDynamics, //!< Execute dynamics 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_HotRequest, //!< Hot request on object 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)
event_callback[glow_eEvent_SliderMoved]( this, &e);
// Send slider movement end event
e.event = glow_eEvent_SliderMoveStart;
e.event = glow_eEvent_SliderMoveEnd;
e.any.type = glow_eEventType_Object;
e.any.x_pixel = x;
e.any.y_pixel = y;
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.object.object = NULL;
e.object.object_type = glow_eObjectType_NoObject;
event_callback[glow_eEvent_SliderMoveStart]( this, &e);
e.object.object = restriction_object;
e.object.object_type = restriction_object->type();
event_callback[glow_eEvent_SliderMoveEnd]( this, &e);
}
node_move_last_x = x;
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