Commit 298e7e68 authored by claes's avatar claes

New scale cursors, and status row in ge

parent 64bb037d
...@@ -696,6 +696,14 @@ typedef enum { ...@@ -696,6 +696,14 @@ typedef enum {
glow_eDrawCursor_CrossHair, //!< Crosshair cursor glow_eDrawCursor_CrossHair, //!< Crosshair cursor
glow_eDrawCursor_Hand, //!< Hand cursor glow_eDrawCursor_Hand, //!< Hand cursor
glow_eDrawCursor_DiamondCross, //!< Diamond cross cursor glow_eDrawCursor_DiamondCross, //!< Diamond cross cursor
glow_eDrawCursor_BottomLeftCorner, //!< Bottom left corner cursor
glow_eDrawCursor_BottomRightCorner, //!< Bottom right corner cursor
glow_eDrawCursor_BottomSide, //!< Bottom side cursor
glow_eDrawCursor_TopLeftCorner, //!< Top left corner cursor
glow_eDrawCursor_TopRightCorner, //!< Top right corner cursor
glow_eDrawCursor_TopSide, //!< Top side cursor
glow_eDrawCursor_RightSide, //!< Right side cursor
glow_eDrawCursor_LeftSide, //!< Left side cursor
glow_eDrawCursor__ glow_eDrawCursor__
} glow_eDrawCursor; } glow_eDrawCursor;
......
...@@ -780,6 +780,10 @@ class GlowCtx { ...@@ -780,6 +780,10 @@ class GlowCtx {
/*! \param show 1 display the grid points, 0 hide. */ /*! \param show 1 display the grid points, 0 hide. */
void set_show_grid( int show); void set_show_grid( int show);
//! Get show grid.
/*! \return 1 grid points are displayed, 0 hidden. */
int get_show_grid() { return show_grid;}
//! Draw gridpoints in the specified area. //! Draw gridpoints in the specified area.
/*! /*!
\param ll_x x coordinate for lower left corner of area in pixel. \param ll_x x coordinate for lower left corner of area in pixel.
......
...@@ -134,6 +134,30 @@ static int glow_create_cursor( draw_tCtx draw_ctx) ...@@ -134,6 +134,30 @@ static int glow_create_cursor( draw_tCtx draw_ctx)
draw_ctx->cursors[glow_eDrawCursor_Hand] = draw_ctx->cursors[glow_eDrawCursor_Hand] =
XCreateFontCursor( draw_ctx->display, XC_hand2); XCreateFontCursor( draw_ctx->display, XC_hand2);
draw_ctx->cursors[glow_eDrawCursor_BottomLeftCorner] =
XCreateFontCursor( draw_ctx->display, XC_bottom_left_corner);
draw_ctx->cursors[glow_eDrawCursor_BottomRightCorner] =
XCreateFontCursor( draw_ctx->display, XC_bottom_right_corner);
draw_ctx->cursors[glow_eDrawCursor_BottomSide] =
XCreateFontCursor( draw_ctx->display, XC_bottom_side);
draw_ctx->cursors[glow_eDrawCursor_TopLeftCorner] =
XCreateFontCursor( draw_ctx->display, XC_top_left_corner);
draw_ctx->cursors[glow_eDrawCursor_TopRightCorner] =
XCreateFontCursor( draw_ctx->display, XC_top_right_corner);
draw_ctx->cursors[glow_eDrawCursor_TopSide] =
XCreateFontCursor( draw_ctx->display, XC_top_side);
draw_ctx->cursors[glow_eDrawCursor_RightSide] =
XCreateFontCursor( draw_ctx->display, XC_right_side);
draw_ctx->cursors[glow_eDrawCursor_LeftSide] =
XCreateFontCursor( draw_ctx->display, XC_left_side);
return 1; return 1;
} }
......
...@@ -678,6 +678,53 @@ void grow_SetAttributes( grow_tCtx ctx, grow_sAttributes *attr, ...@@ -678,6 +678,53 @@ void grow_SetAttributes( grow_tCtx ctx, grow_sAttributes *attr,
ctx->initial_position = attr->initial_position; ctx->initial_position = attr->initial_position;
} }
void grow_GetAttributes( grow_tCtx ctx, grow_sAttributes *attr,
unsigned long mask)
{
if ( mask & grow_eAttr_base_zoom_factor)
attr->base_zoom_factor = ctx->base_zoom_factor;
if ( mask & grow_eAttr_offset_x)
attr->offset_x = ctx->offset_x;
if ( mask & grow_eAttr_offset_y)
attr->offset_y = ctx->offset_y;
if ( mask & grow_eAttr_grid_size_x)
attr->grid_size_x = ctx->grid_size_x;
if ( mask & grow_eAttr_grid_size_y)
attr->grid_size_y = ctx->grid_size_y;
if ( mask & grow_eAttr_grid_on)
attr->grid_on = ctx->grid_on;
if ( mask & grow_eAttr_user_highlight)
attr->user_highlight = ctx->user_highlight;
if ( mask & grow_eAttr_draw_delta)
attr->draw_delta = ctx->draw_delta;
if ( mask & grow_eAttr_grafcet_con_delta)
attr->grafcet_con_delta = ctx->grafcet_con_delta;
if ( mask & grow_eAttr_refcon_width)
attr->refcon_width = ctx->refcon_width;
if ( mask & grow_eAttr_refcon_height)
attr->refcon_height = ctx->refcon_height;
if ( mask & grow_eAttr_refcon_linewidth)
attr->refcon_linewidth = ctx->refcon_linewidth;
if ( mask & grow_eAttr_refcon_textsize)
attr->refcon_textsize = ctx->refcon_textsize;
if ( mask & grow_eAttr_application_paste)
attr->application_paste = ctx->application_paste;
if ( mask & grow_eAttr_select_policy)
attr->select_policy = ctx->select_policy;
if ( mask & grow_eAttr_display_level)
attr->display_level = ctx->display_level;
if ( mask & grow_eAttr_default_hot_mode)
attr->default_hot_mode = ctx->default_hot_mode;
if ( mask & grow_eAttr_enable_bg_pixmap)
attr->enable_bg_pixmap = ctx->enable_bg_pixmap;
if ( mask & grow_eAttr_double_buffer_on)
attr->double_buffer_on = ctx->double_buffer_on;
if ( mask & grow_eAttr_hot_mode)
attr->hot_mode = ctx->hot_mode;
if ( mask & grow_eAttr_initial_position)
attr->initial_position = (glow_eDirection) ctx->initial_position;
}
void grow_PositionToPixel( grow_tCtx ctx, double x, double y, void grow_PositionToPixel( grow_tCtx ctx, double x, double y,
int *pix_x, int *pix_y) int *pix_x, int *pix_y)
{ {
...@@ -3636,11 +3683,21 @@ void grow_SetMoveRestrictions( grow_tCtx ctx, glow_eMoveRestriction restriction, ...@@ -3636,11 +3683,21 @@ void grow_SetMoveRestrictions( grow_tCtx ctx, glow_eMoveRestriction restriction,
(GlowArrayElem *)object); (GlowArrayElem *)object);
} }
glow_eMoveRestriction grow_GetMoveRestrictions( grow_tCtx ctx)
{
return ctx->move_restriction;
}
void grow_SetScaleEqual( grow_tCtx ctx, int equal) void grow_SetScaleEqual( grow_tCtx ctx, int equal)
{ {
ctx->set_scale_equal( equal); ctx->set_scale_equal( equal);
} }
int grow_GetScaleEqual( grow_tCtx ctx)
{
return ctx->scale_equal;
}
void grow_GetSliderInfo( grow_tObject object, glow_eDirection *direction, void grow_GetSliderInfo( grow_tObject object, glow_eDirection *direction,
double *max_value, double *min_value, double *max_pos, double *min_pos) double *max_value, double *min_value, double *max_pos, double *min_pos)
{ {
...@@ -3899,6 +3956,11 @@ void grow_SetShowGrid( grow_tCtx ctx, int show) ...@@ -3899,6 +3956,11 @@ void grow_SetShowGrid( grow_tCtx ctx, int show)
ctx->set_show_grid( show); ctx->set_show_grid( show);
} }
int grow_GetShowGrid( grow_tCtx ctx)
{
return ctx->get_show_grid();
}
int grow_IsNextNodeClass( grow_tNodeClass nodeclass) int grow_IsNextNodeClass( grow_tNodeClass nodeclass)
{ {
return ((GlowNodeClass *)nodeclass)->is_next(); return ((GlowNodeClass *)nodeclass)->is_next();
......
...@@ -664,6 +664,15 @@ typedef GlowTraceData glow_sTraceData; ...@@ -664,6 +664,15 @@ typedef GlowTraceData glow_sTraceData;
void grow_SetAttributes( grow_tCtx ctx, grow_sAttributes *attr, void grow_SetAttributes( grow_tCtx ctx, grow_sAttributes *attr,
unsigned long mask); unsigned long mask);
//! Get attributes of the grow context.
/*!
\param ctx Grow context.
\param attr Data structure with attribute values.
\param mask Mask of the attributes to get.
*/
void grow_GetAttributes( grow_tCtx ctx, grow_sAttributes *attr,
unsigned long mask);
//! Convert coordinates for a point to pixel. //! Convert coordinates for a point to pixel.
/*! /*!
\param ctx Grow context. \param ctx Grow context.
...@@ -1938,6 +1947,13 @@ typedef GlowTraceData glow_sTraceData; ...@@ -1938,6 +1947,13 @@ typedef GlowTraceData glow_sTraceData;
void grow_SetMoveRestrictions( grow_tCtx ctx, glow_eMoveRestriction restriction, void grow_SetMoveRestrictions( grow_tCtx ctx, glow_eMoveRestriction restriction,
double max_limit, double min_limit, grow_tObject object); double max_limit, double min_limit, grow_tObject object);
//! Get current movement restrictions.
/*!
\param ctx Grow context.
\return Type of restriction.
*/
glow_eMoveRestriction grow_GetMoveRestrictions( grow_tCtx ctx);
//! Set or reset scaletype to equal scale. //! Set or reset scaletype to equal scale.
/*! /*!
\param ctx Grow context. \param ctx Grow context.
...@@ -1948,6 +1964,13 @@ typedef GlowTraceData glow_sTraceData; ...@@ -1948,6 +1964,13 @@ typedef GlowTraceData glow_sTraceData;
*/ */
void grow_SetScaleEqual( grow_tCtx ctx, int equal); void grow_SetScaleEqual( grow_tCtx ctx, int equal);
//! Get current scaletype.
/*!
\param ctx Grow context.
\return If 1 scaletype is equal.
*/
int grow_GetScaleEqual( grow_tCtx ctx);
//! Get info for a slider object. //! Get info for a slider object.
/*! /*!
\param object Slider object. \param object Slider object.
...@@ -2346,6 +2369,13 @@ typedef GlowTraceData glow_sTraceData; ...@@ -2346,6 +2369,13 @@ typedef GlowTraceData glow_sTraceData;
*/ */
void grow_SetShowGrid( grow_tCtx ctx, int show); void grow_SetShowGrid( grow_tCtx ctx, int show);
//! Get if gridpoints are displayed.
/*!
\param ctx Grow context.
\return 1: gridpoints are displayed, 0: hidden.
*/
int grow_GetShowGrid( grow_tCtx ctx);
//! Check if a nodeclass is a next page. //! Check if a nodeclass is a next page.
/*! /*!
\param nodeclass Nodeclass to check. \param nodeclass Nodeclass to check.
......
...@@ -493,14 +493,89 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h) ...@@ -493,14 +493,89 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
} }
break; break;
case glow_eEvent_CursorMotion: case glow_eEvent_CursorMotion:
cursor_present = 1; if ( edit_mode == grow_eMode_Scale) {
cursor_x = x; int x0 = select_rect_ll_x;
cursor_y = y; int delta_x = (select_rect_ur_x - select_rect_ll_x) / 3 + 1;
if ( node_movement_paste_active) int y0 = select_rect_ll_y;
{ int delta_y = (select_rect_ur_y - select_rect_ll_y) / 3 + 1;
set_defered_redraw();
switch( move_restriction) glow_eScaleType scale_type;
{
if ( (x0 <= x && x < x0 + delta_x) &&
(y0 <= y && y < y0 + delta_y))
scale_type = glow_eScaleType_UpperRight;
else if ( (x0 + delta_x <= x && x < x0 + 2 * delta_x) &&
(y0 <= y && y < y0 + delta_y))
scale_type = glow_eScaleType_Up;
else if ( (x0 + 2 * delta_x <= x && x < x0 + 3 * delta_x) &&
(y0 <= y && y < y0 + delta_y))
scale_type = glow_eScaleType_UpperLeft;
else if ( (x0 <= x && x < x0 + delta_x) &&
(y0 + delta_y <= y && y < y0 + 2 * delta_y))
scale_type = glow_eScaleType_Right;
else if ( (x0 + 2 * delta_x <= x && x < x0 + 3 * delta_x) &&
(y0 + delta_y <= y && y < y0 + 2 * delta_y))
scale_type = glow_eScaleType_Left;
else if ( (x0 <= x && x < x0 + delta_x) &&
(y0 + 2 * delta_y <= y && y < y0 + 3 * delta_y))
scale_type = glow_eScaleType_LowerRight;
else if ( (x0 + delta_x <= x && x < x0 + 2 * delta_x) &&
(y0 + 2 * delta_y <= y && y < y0 + 3 * delta_y))
scale_type = glow_eScaleType_Down;
else if ( (x0 + 2 * delta_x <= x && x < x0 + 3 * delta_x) &&
(y0 + 2 * delta_y <= y && y < y0 + 3 * delta_y))
scale_type = glow_eScaleType_LowerLeft;
else
scale_type = glow_eScaleType_No;
switch ( scale_type) {
case glow_eScaleType_Up:
if ( scale_equal)
draw_set_cursor( this, glow_eDrawCursor_Normal);
else
draw_set_cursor( ctx, glow_eDrawCursor_TopSide);
break;
case glow_eScaleType_Down:
if ( scale_equal)
draw_set_cursor( this, glow_eDrawCursor_Normal);
else
draw_set_cursor( ctx, glow_eDrawCursor_BottomSide);
break;
case glow_eScaleType_Right:
if ( scale_equal)
draw_set_cursor( this, glow_eDrawCursor_Normal);
else
draw_set_cursor( ctx, glow_eDrawCursor_LeftSide);
break;
case glow_eScaleType_Left:
if ( scale_equal)
draw_set_cursor( this, glow_eDrawCursor_Normal);
else
draw_set_cursor( this, glow_eDrawCursor_RightSide);
break;
case glow_eScaleType_UpperRight:
draw_set_cursor( ctx, glow_eDrawCursor_TopLeftCorner);
break;
case glow_eScaleType_LowerLeft:
draw_set_cursor( ctx, glow_eDrawCursor_BottomRightCorner);
break;
case glow_eScaleType_UpperLeft:
draw_set_cursor( ctx, glow_eDrawCursor_TopRightCorner);
break;
case glow_eScaleType_LowerRight:
draw_set_cursor( this, glow_eDrawCursor_BottomLeftCorner);
break;
default:
draw_set_cursor( this, glow_eDrawCursor_Normal);
}
}
else {
cursor_present = 1;
cursor_x = x;
cursor_y = y;
if ( node_movement_paste_active) {
set_defered_redraw();
switch( move_restriction) {
case glow_eMoveRestriction_Vertical: case glow_eMoveRestriction_Vertical:
a_move.move( 0, y - node_move_last_y, 0); a_move.move( 0, y - node_move_last_y, 0);
break; break;
...@@ -510,16 +585,16 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h) ...@@ -510,16 +585,16 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
default: default:
a_move.move( x - node_move_last_x, y - node_move_last_y, 0); a_move.move( x - node_move_last_x, y - node_move_last_y, 0);
break; break;
} }
node_move_last_x = x; node_move_last_x = x;
node_move_last_y = y; node_move_last_y = y;
redraw_defered(); redraw_defered();
} }
sts = 0; sts = 0;
hot_found = ( hot_mode == glow_eHotMode_Disabled); hot_found = ( hot_mode == glow_eHotMode_Disabled);
for ( i = 0; i < a.a_size; i++) for ( i = 0; i < a.a_size; i++) {
{ sts = a.a[a.a_size-i-1]->event_handler( event, x, y, fx, fy);
sts = a.a[a.a_size-i-1]->event_handler( event, x, y, fx, fy); }
} }
break; break;
case glow_eEvent_ButtonMotion: case glow_eEvent_ButtonMotion:
...@@ -971,8 +1046,14 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h) ...@@ -971,8 +1046,14 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
} }
else if ( edit_mode == grow_eMode_EditPolyLine && node_movement_active) else if ( edit_mode == grow_eMode_EditPolyLine && node_movement_active)
{ {
((GrowPolyLine *)a_move[0])->move_current_point( int dx = x - node_move_last_x;
x - node_move_last_x, y - node_move_last_y, 0); int dy = y - node_move_last_y;
if ( move_restriction == glow_eMoveRestriction_Vertical)
dx = 0;
else if ( move_restriction == glow_eMoveRestriction_Horizontal)
dy = 0;
((GrowPolyLine *)a_move[0])->move_current_point( dx, dy, 0);
node_move_last_x = x; node_move_last_x = x;
node_move_last_y = y; node_move_last_y = y;
} }
...@@ -984,8 +1065,14 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h) ...@@ -984,8 +1065,14 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
scale_active = 0; scale_active = 0;
if ( node_movement_active && edit_mode == grow_eMode_EditPolyLine) if ( node_movement_active && edit_mode == grow_eMode_EditPolyLine)
{ {
((GrowPolyLine *)a_move[0])->move_current_point( int dx = x - node_move_last_x;
x - node_move_last_x, y - node_move_last_y, grid_on); int dy = y - node_move_last_y;
if ( move_restriction == glow_eMoveRestriction_Vertical)
dx = 0;
else if ( move_restriction == glow_eMoveRestriction_Horizontal)
dy = 0;
((GrowPolyLine *)a_move[0])->move_current_point( dx, dy, grid_on);
node_move_last_x = x; node_move_last_x = x;
node_move_last_y = y; node_move_last_y = y;
node_movement_active = 0; node_movement_active = 0;
...@@ -1327,9 +1414,8 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h) ...@@ -1327,9 +1414,8 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
} }
} }
} }
else if ( select_rect_active && edit_mode != grow_eMode_Scale) else if ( select_rect_active && edit_mode == grow_eMode_Scale)
{ {
} }
else if ( con_create_active) else if ( con_create_active)
{ {
...@@ -2500,6 +2586,10 @@ void grow_auto_scrolling( GrowCtx *ctx) ...@@ -2500,6 +2586,10 @@ void grow_auto_scrolling( GrowCtx *ctx)
{ {
delta_x = - (ctx->node_move_last_x - ctx->window_width / 2) / 6; delta_x = - (ctx->node_move_last_x - ctx->window_width / 2) / 6;
delta_y = - (ctx->node_move_last_y - ctx->window_height / 2) / 6; delta_y = - (ctx->node_move_last_y - ctx->window_height / 2) / 6;
if ( ctx->move_restriction == glow_eMoveRestriction_Vertical)
delta_x = 0;
else if ( ctx->move_restriction == glow_eMoveRestriction_Horizontal)
delta_y = 0;
ctx->set_defered_redraw(); ctx->set_defered_redraw();
((GrowPolyLine *)ctx->a_move[0])->move_current_point( ((GrowPolyLine *)ctx->a_move[0])->move_current_point(
......
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