module Gdk::IconOverButton

アイコン上にボタンを表示するためのモジュール

Attributes

current_icon_pos[RW]

Public Instance Methods

_schemer() click to toggle source
# File core/mui/cairo_icon_over_button.rb, line 11
def _schemer
  {x_count: 2, y_count: 2} end
get_icon_rectangle(ipx, ipy) click to toggle source
# File core/mui/cairo_icon_over_button.rb, line 20
def get_icon_rectangle(ipx, ipy)
  w, h = pos.main_icon.width / _schemer[:x_count], pos.main_icon.height / _schemer[:y_count]
  Gdk::Rectangle.new(w * ipx, h * ipy, w, h)
end
globalpos2iconpos(gx, gy) click to toggle source
# File core/mui/cairo_icon_over_button.rb, line 25
def globalpos2iconpos(gx, gy)
  lx, ly = gx - pos.main_icon.x, gy - pos.main_icon.y
  w, h = pos.main_icon.width / _schemer[:x_count], pos.main_icon.height / _schemer[:y_count]
  ipx, ipy = (lx / w).to_i, (ly / h).to_i
  if ipx >= 0 and ipx < _schemer[:x_count] and ipy >= 0 and ipy < _schemer[:y_count]
    [ipx, ipy]
  else
    nil end end
index2point(index) click to toggle source

アイコンインデックスからアイコンの左上座標を計算する

# File core/mui/cairo_icon_over_button.rb, line 15
def index2point(index)
  x, y = _schemer[:x_count], _schemer[:y_count]
  (index / y)*x + index % x
end
iob_clicked(gx, gy) click to toggle source

icon over buttonがクリックされたことを通知する

Args

gx

MiraclePainter全体から見たx座標

gy

MiraclePainter全体から見たy座標

# File core/mui/cairo_icon_over_button.rb, line 77
def iob_clicked(gx, gy)
  icon_position = globalpos2iconpos(gx, gy)
  return if message.system?
  if icon_position
    __send__([ [:iob_reply_clicked, :iob_etc_clicked],
               [:iob_retweet_clicked, :iob_fav_clicked]][icon_position[0]][icon_position[1]]) end end
iob_main_leave() click to toggle source

icon over buttonからマウスポインタが離れたときに呼ぶ。

# File core/mui/cairo_icon_over_button.rb, line 68
def iob_main_leave
  if(current_icon_pos)
    @current_icon_pos = nil
    on_modify end end
point_moved_main_icon(gx, gy) click to toggle source

アイコン上でマウスポインタが動いた時に呼ぶ。

  • gx MiraclePainter全体から見たx座標

  • _gy_MiraclePainter 全体から見たy座標

# File core/mui/cairo_icon_over_button.rb, line 58
def point_moved_main_icon(gx, gy)
  icon_position = globalpos2iconpos(gx, gy)
  if icon_position
    if current_icon_pos != icon_position
      on_modify
      @current_icon_pos = icon_position end
  else
    iob_main_leave end end
render_icon_over_button(context) click to toggle source

context にicon over buttonを描画する。

# File core/mui/cairo_icon_over_button.rb, line 35
def render_icon_over_button(context)
  context.save{
    context.translate(pos.main_icon.x, pos.main_icon.y)
    _schemer[:y_count].times{ |posy|
      _schemer[:x_count].times{ |posx|
        pos = [posx, posy]
        ir = get_icon_rectangle(*pos)
        icon_file_name = (current_icon_pos ? iob_icon_pixbuf : iob_icon_pixbuf_off)[posx][posy]
        if(icon_file_name)
          if(current_icon_pos)
            context.save{
              pb_filename = current_icon_pos == pos ? 'overbutton_mouseover.png' : 'overbutton.png'
              context.translate(ir.x, ir.y)
              context.set_source_pixbuf(Skin[pb_filename].pixbuf(width: ir.width, height: ir.height))
              context.paint } end
          context.save{
            context.translate(ir.x, ir.y)
            context.set_source_pixbuf(Skin[icon_file_name].pixbuf(width: ir.width, height: ir.height))
            context.paint } end } } } end