Commit 728ae83b authored by Claes Sjofors's avatar Claes Sjofors

Ge colorpalette current tone, and insert current tone in attribute editor with...

Ge colorpalette current tone, and insert current tone in attribute editor with ctrl+double click added
parent 5a9447f4
......@@ -187,6 +187,8 @@ int AttrGtk::reconfigure_attr()
&Attr::get_plant_select_c;
attrnav->get_current_colors_cb =
&Attr::get_current_colors_c;
attrnav->get_current_color_tone_cb =
&Attr::get_current_color_tone_c;
return 1;
......@@ -443,6 +445,8 @@ AttrGtk::AttrGtk( GtkWidget *a_parent_wid,
&Attr::get_plant_select_c;
attrnav->get_current_colors_cb =
&Attr::get_current_colors_c;
attrnav->get_current_color_tone_cb =
&Attr::get_current_color_tone_c;
GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
// msg_label = gtk_statusbar_new();
......
......@@ -2967,6 +2967,8 @@ GeGtk::GeGtk( void *x_parent_ctx,
graph->get_current_subgraph_cb = &Ge::subpalette_get_select;
graph->get_current_colors_cb = &Ge::colorpalette_get_current;
graph->set_current_colors_cb = &Ge::colorpalette_set_current;
graph->get_current_color_tone_cb = &Ge::colorpalette_get_current_tone;
graph->set_current_color_tone_cb = &Ge::colorpalette_set_current_tone;
graph->cursor_motion_cb = &Ge::status_msg;
graph->change_text_cb = &change_text_cb;
graph->change_name_cb = &change_name_cb;
......
......@@ -636,6 +636,16 @@ void Ge::colorpalette_set_current( void *gectx, glow_eDrawType fill_color,
fill_color, border_color, text_color);
}
void Ge::colorpalette_get_current_tone( void *gectx, glow_eDrawType *color_tone)
{
colpal_GetCurrentColorTone( ((Ge *)gectx)->colorpalette_ctx, color_tone);
}
void Ge::colorpalette_set_current_tone( void *gectx, glow_eDrawType color_tone)
{
colpal_SetCurrentColorTone( ((Ge *)gectx)->colorpalette_ctx, color_tone);
}
void Ge::subgraphs_close_cb( SubGraphs *subgraphs)
{
((Ge *) subgraphs->parent_ctx)->subgraphs = NULL;
......
......@@ -303,6 +303,8 @@ class Ge {
static void colorpalette_set_current( void *gectx, glow_eDrawType fill_color,
glow_eDrawType border_color,
glow_eDrawType text_color);
static void colorpalette_get_current_tone( void *gectx, glow_eDrawType *tone);
static void colorpalette_set_current_tone( void *gectx, glow_eDrawType tone);
static void subgraphs_close_cb( SubGraphs *subgraphs);
static void status_msg( void *ge_ctx, double x, double y);
static int command_cb( void *ge_ctx, char *command);
......
......@@ -154,6 +154,14 @@ int Attr::get_current_colors_c( void *attr_ctx, glow_eDrawType *fill_color,
return 0;
}
int Attr::get_current_color_tone_c( void *attr_ctx, glow_eDrawType *color_tone)
{
Attr *attr = (Attr *) attr_ctx;
if ( attr->get_current_color_tone_cb)
return attr->get_current_color_tone_cb( attr->parent_ctx, color_tone);
return 0;
}
int Attr::get_subgraph_info_c( void *attr_ctx, char *name,
attr_sItem **itemlist, int *item_cnt)
{
......
......@@ -90,6 +90,7 @@ class Attr {
int (*get_plant_select_cb) (void *, char *, int);
int (*get_current_colors_cb)( void *, glow_eDrawType *, glow_eDrawType *,
glow_eDrawType *);
int (*get_current_color_tone_cb)( void *, glow_eDrawType *);
void *client_data;
int recall_idx;
GeDyn *original_data;
......@@ -105,6 +106,7 @@ class Attr {
static int get_current_colors_c( void *attr_ctx, glow_eDrawType *fill_color,
glow_eDrawType *border_color,
glow_eDrawType *text_color);
static int get_current_color_tone_c( void *attr_ctx, glow_eDrawType *tone_color);
static int get_subgraph_info_c( void *attr_ctx, char *name,
attr_sItem **itemlist, int *item_cnt);
static int get_dyn_info_c( void *attr_ctx, GeDyn *dyn,
......
......@@ -1713,6 +1713,19 @@ static int attrnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
*(glow_eDrawType *)item->value_p = fill_color;
}
else if ( item->type_id == glow_eType_Tone ||
item->type_id == glow_eType_ToneOrColor) {
int sts;
glow_eDrawType color_tone;
if ( ! attrnav->get_current_color_tone_cb)
break;
sts = (attrnav->get_current_color_tone_cb) (attrnav->parent_ctx,
&color_tone);
if ( EVEN(sts)) break;
*(glow_eDrawType *)item->value_p = color_tone;
}
break;
default: ;
}
......
......@@ -159,6 +159,7 @@ class AttrNav {
int (*get_plant_select_cb)( void *, char *, int);
int (*get_current_colors_cb)( void *, glow_eDrawType *, glow_eDrawType *,
glow_eDrawType *);
int (*get_current_color_tone_cb)( void *, glow_eDrawType *);
virtual int set_attr_value( char *value_str);
virtual int check_attr_value( int *multiline, char **value);
......
......@@ -124,6 +124,7 @@ static int graph_reconfigure_attr_cb( void *g, grow_tObject object,
static int graph_get_plant_select_cb( void *g, char *value, int size);
static int graph_get_current_colors_cb( void *g, glow_eDrawType *fill_color,
glow_eDrawType *border_color, glow_eDrawType *text_color);
static int graph_get_current_color_tone_cb( void *g, glow_eDrawType *color_tone);
static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event);
static void graph_free_dyn( grow_tObject object);
......@@ -1881,6 +1882,7 @@ int Graph::edit_attributes( grow_tObject object)
attr->set_data_cb = &graph_attr_set_data_cb;
attr->get_plant_select_cb = &graph_get_plant_select_cb;
attr->get_current_colors_cb = &graph_get_current_colors_cb;
attr->get_current_color_tone_cb = &graph_get_current_color_tone_cb;
attr_list.insert( (void *)object, (void *) attr);
grow_SetModified( grow->ctx, 1);
......@@ -1910,6 +1912,17 @@ static int graph_get_current_colors_cb( void *g, glow_eDrawType *fill_color,
return 0;
}
static int graph_get_current_color_tone_cb( void *g, glow_eDrawType *color_tone)
{
Graph *graph = (Graph *)g;
if ( graph->get_current_color_tone_cb) {
(graph->get_current_color_tone_cb) (graph->parent_ctx, color_tone);
return 1;
}
return 0;
}
static int graph_reconfigure_attr_cb( void *g, grow_tObject object,
attr_sItem **itemlist, int *itemlist_cnt, void **client_data)
{
......
......@@ -456,6 +456,8 @@ class Graph {
int (*close_cb)( void *);
void (*get_current_colors_cb)( void *, glow_eDrawType *, glow_eDrawType *, glow_eDrawType *);
void (*set_current_colors_cb)( void *, glow_eDrawType, glow_eDrawType, glow_eDrawType);
void (*get_current_color_tone_cb)( void *, glow_eDrawType *);
void (*set_current_color_tone_cb)( void *, glow_eDrawType);
void (*init_cb)( void *);
void (*cursor_motion_cb)( void *, double, double);
void (*change_text_cb)( void *, void *, const char *);
......
......@@ -89,6 +89,15 @@ void colpal_SetCurrentColors( colpal_tCtx ctx, glow_eDrawType fill_color,
ctx->current_text = text_color;
}
void colpal_GetCurrentColorTone( colpal_tCtx ctx, glow_eDrawType *color_tone)
{
*color_tone = ctx->current_tone;
}
void colpal_SetCurrentColorTone( colpal_tCtx ctx, glow_eDrawType color_tone)
{
ctx->current_tone = color_tone;
}
colpal_eActive colpal_GetActive( colpal_tCtx ctx)
{
......
......@@ -115,6 +115,10 @@ typedef ColPalCtx *colpal_tCtx;
void colpal_SetCurrentColors( colpal_tCtx ctx, glow_eDrawType fill_color,
glow_eDrawType border_color, glow_eDrawType text_color);
void colpal_GetCurrentColorTone( colpal_tCtx ctx, glow_eDrawType *tone);
void colpal_SetCurrentColorTone( colpal_tCtx ctx, glow_eDrawType tone);
colpal_eActive colpal_GetActive( colpal_tCtx ctx);
/*@}*/
......
......@@ -58,6 +58,7 @@
#include "glow_draw.h"
#include "glow_msg.h"
static int tone_color_match( int tone);
void ColPalCtx::configure()
{
......@@ -130,10 +131,16 @@ void ColPalCtx::configure()
double tone_entry_width = 3 * entry_width;
y += entry_height;
x = 0;
text = new GrowText( this, "ToneText", "Tone", x + 0.15,
active_tone = new GrowRect( this, "ToneRect", x, y,
tone_entry_width * 2, entry_height, glow_eDrawType_Line, 1, 0,
glow_mDisplayLevel_1, 1, 1, 0, glow_eDrawType_Color34);
insert( active_tone);
text_tone = new GrowText( this, "ToneText", "Tone", x + 0.15,
y + entry_height / 2 + 0.25,
glow_eDrawType_TextHelveticaBold, glow_eDrawType_Line, 2);
insert( (GlowArrayElem *)text);
insert( text_tone);
x += 2 * tone_entry_width;
sprintf( name, "ToneEntry%d", 0);
rect = new GrowRect( this, name, x, y,
......@@ -165,36 +172,7 @@ void ColPalCtx::configure()
char name[16];
glow_eDrawType drawtype;
switch( i) {
case glow_eDrawTone_No: drawtype = glow_eDrawType_Color32; break;
case glow_eDrawTone_Gray: drawtype = glow_eDrawType_Color35; break;
case glow_eDrawTone_YellowGreen: drawtype = glow_eDrawType_Color85; break;
case glow_eDrawTone_Yellow: drawtype = glow_eDrawType_Color115; break;
case glow_eDrawTone_Orange: drawtype = glow_eDrawType_Color145; break;
case glow_eDrawTone_Red: drawtype = glow_eDrawType_Color175; break;
case glow_eDrawTone_Magenta: drawtype = glow_eDrawType_Color205; break;
case glow_eDrawTone_Blue: drawtype = glow_eDrawType_Color235; break;
case glow_eDrawTone_Seablue: drawtype = glow_eDrawType_Color265; break;
case glow_eDrawTone_Green: drawtype = glow_eDrawType_Color295; break;
case glow_eDrawTone_DarkGray: drawtype = glow_eDrawType_Color38; break;
case glow_eDrawTone_DarkYellowGreen: drawtype = glow_eDrawType_Color88; break;
case glow_eDrawTone_DarkYellow: drawtype = glow_eDrawType_Color118; break;
case glow_eDrawTone_DarkOrange: drawtype = glow_eDrawType_Color148; break;
case glow_eDrawTone_DarkRed: drawtype = glow_eDrawType_Color178; break;
case glow_eDrawTone_DarkMagenta: drawtype = glow_eDrawType_Color208; break;
case glow_eDrawTone_DarkBlue: drawtype = glow_eDrawType_Color238; break;
case glow_eDrawTone_DarkSeablue: drawtype = glow_eDrawType_Color268; break;
case glow_eDrawTone_DarkGreen: drawtype = glow_eDrawType_Color298; break;
case glow_eDrawTone_LightGray: drawtype = glow_eDrawType_Color32; break;
case glow_eDrawTone_LightYellowGreen: drawtype = glow_eDrawType_Color82; break;
case glow_eDrawTone_LightYellow: drawtype = glow_eDrawType_Color112; break;
case glow_eDrawTone_LightOrange: drawtype = glow_eDrawType_Color142; break;
case glow_eDrawTone_LightRed: drawtype = glow_eDrawType_Color172; break;
case glow_eDrawTone_LightMagenta: drawtype = glow_eDrawType_Color202; break;
case glow_eDrawTone_LightBlue: drawtype = glow_eDrawType_Color232; break;
case glow_eDrawTone_LightSeablue: drawtype = glow_eDrawType_Color262; break;
case glow_eDrawTone_LightGreen: drawtype = glow_eDrawType_Color292; break;
}
drawtype = (glow_eDrawType) tone_color_match( i);
if ( i == glow_eDrawTone_Gray ||
i == glow_eDrawTone_LightGray ||
i == glow_eDrawTone_DarkGray) {
......@@ -397,6 +375,7 @@ int ColPalCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
e.colortone.tone = tone;
event_callback[event]( this, &e);
}
current_tone = (glow_eDrawType) tone;
break;
}
if ( strcmp( name, "ColorEntryBg") == 0) {
......@@ -452,6 +431,9 @@ int ColPalCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
e.colortone.tone = tone;
event_callback[event]( this, &e);
}
current_tone = (glow_eDrawType) tone;
((GrowRect *)active_tone)->set_fill_color(
(glow_eDrawType) tone_color_match( (int)tone));
break;
}
if ( strncmp( name, "ColorEntry", 10) != 0)
......@@ -669,3 +651,42 @@ void ColPalCtx::set_colors()
draw( &mw, 0, 0, mw.window_width, mw.window_height);
}
int tone_color_match( int tone)
{
int drawtype;
switch( tone) {
case glow_eDrawTone_No: drawtype = glow_eDrawType_Color32; break;
case glow_eDrawTone_Gray: drawtype = glow_eDrawType_Color35; break;
case glow_eDrawTone_YellowGreen: drawtype = glow_eDrawType_Color85; break;
case glow_eDrawTone_Yellow: drawtype = glow_eDrawType_Color115; break;
case glow_eDrawTone_Orange: drawtype = glow_eDrawType_Color145; break;
case glow_eDrawTone_Red: drawtype = glow_eDrawType_Color175; break;
case glow_eDrawTone_Magenta: drawtype = glow_eDrawType_Color205; break;
case glow_eDrawTone_Blue: drawtype = glow_eDrawType_Color235; break;
case glow_eDrawTone_Seablue: drawtype = glow_eDrawType_Color265; break;
case glow_eDrawTone_Green: drawtype = glow_eDrawType_Color295; break;
case glow_eDrawTone_DarkGray: drawtype = glow_eDrawType_Color38; break;
case glow_eDrawTone_DarkYellowGreen: drawtype = glow_eDrawType_Color88; break;
case glow_eDrawTone_DarkYellow: drawtype = glow_eDrawType_Color118; break;
case glow_eDrawTone_DarkOrange: drawtype = glow_eDrawType_Color148; break;
case glow_eDrawTone_DarkRed: drawtype = glow_eDrawType_Color178; break;
case glow_eDrawTone_DarkMagenta: drawtype = glow_eDrawType_Color208; break;
case glow_eDrawTone_DarkBlue: drawtype = glow_eDrawType_Color238; break;
case glow_eDrawTone_DarkSeablue: drawtype = glow_eDrawType_Color268; break;
case glow_eDrawTone_DarkGreen: drawtype = glow_eDrawType_Color298; break;
case glow_eDrawTone_LightGray: drawtype = glow_eDrawType_Color32; break;
case glow_eDrawTone_LightYellowGreen: drawtype = glow_eDrawType_Color82; break;
case glow_eDrawTone_LightYellow: drawtype = glow_eDrawType_Color112; break;
case glow_eDrawTone_LightOrange: drawtype = glow_eDrawType_Color142; break;
case glow_eDrawTone_LightRed: drawtype = glow_eDrawType_Color172; break;
case glow_eDrawTone_LightMagenta: drawtype = glow_eDrawType_Color202; break;
case glow_eDrawTone_LightBlue: drawtype = glow_eDrawType_Color232; break;
case glow_eDrawTone_LightSeablue: drawtype = glow_eDrawType_Color262; break;
case glow_eDrawTone_LightGreen: drawtype = glow_eDrawType_Color292; break;
default: return glow_eDrawType_No;
}
return drawtype;
}
......@@ -128,15 +128,18 @@ class ColPalCtx : public GrowCtx {
glow_eDrawType current_fill; //!< The currently selected fill color.
glow_eDrawType current_border; //!< The currently selected border color.
glow_eDrawType current_text; //!< The currently selected text color.
glow_eDrawType current_tone; //!< The currently selected color tone.
GlowArrayElem *display_fill; //!< The rectangle object to display the current fillcolor.
GlowArrayElem *display_border; //!< The rectangle object to display the current border color.
GlowArrayElem *display_text; //!< The rectangle object to display the current text color.
GlowArrayElem *active_fill; //!< The rectangle object to mark fill color active.
GlowArrayElem *active_border; //!< The rectangle object to mark border color active.
GlowArrayElem *active_text; //!< The rectangle object to mark text color active.
GlowArrayElem *active_tone; //!< The rectangle object to mark colortone active.
GlowArrayElem *text_fill; //!< The fill color text object.
GlowArrayElem *text_border; //!< The border color text object.
GlowArrayElem *text_text; //!< The text color text object.
GlowArrayElem *text_tone; //!< The text tone text object.
double entry_width; //!< Width of a color palette entry.
double entry_height; //!< Height of a color palette entry.
double display_entry_width; //!< Width of a display entry.
......
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