Beispiel #1
0
void ScrollView::scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll) {
  if (!scroll.isAccelerated) {
    boo::SScrollDelta newScroll = scroll;
    m_consecutiveScroll[m_consecutiveIdx][0] += scroll.delta[0];
    m_consecutiveScroll[m_consecutiveIdx][1] += scroll.delta[1];
    newScroll.delta[0] = 0;
    newScroll.delta[1] = 0;
    for (size_t i = 0; i < 16; ++i) {
      newScroll.delta[0] += m_consecutiveScroll[i][0];
      newScroll.delta[1] += m_consecutiveScroll[i][1];
    }
    if (_scroll(newScroll))
      updateSize();
    return;
  }
  if (_scroll(scroll))
    updateSize();
}
Beispiel #2
0
static void
_key_scroll(int dir, int lines)
{
  int cv = __cvisible;
  if (cv)
    _cursor(HIDE);
  _scroll(0, vtc_lines, dir, lines);
  if (cv)
    _cursor(SHOW);
}
Beispiel #3
0
void ScrollView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) {
  View::resized(root, sub);
  _scroll({});
  if (m_contentView.m_view) {
    boo::SWindowRect cRect = sub;
    cRect.location[0] += m_scroll[0];
    cRect.location[1] += sub.size[1] - m_contentView.m_view->nominalHeight() + m_scroll[1];
    cRect.size[0] = m_contentView.m_view->nominalWidth();
    cRect.size[1] = m_contentView.m_view->nominalHeight();
    m_contentView.m_scissorRect = sub;
    if (m_style == Style::SideButtons && m_drawSideButtons) {
      int width0 = m_sideButtons[0].m_view->nominalWidth() + 2;
      int width1 = m_sideButtons[1].m_view->nominalWidth();
      cRect.location[0] += width0;
      cRect.size[0] -= (width0 + width1);

      m_contentView.m_scissorRect.location[0] += width0;
      m_contentView.m_scissorRect.size[0] -= (width0 + width1);
    }
    m_contentView.m_view->resized(root, cRect, m_contentView.m_scissorRect);

    if (m_style == Style::ThinIndicator) {
      float ratio = sub.size[1] / float(cRect.size[1]);
      m_drawInd = ratio < 1.f;
      if (m_drawInd) {
        float pf = rootView().viewRes().pixelFactor();
        int barHeight = sub.size[1] * ratio;
        int scrollHeight = sub.size[1] - barHeight;
        float prog = m_scroll[1] / float(cRect.size[1] - sub.size[1]);
        int x = sub.size[0];
        int y = sub.size[1] - scrollHeight * prog;
        m_verts[0].m_pos.assign(x, y, 0);
        m_verts[1].m_pos.assign(x, y - barHeight, 0);
        m_verts[2].m_pos.assign(x + 2 * pf, y, 0);
        m_verts[3].m_pos.assign(x + 2 * pf, y - barHeight, 0);
        const zeus::CColor& color = rootView().themeData().scrollIndicator();
        for (int i = 0; i < 4; ++i)
          m_verts[i].m_color = color;
        m_vertsBinding.load<decltype(m_verts)>(m_verts);
      }
    } else if (m_style == Style::SideButtons && m_drawSideButtons) {
      boo::SWindowRect bRect = sub;
      bRect.size[0] = m_sideButtons[0].m_view->nominalWidth();
      bRect.size[1] = m_sideButtons[0].m_view->nominalHeight();
      m_sideButtons[0].m_view->resized(root, bRect);

      bRect.size[0] = m_sideButtons[1].m_view->nominalWidth();
      bRect.size[1] = m_sideButtons[1].m_view->nominalHeight();
      bRect.location[0] += sub.size[0] - bRect.size[0];
      m_sideButtons[1].m_view->resized(root, bRect);
    }
  }
}
Beispiel #4
0
static void
_nline(void)
{
  int new_sb_y = OFS_LINES(sb_y+1);
  sb_x = 0;
  
  memset(&vtc_scrbuf[new_sb_y * vtc_cols], ' ', vtc_cols);
  
  if (new_sb_y == bob)
    {
      /* scroll ring buffer one forward */
      if (bob == fline)
	_scroll(0, vtc_lines, SUP, 1);
      bob = OFS_LINES(bob+1);
    }

  sb_y = new_sb_y;
  if (sb_y == OFS_LINES(fline+vtc_lines))
    /* scroll screen one forward */
    _scroll(0, vtc_lines, SUP, 1);
}
Beispiel #5
0
 // Deal with commands that change SeqSet params
 void SeqWindow::handle_command(Command command) {
     Com com_name = command.first;
     int param = command.second;
     int newpos;
     if(com_name == SCROLLUP) {
         if(first_seq > 0) {
             newpos = first_seq - param;
             if(newpos < 0)
                 newpos = 0;
             _scroll(first_pos, newpos);
         }
     } else if(com_name == SCROLLDOWN) {
         if(first_seq < seqs.numseqs()) {
             newpos = first_seq + param;
             if(newpos >= seqs.numseqs())
                 newpos = seqs.numseqs() - 1;
             _scroll(first_pos, newpos);
         }
     } else if(com_name == SCROLLLEFT) {
         if(first_pos > 0) {
             newpos = first_pos - scrollmode * param * transl_adj;
             if(newpos < 0)
                 newpos = 0;
             _scroll(newpos, first_seq);
         }
     } else if(com_name == SCROLLRIGHT) {
         if(first_pos < seqs.length()) {
             newpos = first_pos + scrollmode * param * transl_adj;
             if(newpos >= seqs.length())
                 newpos = seqs.length() - 1;
             _scroll(newpos, first_seq);
         }
     } else if(com_name == SCROLLTOP) {
         _scroll(first_pos, 0);
     } else if(com_name == SCROLLBOTTOM) {
         _scroll(first_pos, seqs.numseqs() - 1);
     } else if(com_name == GOTOBEGIN) {
         _scroll(0, first_seq);
     } else if(com_name == GOTOEND) {
         _scroll((seqs.length() - 1), first_seq);
     } else if(com_name == GOTO) {
         newpos = param - 1 - (width - names_width) / 2;
         if(display_mode == CODON)
             newpos += (width - names_width) / 6;
         if(display_mode == TEN)
             newpos += (width - names_width) / 20;
         if(newpos < 0)
             newpos = 0;
         if(newpos > seqs.length() - 1)
             newpos = seqs.length() - 1;
         _scroll(newpos, first_seq);
     } else if(com_name == SCROLLMODE) {
         set_scroll_mode(param);
     } else if(com_name == NAMEWIDTH) {
         if(param > 0) {
             change_name_width(param);
         } else if(param == -1) {
             change_name_width(names_width-1);
         } else if(param == 0) {
             change_name_width(names_width+1);
         }
     } else if(com_name == DISPLAYMODE) {
         transl_adj = 1;
         if(param == 1) {
             display_mode = NORMAL;
         } else if(param == 2) {
             display_mode = CODON;
         } else if(param == 3) {
             display_mode = TEN;
         } else if(param == 4) {
             //first_pos /= 3;
             transl_adj = 3;
             display_mode = TRANSLATE;
         }
         modified = true;
     } else if(com_name == SETFRAME) {
         seqs.set_frame(param);
         modified = true;
     } else if(com_name == COMPARETOGGLE) {
         if(compare == NOCOMPARE) {
             compare = pcomp;
         } else {
             pcomp = compare;
             compare = NOCOMPARE;
         }
         modified = true;
     } else if(com_name == COMPARE) {
         if(param == NOCOMPARE) {
             pcomp = compare;
             compare = NOCOMPARE;
         } else {
             compare = (ComparisonMode) param;
             pcomp = (ComparisonMode) param;
         }
     } else if(com_name == TOGGLEBOLD) {
         bolded = !bolded;
         modified = true;
     }
 }
Beispiel #6
0
void scroll(void)
{
    _scroll(bios_attr,0,0,79,24);
}
Beispiel #7
0
static gboolean _key_release_event(GtkWidget   *widget,
                                  GdkEventKey *event,
                                  gpointer     data)
{
    (void)widget;
    (void)data;

    //*
    switch(event->keyval) {
        case GDK_Left  :
        case GDK_Right :
        case GDK_Up    :
        case GDK_Down  :_scroll(event);            break;

        case GDK_equal :
        case GDK_plus  :
        case GDK_minus :_rotation(event);          break;

        case GDK_Page_Down:
        case GDK_Page_Up:_zoom(event);             break;


     //   case GDK_KEY_Escape:_resetView(&_engine.state);                break;
        case GDK_r     : //gtk_widget_draw(widget, NULL);
                              break;
     //   case GDK_KEY_h     :_doRenderHelp = !_doRenderHelp;
     //                   _usage("s52gtk2");
     //                   break;
        case GDK_v     :g_print("%s\n", S52_version());    break;
        case GDK_x     :_dumpParam();                      break;
        case GDK_q     :gtk_main_quit();                   break;

        case GDK_w     :_toggle(S52_MAR_TWO_SHADES);       break;
        case GDK_s     :_toggle(S52_MAR_SHALLOW_PATTERN);  break;
        case GDK_o     :_toggle(S52_MAR_SHIPS_OUTLINE);    break;
        case GDK_l     :_toggle(S52_MAR_FULL_SECTORS);     break;
        case GDK_b     :_toggle(S52_MAR_SYMBOLIZED_BND);   break;
        case GDK_p     :_toggle(S52_MAR_SYMPLIFIED_PNT);   break;
        case GDK_n     :_toggle(S52_MAR_FONT_SOUNDG);      break;
        case GDK_u     :_toggle(S52_MAR_SCAMIN);           break;
        case GDK_i     :_toggle(S52_MAR_ANTIALIAS);        break;
        case GDK_j     :_toggle(S52_MAR_QUAPNT01);         break;
        case GDK_z     :_toggle(S52_MAR_DISP_OVERLAP);     break;
        //case GDK_1     :_toggle(S52_MAR_DISP_LAYER_LAST);  break;
        case GDK_1     :_meterInc(S52_MAR_DISP_LAYER_LAST);break;
        case GDK_exclam:_meterDec(S52_MAR_DISP_LAYER_LAST);break;

        case GDK_2     :_inc(S52_MAR_ROT_BUOY_LIGHT);      break;

        case GDK_3     :_toggle(S52_MAR_DISP_CRSR_POS);
                        _toggle(S52_MAR_DISP_LEGEND);
                        _toggle(S52_MAR_DISP_CALIB);
                        _toggle(S52_MAR_DISP_DRGARE_PATTERN);
                        break;

        case GDK_4     :_toggle(S52_MAR_DISP_GRATICULE);   break;
        case GDK_5     :_toggle(S52_MAR_HEADNG_LINE);      break;

        //case GDK_t     :_meterInc(S52_MAR_SHOW_TEXT);      break;
        //case GDK_T     :_meterDec(S52_MAR_SHOW_TEXT);      break;
        case GDK_t     :
        case GDK_T     :_toggle  (S52_MAR_SHOW_TEXT);      break;
        case GDK_c     :_meterInc(S52_MAR_SAFETY_CONTOUR); break;
        case GDK_C     :_meterDec(S52_MAR_SAFETY_CONTOUR); break;
        case GDK_d     :_meterInc(S52_MAR_SAFETY_DEPTH);   break;
        case GDK_D     :_meterDec(S52_MAR_SAFETY_DEPTH);   break;
        case GDK_a     :_meterInc(S52_MAR_SHALLOW_CONTOUR);break;
        case GDK_A     :_meterDec(S52_MAR_SHALLOW_CONTOUR);break;
        case GDK_e     :_meterInc(S52_MAR_DEEP_CONTOUR);   break;
        case GDK_E     :_meterDec(S52_MAR_DEEP_CONTOUR);   break;
        case GDK_f     :_meterInc(S52_MAR_DISTANCE_TAGS);  break;
        case GDK_F     :_meterDec(S52_MAR_DISTANCE_TAGS);  break;
        case GDK_g     :_meterInc(S52_MAR_TIME_TAGS);      break;
        case GDK_G     :_meterDec(S52_MAR_TIME_TAGS);      break;
        case GDK_y     :_meterInc(S52_MAR_BEAM_BRG_NM);    break;
        case GDK_Y     :_meterDec(S52_MAR_BEAM_BRG_NM);    break;
        case GDK_m     :_meterInc(S52_MAR_DATUM_OFFSET);   break;
        case GDK_M     :_meterDec(S52_MAR_DATUM_OFFSET);   break;

        //case GDK_7     :_disp(S52_MAR_DISP_CATEGORY, 'D'); break; // DISPLAYBASE
        //case GDK_8     :_disp(S52_MAR_DISP_CATEGORY, 'S'); break; // STANDARD
        //case GDK_9     :_disp(S52_MAR_DISP_CATEGORY, 'O'); break; // OTHER
        //case GDK_0     :_disp(S52_MAR_DISP_CATEGORY, 'A'); break; // OTHER (all)
        //case GDK_7     :_disp(S52_MAR_DISP_CATEGORY, 0);   break; // DISPLAYBASE
        //case GDK_8     :_disp(S52_MAR_DISP_CATEGORY, 1);   break; // STANDARD
        //case GDK_9     :_disp(S52_MAR_DISP_CATEGORY, 2);   break; // OTHER
        //case GDK_0     :_disp(S52_MAR_DISP_CATEGORY, 3);   break; // OTHER (all)
        case GDK_7     :_disp(S52_MAR_DISP_CATEGORY, S52_MAR_DISP_CATEGORY_BASE);   break; // DISPLAYBASE
        case GDK_8     :_disp(S52_MAR_DISP_CATEGORY, S52_MAR_DISP_CATEGORY_STD);    break; // STANDARD
        case GDK_9     :_disp(S52_MAR_DISP_CATEGORY, S52_MAR_DISP_CATEGORY_OTHER);  break; // OTHER
        case GDK_0     :_disp(S52_MAR_DISP_CATEGORY, S52_MAR_DISP_CATEGORY_SELECT); break; // OTHER (all)

        case GDK_k     :_cpal(S52_MAR_COLOR_PALETTE,  1.0);break;
        case GDK_K     :_cpal(S52_MAR_COLOR_PALETTE, -1.0);break;

        case GDK_6     :_meterInc(S52_MAR_DISP_WHOLIN);    break;
        case GDK_asciicircum:
        case GDK_question:
        case GDK_caret :_meterDec(S52_MAR_DISP_WHOLIN);    break;


        //case GDK_3     :_cpal("S52_MAR_COLOR_PALETTE", 2.0); break; // DAY_WHITEBACK
        //case GDK_4     :_cpal("S52_MAR_COLOR_PALETTE", 3.0); break; // DUSK
        //case GDK_5     :_cpal("S52_MAR_COLOR_PALETTE", 4.0); break; // NIGHT

        //case GDK_F1    :S52_doneCell("/home/vitaly/CHARTS/for_sasha/GB5X01SE.000"); break;
        //case GDK_F2    :S52_doneCell("/home/vitaly/CHARTS/for_sasha/GB5X01NE.000"); break;
        case GDK_F1    :S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_SY); break;
        case GDK_F2    :S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_LS); break;
        case GDK_F3    :S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_LC); break;
        case GDK_F4    :S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_AC); break;
        case GDK_F5    :S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_AP); break;
        case GDK_F6    :S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_TX); break;

        case GDK_F7    :_mmInc(S52_MAR_DOTPITCH_MM_X); break;
        case GDK_F8    :_mmInc(S52_MAR_DOTPITCH_MM_Y); break;

        case GDK_F9    :_toggle(S52_MAR_DISP_NODATA_LAYER); break;

        default:
            g_print("key: 0x%04x\n", event->keyval);
    }
    //*/

    // redraw
    _engine.do_S52draw = TRUE;

    return TRUE;
}
Beispiel #8
0
void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {

	if (p_event->is_action("ui_down") && p_event->is_pressed()) {

		int search_from = mouse_over + 1;
		if (search_from >= items.size())
			search_from = 0;

		for (int i = search_from; i < items.size(); i++) {

			if (i < 0 || i >= items.size())
				continue;

			if (!items[i].separator && !items[i].disabled) {

				mouse_over = i;
				emit_signal("id_focused", i);
				update();
				accept_event();
				break;
			}
		}
	} else if (p_event->is_action("ui_up") && p_event->is_pressed()) {

		int search_from = mouse_over - 1;
		if (search_from < 0)
			search_from = items.size() - 1;

		for (int i = search_from; i >= 0; i--) {

			if (i < 0 || i >= items.size())
				continue;

			if (!items[i].separator && !items[i].disabled) {

				mouse_over = i;
				emit_signal("id_focused", i);
				update();
				accept_event();
				break;
			}
		}
	} else if (p_event->is_action("ui_left") && p_event->is_pressed()) {

		Node *n = get_parent();
		if (n && Object::cast_to<PopupMenu>(n)) {
			hide();
			accept_event();
		}
	} else if (p_event->is_action("ui_right") && p_event->is_pressed()) {

		if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator && items[mouse_over].submenu != "" && submenu_over != mouse_over) {
			_activate_submenu(mouse_over);
			accept_event();
		}
	} else if (p_event->is_action("ui_accept") && p_event->is_pressed()) {

		if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator) {

			if (items[mouse_over].submenu != "" && submenu_over != mouse_over) {
				_activate_submenu(mouse_over);
			} else {
				activate_item(mouse_over);
			}
			accept_event();
		}
	}

	Ref<InputEventMouseButton> b = p_event;

	if (b.is_valid()) {

		if (b->is_pressed())
			return;

		int button_idx = b->get_button_index();
		switch (button_idx) {

			case BUTTON_WHEEL_DOWN: {

				if (get_global_position().y + get_size().y > get_viewport_rect().size.y) {
					_scroll(-b->get_factor(), b->get_position());
				}
			} break;
			case BUTTON_WHEEL_UP: {

				if (get_global_position().y < 0) {
					_scroll(b->get_factor(), b->get_position());
				}
			} break;
			default: {
				// Allow activating item by releasing the LMB or any that was down when the popup appeared
				if (button_idx == BUTTON_LEFT || (initial_button_mask & (1 << (button_idx - 1)))) {

					bool was_during_grabbed_click = during_grabbed_click;
					during_grabbed_click = false;

					int over = _get_mouse_over(b->get_position());

					if (invalidated_click) {
						invalidated_click = false;
						break;
					}
					if (over < 0) {
						if (!was_during_grabbed_click) {
							hide();
						}
						break; //non-activable
					}

					if (items[over].separator || items[over].disabled)
						break;

					if (items[over].submenu != "") {

						_activate_submenu(over);
						return;
					}
					activate_item(over);
				}
			}
		}

		//update();
	}

	Ref<InputEventMouseMotion> m = p_event;

	if (m.is_valid()) {

		if (invalidated_click) {
			moved += m->get_relative();
			if (moved.length() > 4)
				invalidated_click = false;
		}

		for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) {

			if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E->get().has_point(m->get_position())) {
				call_deferred("hide");
				return;
			}
		}

		int over = _get_mouse_over(m->get_position());
		int id = (over < 0 || items[over].separator || items[over].disabled) ? -1 : (items[over].ID >= 0 ? items[over].ID : over);

		if (id < 0) {
			mouse_over = -1;
			update();
			return;
		}

		if (items[over].submenu != "" && submenu_over != over) {
			submenu_over = over;
			submenu_timer->start();
		}

		if (over != mouse_over) {
			mouse_over = over;
			update();
		}
	}

	Ref<InputEventPanGesture> pan_gesture = p_event;
	if (pan_gesture.is_valid()) {
		if (get_global_position().y + get_size().y > get_viewport_rect().size.y || get_global_position().y < 0) {
			_scroll(-pan_gesture->get_delta().y, pan_gesture->get_position());
		}
	}
}
void scroll(void)
{
    _scroll(curr_attr, view_window.x1, view_window.y1, view_window.x2,
    	view_window.y2);
}