bool RegionChooser::on_button_press_event(GdkEventButton* event) { if (!instrument) return true; const int k = int(event->x / (get_width() - 1) * 128.0); if (event->type == GDK_BUTTON_PRESS) { if (event->y >= REGION_BLOCK_HEIGHT) { int velocity = (event->y >= REGION_BLOCK_HEIGHT + KEYBOARD_HEIGHT - 1) ? 127 : int(float(event->y - REGION_BLOCK_HEIGHT) / float(KEYBOARD_HEIGHT) * 128.0f) + 1; currentActiveKey = k; keyboard_key_hit_signal.emit(k, velocity); } } if (event->y >= REGION_BLOCK_HEIGHT) return true; if (event->type == GDK_BUTTON_PRESS && event->button == 3) { gig::Region* r = get_region(k); if (r) { region = r; queue_draw(); region_selected(); dimensionManager.set_region(region); popup_menu_inside_region->popup(event->button, event->time); } else { new_region_pos = k; popup_menu_outside_region->popup(event->button, event->time); } } else { if (is_in_resize_zone(event->x, event->y)) { get_window()->pointer_grab(false, Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK, Gdk::Cursor(Gdk::SB_H_DOUBLE_ARROW), event->time); resize.active = true; } else { gig::Region* r = get_region(k); if (r) { region = r; queue_draw(); region_selected(); dimensionManager.set_region(region); get_window()->pointer_grab(false, Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK, Gdk::Cursor(Gdk::FLEUR), event->time); move.active = true; move.from_x = event->x; move.pos = 0; } } } return true; }
bool Render::on_motion_notify_event(GdkEventMotion* event) { bool redraw=true; Vector2f dragp(event->x, event->y); Vector2f delta = m_downPoint - dragp; double factor = 0.3; Vector3d delta3f(-delta.x*factor, delta.y*factor, 0); get_model()->setMeasuresPoint(Vector2d((10.+event->x)/(get_width()-20), (10.+get_height()-event->y)/(get_height()-20))); if (event->state & GDK_BUTTON1_MASK) { // move or rotate if (event->state & GDK_SHIFT_MASK) { // move object if (false);//delta3f.x<1 && delta3f.y<1) redraw=false; else { Shape *shape; TreeObject *object; if (!m_view->get_selected_stl(object, shape)) return true; if (!object && !shape) return true; Transform3D *transf; if (!shape) transf = &object->transform3D; else transf = &shape->transform3D; transf->move(delta3f); m_downPoint = dragp; //m_view->get_model()->CalcBoundingBoxAndCenter(); } } else { // rotate m_arcBall->dragAccumulate(event->x, event->y, &m_transform); } if (redraw) queue_draw(); return true; } else { if (event->state & GDK_BUTTON2_MASK) { // zoom double factor = 1.0 + 0.01 * (delta.x - delta.y); m_zoom *= factor; } else if (event->state & GDK_BUTTON3_MASK) { // pan Matrix4f matrix; memcpy(&matrix.m00, &m_transform.M[0], sizeof(Matrix4f)); Vector3f m_transl = matrix.getTranslation(); m_transl += delta3f; matrix.setTranslation(m_transl); memcpy(&m_transform.M[0], &matrix.m00, sizeof(Matrix4f)); } m_downPoint = dragp; if (redraw) queue_draw(); return true; } return Gtk::DrawingArea::on_motion_notify_event (event); }
static gint gtk_hex_entry_motion (GtkWidget *widget, GdkEventMotion *event) { GtkHexEntry *hex_entry; gint x; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_HEX_ENTRY (widget), FALSE); hex_entry = GTK_HEX_ENTRY (widget); if (hex_entry->button == 0) return FALSE; x = event->x; if (event->is_hint || (widget->window != event->window)) gdk_window_get_pointer (widget->window, &x, NULL, NULL); hex_entry->cursor_position = x / gdk_char_width (hex_entry->font,'0'); hex_entry->selection_end_pos = hex_entry->cursor_position; if (hex_entry->selection_end_pos < hex_entry->selection_start_pos) { hex_entry->selection_end_pos = hex_entry->selection_start_pos; hex_entry->selection_start_pos = hex_entry->cursor_position; } queue_draw (hex_entry); return TRUE; }
/** Set graph. * @param graph string representation of the current graph in the dot language. */ void SkillGuiGraphDrawingArea::set_graph(std::string graph) { if ( __update_graph ) { __graph_dot = graph; layout_graph(); queue_draw(); } else { __nonupd_graph = graph; } if ( __recording ) { char *tmp; timespec t; if (clock_gettime(CLOCK_REALTIME, &t) == 0) { struct tm tms; localtime_r(&t.tv_sec, &tms); if ( asprintf(&tmp, "%s/%s_%04i%02i%02i-%02i%02i%02i.%09li.dot", __record_directory.c_str(), __graph_fsm.c_str(), tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday, tms.tm_hour, tms.tm_min, tms.tm_sec, t.tv_nsec) != -1) { //printf("Would record to filename %s\n", tmp); save_dotfile(tmp); free(tmp); } else { printf("Warning: Could not create file name for recording, skipping graph\n"); } } else { printf("Warning: Could not time recording, skipping graph\n"); } } }
void perfroll::update_sizes () { int h_bars = m_roll_length_ticks / (m_ticks_per_bar); int h_bars_visible = (m_window_x * m_perf_scale_x) / (m_ticks_per_bar); int h_max_value = h_bars - h_bars_visible; m_hadjust.set_lower(0); m_hadjust.set_upper(h_bars); m_hadjust.set_page_size(h_bars_visible); m_hadjust.set_step_increment(1); m_hadjust.set_page_increment(1); if (m_hadjust.get_value() > h_max_value) m_hadjust.set_value(h_max_value); m_vadjust.set_lower(0); m_vadjust.set_upper(m_sequence_max); m_vadjust.set_page_size(m_window_y / m_names_y); m_vadjust.set_step_increment(1); m_vadjust.set_page_increment(1); int v_max_value = m_sequence_max - (m_window_y / m_names_y); if (m_vadjust.get_value() > v_max_value) m_vadjust.set_value(v_max_value); if (is_realized()) m_pixmap = Gdk::Pixmap::create(m_window, m_window_x, m_window_y, -1); queue_draw(); }
bool Terminal::on_my_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) { int width = get_width(); int height = get_height(); int from_center_x = x - width/2; int from_center_y = y - height/2; if (ABS(from_center_x) > ABS(from_center_y)) if (from_center_x > 0) dock_pos = Gtk::POS_RIGHT; else dock_pos = Gtk::POS_LEFT; else if (from_center_y > 0) dock_pos = Gtk::POS_BOTTOM; else dock_pos = Gtk::POS_TOP; switch (dock_pos) { case Gtk::POS_TOP: dock_hint = GdkRectangle{0, 0, width, height/2}; break; case Gtk::POS_LEFT: dock_hint = GdkRectangle{0, 0, width/2, height}; break; case Gtk::POS_RIGHT: dock_hint = GdkRectangle{width/2, 0, width/2, height}; break; case Gtk::POS_BOTTOM: dock_hint = GdkRectangle{0, height/2, width, height/2}; } queue_draw(); }
bool Terminal::on_my_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) { dock_hint = GdkRectangle{0, 0, 0, 0}; queue_draw(); if (dock_from == this) { return FALSE; } Frame *old_frame = static_cast<Frame *>(dock_from->get_parent()); switch (dock_pos) { case GTK_POS_TOP: manage(new Splitter(get_parent(), dock_from, this, Gtk::ORIENTATION_VERTICAL)); break; case GTK_POS_BOTTOM: manage(new Splitter(get_parent(), this, dock_from, Gtk::ORIENTATION_VERTICAL)); break; case GTK_POS_LEFT: manage(new Splitter(get_parent(), dock_from, this, Gtk::ORIENTATION_HORIZONTAL)); break; case GTK_POS_RIGHT: manage(new Splitter(get_parent(), this, dock_from, Gtk::ORIENTATION_HORIZONTAL)); } old_frame->destroy(); static_cast<TerminalWindow *>(this->get_toplevel())->present(); dock_from->focus_vte(); }
static RobWidget* m2_mouseup(RobWidget* handle, RobTkBtnEvent *event) { MF2UI* ui = (MF2UI*)GET_HANDLE(handle); ui->drag_cutoff_x = -1; ui->update_annotations = true; queue_draw(ui->m2); return NULL; }
void knob::set_value(float _value) { if (invert) { value = max - _value; } else { value = _value; } if (min > max && max >=0) { knob_value = value / (min-max); } if (min > max && max <0) { knob_value = (value / (min - max)) + 0.5; } if (min <= max && min >=0) { knob_value = value / (max-min); } if (min <= max && min <0) { knob_value = (value / (max - min)) + 0.5; } queue_draw(); }
bool Simple_GOL_Area::on_button_press_event(GdkEventButton* event) { if(event->type == GDK_BUTTON_PRESS) { if(event->button == 1) { Gtk::Allocation allocation = get_allocation(); int item_x = int(sim_data->get_width()*event->x/allocation.get_width()); int item_y = int(sim_data->get_height()*event->y/allocation.get_height()); std::cout << item_x << " " << item_y << "\n"; mouse_button_one_down = (sim_data->get(item_x, item_y)+1)%2 + 1; sim_data->set(item_x, item_y, (sim_data->get(item_x, item_y)+1)%2); queue_draw(); } else if(event->button == 3) { pause_toggle(); } } return true; }
/** Button release event handler. * @param event event data * @return true */ bool SkillGuiGraphDrawingArea::on_button_release_event(GdkEventButton *event) { __mouse_motion = false; queue_draw(); return true; }
void perftime::set_guides( int a_snap, int a_measure ) { m_snap = a_snap; m_measure_length = a_measure; queue_draw(); }
bool perftime::on_button_press_event(GdkEventButton* p0) { long tick = (long) p0->x; tick *= m_perf_scale_x; //tick = tick - (tick % (c_ppqn * 4)); tick += (m_4bar_offset * 16 * c_ppqn); tick = tick - (tick % m_snap); //if ( p0->button == 2 ) //m_mainperf->set_start_tick( tick ); if ( p0->button == 1 ) { m_mainperf->set_left_tick( tick ); } if ( p0->button == 3 ) { m_mainperf->set_right_tick( tick + m_snap ); } queue_draw(); return true; }
static gint gtk_hex_entry_button_release (GtkWidget *widget, GdkEventButton *event) { GtkHexEntry *hex_entry; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_HEX_ENTRY (widget), FALSE); hex_entry = GTK_HEX_ENTRY (widget); if (hex_entry->button != event->button) return FALSE; if (event->button == 1) { gtk_grab_remove (widget); hex_entry->has_selection = FALSE; if (hex_entry->selection_start_pos != hex_entry->selection_end_pos) { hex_entry->has_selection = TRUE; } } queue_draw (hex_entry); return FALSE; }
/** Open a dot graph and display it. */ void SkillGuiGraphDrawingArea::open() { Gtk::Window *w = dynamic_cast<Gtk::Window *>(get_toplevel()); __fcd_open->set_transient_for(*w); int result = __fcd_open->run(); if (result == Gtk::RESPONSE_OK) { __update_graph = false; __graph_dot = ""; char *basec = strdup(__fcd_open->get_filename().c_str()); char *basen = basename(basec); __graph_fsm = basen; free(basec); FILE *f = fopen(__fcd_open->get_filename().c_str(), "r"); while (! feof(f)) { char tmp[4096]; size_t s; if ((s = fread(tmp, 1, 4096, f)) > 0) { __graph_dot.append(tmp, s); } } fclose(f); __signal_update_disabled.emit(); queue_draw(); } __fcd_open->hide(); }
static void gtk_hex_entry_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkHexEntry *hex_entry; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_HEX_ENTRY (widget)); g_return_if_fail (allocation != NULL); widget->allocation = *allocation; hex_entry = GTK_HEX_ENTRY (widget); if (GTK_WIDGET_REALIZED (widget)) { GtkRequisition requisition; gtk_widget_get_child_requisition (widget, &requisition); gdk_window_move_resize (widget->window, allocation->x, allocation->y, requisition.width, requisition.height); queue_draw (hex_entry); } }
static void m2_leave(RobWidget *handle) { MF2UI* ui = (MF2UI*)GET_HANDLE(handle); if (ui->prelight_cutoff) { ui->prelight_cutoff = false; ui->update_annotations = true; queue_draw(ui->m2); } }
void CWRuler::setUpper(float theUpper) { if (theUpper != _myUpper) { _myUpper = theUpper; _myUpperChangedSignal.emit(_myUpper); } queue_draw(); }
void CWRuler::setWindowWidth(float theWidth) { if (theWidth != _myWindowWidth) { _myWindowWidth = theWidth; _myWidthChangedSignal.emit(_myWindowWidth); } queue_draw(); }
void CWRuler::setWindowCenter(float theCenter) { if (theCenter != _myWindowCenter) { _myWindowCenter = theCenter; _myCenterChangedSignal.emit(_myWindowCenter); } queue_draw(); }
static RobWidget* m2_mousedown(RobWidget* handle, RobTkBtnEvent *event) { MF2UI* ui = (MF2UI*)GET_HANDLE(handle); if (event->state & ROBTK_MOD_SHIFT) { ui->db_cutoff = -45; ui->update_annotations = true; queue_draw(ui->m2); return NULL; } ui->drag_cutoff_db = ui->db_cutoff; ui->drag_cutoff_x = event->x; ui->update_annotations = true; queue_draw(ui->m2); return handle; }
void Simple_GOL_Area::tick() { if(running) { sim_data->itterate_under_conway(); queue_draw(); } }
void seqkeys::on_size_allocate (Gtk::Allocation & a_r) { Gtk::DrawingArea::on_size_allocate(a_r); m_window_x = a_r.get_width(); m_window_y = a_r.get_height(); queue_draw(); }
bool CWRuler::on_motion_notify_event(GdkEventMotion * theEvent) { if ( _myState != IDLE) { float myValue = convertScreenPosToValue(int(theEvent->x)); if (_myMode == MODE_LOWER_UPPER) { switch (_myState) { case CHANGE_WIDTH_LEFT: myValue = min(max(myValue, _myValueRange[0]), _myUpper - MIN_WINDOW_WIDTH); if (myValue != _myLower) { _myLower = myValue; _myLowerChangedSignal.emit(_myLower); } break; case CHANGE_WIDTH_RIGHT: myValue = max(min(myValue, _myValueRange[1]), _myLower + MIN_WINDOW_WIDTH); if (myValue != _myUpper) { _myUpper = myValue; _myUpperChangedSignal.emit(_myUpper); } break; case IDLE: case CHANGE_CENTER: break; } } else { switch (_myState) { case CHANGE_CENTER: myValue = min(max(myValue, _myValueRange[0]), _myValueRange[1]); if (myValue != _myWindowCenter) { _myWindowCenter = myValue; _myCenterChangedSignal.emit(_myWindowCenter); } break; case CHANGE_WIDTH_LEFT: myValue = max(min(2.0f * (_myWindowCenter - myValue), 2.0f * (_myWindowCenter - _myValueRange[0])), MIN_WINDOW_WIDTH); if (myValue != _myWindowWidth) { _myWindowWidth = myValue; _myWidthChangedSignal.emit(_myWindowWidth); } break; case CHANGE_WIDTH_RIGHT: myValue = max(min(2.0f * (myValue - _myWindowCenter), 2.0f *(_myValueRange[1] - _myWindowCenter)), MIN_WINDOW_WIDTH); if (myValue != _myWindowWidth) { _myWindowWidth = myValue; _myWidthChangedSignal.emit(_myWindowWidth); } break; case IDLE: break; } } queue_draw(); } return true; }
void RegionChooser::set_instrument(gig::Instrument* instrument) { this->instrument = instrument; regions.update(instrument); region = regions.first(); queue_draw(); region_selected(); dimensionManager.set_region(region); }
void perfroll::change_horz () { if (m_4bar_offset != int(m_hadjust.get_value())) { m_4bar_offset = int(m_hadjust.get_value()); queue_draw(); } }
void perfroll::change_horz() { if ( m_4bar_offset != (int) m_hadjust->get_value() ) { m_4bar_offset = (int) m_hadjust->get_value(); queue_draw(); } }
void perfroll::change_vert () { if (m_sequence_offset != int(m_vadjust.get_value())) { m_sequence_offset = int(m_vadjust.get_value()); queue_draw(); } }
void View::delete_selected_stl() { if (m_rfo_tree->get_selection()->count_selected_rows() <= 0) return; Gtk::TreeModel::iterator iter = m_rfo_tree->get_selection()->get_selected(); m_model->rfo.DeleteSelected (iter); m_rfo_tree->expand_all(); queue_draw(); }
void View::rotate_selection (Vector4f rotate) { RFO_File *file; RFO_Object *object; get_selected_stl (object, file); m_model->RotateObject (file, object, rotate); queue_draw(); }