プロジェクト

全般

プロフィール

提案 #1381 » 0001-「上にスクロール」「下にスクロール」コマンドを実装.patch

Yuto Tokunaga, 2019-09-15 15:53

差分を表示:

core/mui/cairo_inner_tl.rb
111 111
      options[:postboxstorage] = postbox end
112 112
    create_postbox(options) end
113 113

  
114
  def set_cursor_to_display_top
115
    iter = model.iter_first
116
    set_cursor(iter.path, get_column(0), false) if iter end
117

  
118 114
  def get_active_messages
119 115
    get_active_iterators.map{ |iter| iter[1] } end
120 116

  
core/plugin/command/command.rb
295 295
          condition: :itself.to_proc,
296 296
          visible: false,
297 297
          role: :timeline) do |opt|
298
    opt.widget.scroll_to_top end
298
    Plugin.call :gui_timeline_scroll, opt.widget, :top
299
  end
300

  
301
  command(:scroll_up,
302
          name: _('上にスクロール'),
303
          condition: :itself.to_proc,
304
          visible: false,
305
          role: :timeline) do |opt|
306
    Plugin.call :gui_timeline_scroll, opt.widget, :up
307
  end
308

  
309
  command(:scroll_down,
310
          name: _('下にスクロール'),
311
          condition: :itself.to_proc,
312
          visible: false,
313
          role: :timeline) do |opt|
314
    Plugin.call :gui_timeline_scroll, opt.widget, :down
315
  end
299 316

  
300 317
  # フォーカスを _widget_ から _distance_ に移動する
301 318
  # ==== Args
core/plugin/gtk/gtk.rb
305 305
    if timeline
306 306
      timeline.clear end end
307 307

  
308
  on_gui_timeline_scroll_to_top do |i_timeline|
309
    timeline = widgetof(i_timeline)
310
    if timeline
311
      timeline.set_cursor_to_display_top end end
308
  on_gui_timeline_scroll do |i_timeline, msg|
309
    tl = widgetof(i_timeline) or next
310

  
311
    case msg
312
    when :top
313
      iter = tl.model.iter_first or next
314
      tl.set_cursor iter.path, nil, false
315

  
316
    when :up
317
      rect = tl.visible_rect
318
      x, y = tl.convert_tree_to_bin_window_coords rect.x, rect.y
319
      path, _, _, _ = tl.get_path x, y
320
      path or next
321
      tl.set_cursor path, nil, false
322
      tl.scroll_to_cell path, nil, true, 1, 0
323

  
324
    when :down
325
      rect = tl.visible_rect
326
      x, y = tl.convert_tree_to_bin_window_coords rect.x, rect.y + rect.height
327
      path, _, _, _ = tl.get_path x, y
328
      path or next
329
      tl.set_cursor path, nil, false
330
      tl.scroll_to_cell path, nil, true, 0, 0
331
    end
332
  end
312 333

  
313 334
  on_gui_timeline_move_cursor_to do |i_timeline, message|
314 335
    tl = widgetof(i_timeline)
    (1-1/1)