return;
}
- if (ui.cur_mapping != 0) return;
- if (ui.toolno[0] == TOOL_PEN) return;
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return; // not user-generated
+ if (ui.toolno[ui.cur_mapping] == TOOL_PEN) return;
+ ui.cur_mapping = 0; // don't use switch_mapping() (refreshes buttons too soon)
end_text();
reset_focus();
reset_selection();
- ui.toolno[0] = TOOL_PEN;
- ui.cur_brush = &(ui.brushes[0][TOOL_PEN]);
+ ui.toolno[ui.cur_mapping] = TOOL_PEN;
+ ui.cur_brush = &(ui.brushes[ui.cur_mapping][TOOL_PEN]);
ui.cur_brush->ruler = ui.default_brushes[TOOL_PEN].ruler;
ui.cur_brush->recognizer = ui.default_brushes[TOOL_PEN].recognizer;
update_mapping_linkings(TOOL_PEN);
return;
}
- if (ui.cur_mapping != 0) return;
- if (ui.toolno[0] == TOOL_ERASER) return;
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return; // not user-generated
+ if (ui.toolno[ui.cur_mapping] == TOOL_ERASER) return;
+ ui.cur_mapping = 0; // don't use switch_mapping() (refreshes buttons too soon)
end_text();
reset_focus();
reset_selection();
- ui.toolno[0] = TOOL_ERASER;
- ui.cur_brush = &(ui.brushes[0][TOOL_ERASER]);
+ ui.toolno[ui.cur_mapping] = TOOL_ERASER;
+ ui.cur_brush = &(ui.brushes[ui.cur_mapping][TOOL_ERASER]);
update_mapping_linkings(TOOL_ERASER);
update_tool_buttons();
update_tool_menu();
return;
}
- if (ui.cur_mapping != 0) return; // not user-generated
- if (ui.toolno[0] == TOOL_HIGHLIGHTER) return;
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return; // not user-generated
+ if (ui.toolno[ui.cur_mapping] == TOOL_HIGHLIGHTER) return;
+ ui.cur_mapping = 0; // don't use switch_mapping() (refreshes buttons too soon)
end_text();
reset_focus();
reset_selection();
- ui.toolno[0] = TOOL_HIGHLIGHTER;
- ui.cur_brush = &(ui.brushes[0][TOOL_HIGHLIGHTER]);
+ ui.toolno[ui.cur_mapping] = TOOL_HIGHLIGHTER;
+ ui.cur_brush = &(ui.brushes[ui.cur_mapping][TOOL_HIGHLIGHTER]);
ui.cur_brush->ruler = ui.default_brushes[TOOL_HIGHLIGHTER].ruler;
ui.cur_brush->recognizer = ui.default_brushes[TOOL_HIGHLIGHTER].recognizer;
update_mapping_linkings(TOOL_HIGHLIGHTER);
return;
}
- if (ui.cur_mapping != 0) return; // not user-generated
- if (ui.toolno[0] == TOOL_TEXT) return;
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return; // not user-generated
+ if (ui.toolno[ui.cur_mapping] == TOOL_TEXT) return;
+ ui.cur_mapping = 0; // don't use switch_mapping() (refreshes buttons too soon)
reset_focus();
reset_selection();
- ui.toolno[0] = TOOL_TEXT;
- ui.cur_brush = &(ui.brushes[0][TOOL_PEN]);
+ ui.toolno[ui.cur_mapping] = TOOL_TEXT;
+ ui.cur_brush = &(ui.brushes[ui.cur_mapping][TOOL_PEN]);
update_mapping_linkings(-1);
update_tool_buttons();
update_tool_menu();
return;
}
- if (ui.cur_mapping != 0) return; // not user-generated
- if (ui.toolno[0] == TOOL_SELECTRECT) return;
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return; // not user-generated
+ if (ui.toolno[ui.cur_mapping] == TOOL_SELECTRECT) return;
+ ui.cur_mapping = 0; // don't use switch_mapping() (refreshes buttons too soon)
end_text();
reset_focus();
- ui.toolno[0] = TOOL_SELECTRECT;
+ ui.toolno[ui.cur_mapping] = TOOL_SELECTRECT;
update_mapping_linkings(-1);
update_tool_buttons();
update_tool_menu();
return;
}
- if (ui.cur_mapping != 0) return; // not user-generated
- if (ui.toolno[0] == TOOL_VERTSPACE) return;
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return; // not user-generated
+ if (ui.toolno[ui.cur_mapping] == TOOL_VERTSPACE) return;
+ ui.cur_mapping = 0; // don't use switch_mapping() (refreshes buttons too soon)
end_text();
reset_focus();
reset_selection();
- ui.toolno[0] = TOOL_VERTSPACE;
+ ui.toolno[ui.cur_mapping] = TOOL_VERTSPACE;
update_mapping_linkings(-1);
update_tool_buttons();
update_tool_menu();
on_colorBlack_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_BLACK);
+ process_color_activate(menuitem, COLOR_BLACK, predef_colors_rgba[COLOR_BLACK]);
}
on_colorBlue_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_BLUE);
-
+ process_color_activate(menuitem, COLOR_BLUE, predef_colors_rgba[COLOR_BLUE]);
}
on_colorRed_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_RED);
+ process_color_activate(menuitem, COLOR_RED, predef_colors_rgba[COLOR_RED]);
}
on_colorGreen_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_GREEN);
+ process_color_activate(menuitem, COLOR_GREEN, predef_colors_rgba[COLOR_GREEN]);
}
on_colorGray_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_GRAY);
+ process_color_activate(menuitem, COLOR_GRAY, predef_colors_rgba[COLOR_GRAY]);
}
on_colorLightBlue_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_LIGHTBLUE);
+ process_color_activate(menuitem, COLOR_LIGHTBLUE, predef_colors_rgba[COLOR_LIGHTBLUE]);
}
on_colorLightGreen_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_LIGHTGREEN);
+ process_color_activate(menuitem, COLOR_LIGHTGREEN, predef_colors_rgba[COLOR_LIGHTGREEN]);
}
on_colorMagenta_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_MAGENTA);
+ process_color_activate(menuitem, COLOR_MAGENTA, predef_colors_rgba[COLOR_MAGENTA]);
}
on_colorOrange_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_ORANGE);
+ process_color_activate(menuitem, COLOR_ORANGE, predef_colors_rgba[COLOR_ORANGE]);
}
on_colorYellow_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_YELLOW);
+ process_color_activate(menuitem, COLOR_YELLOW, predef_colors_rgba[COLOR_YELLOW]);
}
on_colorWhite_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- process_color_activate(menuitem, COLOR_WHITE);
+ process_color_activate(menuitem, COLOR_WHITE, predef_colors_rgba[COLOR_WHITE]);
}
on_colorOther_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
-
+ gtk_button_clicked(GTK_BUTTON(GET_COMPONENT("buttonColorChooser")));
}
{
struct Item *it;
- if (ui.cur_mapping!=0) return;
- if (ui.toolno[0] < NUM_STROKE_TOOLS)
- g_memmove(ui.default_brushes+ui.toolno[0], &(ui.brushes[0][ui.toolno[0]]), sizeof(struct Brush));
- if (ui.toolno[0] == TOOL_TEXT) {
+ if (ui.cur_mapping!=0 && !ui.button_switch_mapping) return;
+ if (ui.toolno[ui.cur_mapping] < NUM_STROKE_TOOLS)
+ g_memmove(ui.default_brushes+ui.toolno[ui.cur_mapping],
+ &(ui.brushes[ui.cur_mapping][ui.toolno[ui.cur_mapping]]), sizeof(struct Brush));
+ if (ui.toolno[ui.cur_mapping] == TOOL_TEXT) {
if (ui.cur_item_type == ITEM_TEXT) {
g_free(ui.font_name);
ui.font_name = g_strdup(ui.cur_item->font_name);
else
active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem));
- if (ui.cur_mapping != 0) return;
- current = (ui.toolno[0] == TOOL_PEN || ui.toolno[0] == TOOL_HIGHLIGHTER) && ui.cur_brush->ruler;
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return;
+ current = (ui.toolno[ui.cur_mapping] == TOOL_PEN || ui.toolno[ui.cur_mapping] == TOOL_HIGHLIGHTER) && ui.cur_brush->ruler;
if (active == current) return;
-
+
+ ui.cur_mapping = 0;
end_text();
reset_focus();
- if (ui.toolno[0]!=TOOL_PEN && ui.toolno[0]!=TOOL_HIGHLIGHTER) {
+ if (ui.toolno[ui.cur_mapping]!=TOOL_PEN && ui.toolno[ui.cur_mapping]!=TOOL_HIGHLIGHTER) {
reset_selection();
- ui.toolno[0] = TOOL_PEN;
- ui.cur_brush = &(ui.brushes[0][TOOL_PEN]);
+ ui.toolno[ui.cur_mapping] = TOOL_PEN;
+ ui.cur_brush = &(ui.brushes[ui.cur_mapping][TOOL_PEN]);
update_color_menu();
update_tool_buttons();
update_tool_menu();
ui.cur_brush->ruler = active;
if (active) ui.cur_brush->recognizer = FALSE;
- update_mapping_linkings(ui.toolno[0]);
+ update_mapping_linkings(ui.toolno[ui.cur_mapping]);
update_ruler_indicator();
}
else
active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem));
- if (ui.cur_mapping != 0) return;
- current = (ui.toolno[0] == TOOL_PEN || ui.toolno[0] == TOOL_HIGHLIGHTER) && ui.cur_brush->recognizer;
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return;
+ current = (ui.toolno[ui.cur_mapping] == TOOL_PEN || ui.toolno[ui.cur_mapping] == TOOL_HIGHLIGHTER) && ui.cur_brush->recognizer;
if (active == current) return;
+ ui.cur_mapping = 0;
end_text();
reset_focus();
- if (ui.toolno[0]!=TOOL_PEN && ui.toolno[0]!=TOOL_HIGHLIGHTER) {
+ if (ui.toolno[ui.cur_mapping]!=TOOL_PEN && ui.toolno[ui.cur_mapping]!=TOOL_HIGHLIGHTER) {
reset_selection();
- ui.toolno[0] = TOOL_PEN;
- ui.cur_brush = &(ui.brushes[0][TOOL_PEN]);
+ ui.toolno[ui.cur_mapping] = TOOL_PEN;
+ ui.cur_brush = &(ui.brushes[ui.cur_mapping][TOOL_PEN]);
update_color_menu();
update_tool_buttons();
update_tool_menu();
ui.cur_brush->ruler = FALSE;
reset_recognizer();
}
- update_mapping_linkings(ui.toolno[0]);
+ update_mapping_linkings(ui.toolno[ui.cur_mapping]);
update_ruler_indicator();
}
on_buttonFine_clicked (GtkToolButton *toolbutton,
gpointer user_data)
{
- if (ui.cur_mapping != 0) return;
- process_thickness_activate((GtkMenuItem*)toolbutton, ui.toolno[0], THICKNESS_FINE);
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return;
+ process_thickness_activate((GtkMenuItem*)toolbutton, ui.toolno[ui.cur_mapping], THICKNESS_FINE);
}
on_buttonMedium_clicked (GtkToolButton *toolbutton,
gpointer user_data)
{
- if (ui.cur_mapping != 0) return;
- process_thickness_activate((GtkMenuItem*)toolbutton, ui.toolno[0], THICKNESS_MEDIUM);
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return;
+ process_thickness_activate((GtkMenuItem*)toolbutton, ui.toolno[ui.cur_mapping], THICKNESS_MEDIUM);
}
on_buttonThick_clicked (GtkToolButton *toolbutton,
gpointer user_data)
{
- if (ui.cur_mapping != 0) return;
- process_thickness_activate((GtkMenuItem*)toolbutton, ui.toolno[0], THICKNESS_THICK);
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return;
+ process_thickness_activate((GtkMenuItem*)toolbutton, ui.toolno[ui.cur_mapping], THICKNESS_THICK);
}
if (event->button > 3) return FALSE; // no painting with the mouse wheel!
if (event->type != GDK_BUTTON_PRESS) return FALSE;
// double-clicks may have broken axes member (free'd) due to a bug in GDK
+ if ((event->state & (GDK_CONTROL_MASK|GDK_MOD1_MASK)) != 0) return FALSE;
+ // no control-clicking or alt-clicking
if (!is_core)
fix_xinput_coords((GdkEvent *)event);
if (ui.cur_item_type == ITEM_TEXT) {
if (!is_event_within_textview(event)) end_text();
-/* // bugfix for GTK+ 2.17, no longer needed as XInput is disabled during text edition
- else fix_extended_events(ui.cur_item->widget, (GdkEvent *)event,
- gtk_text_view_get_window(GTK_TEXT_VIEW(ui.cur_item->widget), GTK_TEXT_WINDOW_TEXT));
-*/
+ else return FALSE;
}
if (ui.cur_item_type == ITEM_STROKE && ui.is_corestroke && !is_core &&
ui.cur_path.num_points == 1) {
}
if (ui.cur_item_type != ITEM_NONE) return FALSE; // we're already doing something
+ // if button_switch_mapping enabled, button 2 or 3 clicks only switch mapping
+ if (ui.button_switch_mapping && event->button > 1) {
+ if (is_core == ui.use_xinput) return FALSE; // duplicate event
+ if (ui.cur_mapping == event->button-1) switch_mapping(0);
+ else switch_mapping(event->button-1);
+ return FALSE;
+ }
+
ui.is_corestroke = is_core;
if (ui.use_erasertip && event->device->source == GDK_SOURCE_ERASER)
mapping = NUM_BUTTONS;
+ else if (ui.button_switch_mapping) mapping = ui.cur_mapping;
else mapping = event->button-1;
// check whether we're in a page
ui.cur_item_type = ITEM_NONE;
}
- switch_mapping(0);
+ if (!ui.button_switch_mapping || ui.cur_mapping == NUM_BUTTONS)
+ switch_mapping(0);
return FALSE;
}
or if there's a selection (then we might want to change the mouse
cursor to indicate the possibility of resizing) */
if (ui.cur_item_type == ITEM_NONE && ui.selection==NULL) return FALSE;
+ if (ui.cur_item_type == ITEM_TEXT) return FALSE;
is_core = (event->device == gdk_device_get_core_pointer());
if (!ui.use_xinput && !is_core) return FALSE;
}
-void
-on_optionsAntialiasBG_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- gboolean active;
-
- active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem));
- if (ui.antialias_bg == active) return;
- end_text();
- reset_focus();
- ui.antialias_bg = active;
- rescale_bg_pixmaps();
-}
-
-
void
on_optionsProgressiveBG_activate (GtkMenuItem *menuitem,
gpointer user_data)
return;
}
- if (ui.cur_mapping != 0) return;
- if (ui.toolno[0] == TOOL_HAND) return;
+ if (ui.cur_mapping != 0 && !ui.button_switch_mapping) return;
+ if (ui.toolno[ui.cur_mapping] == TOOL_HAND) return;
+ ui.cur_mapping = 0;
end_text();
reset_focus();
reset_selection();
- ui.toolno[0] = TOOL_HAND;
+ ui.toolno[ui.cur_mapping] = TOOL_HAND;
update_mapping_linkings(-1);
update_tool_buttons();
update_tool_menu();
update_mappings_menu();
}
+
+void
+on_buttonColorChooser_set (GtkColorButton *colorbutton,
+ gpointer user_data)
+{
+ GdkColor gdkcolor;
+ guint16 alpha;
+
+ gtk_color_button_get_color(colorbutton, &gdkcolor);
+ alpha = gtk_color_button_get_alpha(colorbutton);
+ process_color_activate((GtkMenuItem*)colorbutton, COLOR_OTHER, gdkcolor_to_rgba(gdkcolor, alpha));
+}
+
+
+void
+on_optionsButtonsSwitchMappings_activate(GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ end_text();
+ reset_focus();
+ switch_mapping(0);
+ ui.button_switch_mapping = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem));
+}
+