查看: 2372|回复: 5

[已经解决] rect的意义

[复制链接]
梦石
0
星屑
49
在线时间
157 小时
注册时间
2013-8-14
回帖
155
发表于 2014-8-6 10:41:48 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
[pre lang="ruby" line="1"]  #--------------------------------------------------------------------------
  # ● 获取项目的绘制矩形
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = item_width
    rect.height = item_height
    rect.x = index % col_max * (item_width + spacing)
    rect.y = index / col_max * item_height
    rect
  end
[/pre]


rect不是实例吗?
怎么变方法了...

另外
cursor_rect 是内建的吗?

还有
page_item_max这啥?
也是内建的方法?

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-8-6 10:50:29 | 显示全部楼层
  1. rect = Rect.new # rect明明是一个局部变量
复制代码
cursor_rect 是内建方法,在F1手册中可以找到
page_item_max 不是内建方法,你可以用 ctrl+shift+F 全局搜索找到

评分

参与人数 1星屑 +150 收起 理由
VIPArcher + 150 我很赞同

查看全部评分

回复

使用道具 举报

梦石
0
星屑
68
在线时间
585 小时
注册时间
2013-5-25
回帖
1484
发表于 2014-8-6 10:53:04 | 显示全部楼层
末句rect是返回rect这个对象
相当于先前版本的return rect
剩下俩自己字面理解okay?

点评

谢谢  发表于 2014-8-6 11:04

评分

参与人数 1星屑 +150 收起 理由
VIPArcher + 150 OK....

查看全部评分

回复

使用道具 举报

梦石
0
星屑
49
在线时间
157 小时
注册时间
2013-8-14
回帖
155
 楼主| 发表于 2014-8-6 11:03:57 | 显示全部楼层
taroxd 发表于 2014-8-6 10:50
cursor_rect 是内建方法,在F1手册中可以找到
page_item_max 不是内建方法,你可以用 ctrl+shift+F 全局搜 ...

打错是page_row_max

点评

搜索全文,我没有找到 cursor_rect.set(rect) 这句话  发表于 2014-8-6 12:13
找到了= = 原本没看到的...  发表于 2014-8-6 12:11
原来是cursor_rect.set(rect)  发表于 2014-8-6 12:05
善用全局搜索  发表于 2014-8-6 11:20
Window_Selectable 140行  发表于 2014-8-6 11:11
回复

使用道具 举报

梦石
0
星屑
49
在线时间
157 小时
注册时间
2013-8-14
回帖
155
 楼主| 发表于 2014-8-6 12:35:11 | 显示全部楼层
九靈 发表于 2014-8-6 11:03
打错是page_row_max


#--------------------------------------------------------------------------
  # ● 更新光标
  #--------------------------------------------------------------------------
  def update_cursor
    if @cursor_all
      cursor_rect.set(0, 0, contents.width, row_max * item_height)
      self.top_row = 0
    elsif @index < 0
      cursor_rect.empty
    else
      ensure_cursor_visible
      cursor_rect.set(item_rect(@index))
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取项目的绘制矩形
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = item_width
    rect.height = item_height
    rect.x = index % col_max * (item_width + spacing)
    rect.y = index / col_max * item_height
    rect
  end


整合起来
cursor_rect.set(item_rect(@index))
相当于
cursor_rect.set(rect)
嗯...个人理解...
回复

使用道具 举报

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-8-6 12:59:36 | 显示全部楼层
九靈 发表于 2014-8-6 12:35
#--------------------------------------------------------------------------
  # ● 更新光标
  #-- ...

对啊没有问题啊,item_rect 返回一个矩形,你把它叫做 rect。
然后 cursor_rect.set(rect) ,很正确啊~

点评

没有了  发表于 2014-8-6 16:15
所以你有什么问题呢?  发表于 2014-8-6 14:44
是吧!  发表于 2014-8-6 14:44
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部