Project

General

Profile

機能 #806 » 0001-Gdk-SubPartsQuote-SubPartsMessage.patch

Satoshi Okuno, 2016-05-11 22:26

View differences:

core/mui/cairo_replyviewer.rb
def main_text_font(message)
Pango::FontDescription.new(UserConfig[:reply_text_font]) end
def header_left_content(*args)
if show_header?
super end end
def header_right_content(*args)
if show_header?
super end end
def icon_size
if show_icon?
if UserConfig[:reply_icon_size]
......
def text_max_line_count(message)
UserConfig[:reply_text_max_line_count] || super end
def render_outline(message, context, base_y)
unless show_edge?
@edge = 2
return end
@edge = 8
case UserConfig[:reply_edge]
when :floating
render_outline_floating(message, context, base_y)
when :solid
render_outline_solid(message, context, base_y)
when :flat
render_outline_flat(message, context, base_y) end end
def render_badge(message, context)
return unless show_edge?
case UserConfig[:reply_edge]
when :floating
render_badge_floating(message, context)
when :solid
render_badge_solid(message, context)
when :flat
render_badge_flat(message, context) end end
def edge_type
UserConfig[:reply_edge] end
def show_header?
(UserConfig[:reply_present_policy] || []).include?(:header) end
core/mui/cairo_sub_parts_message_base.rb
class Gdk::SubPartsMessageBase < Gdk::SubParts
DEFAULT_ICON_SIZE = 32
# ヘッダを表示するか?
# ==== Return
# [TrueClass] 表示する場合true
def show_header?
true end
# アイコンを表示するか?
# ==== Return
# [TrueClass] 表示する場合true
def show_icon?
true end
# 枠を表示するか?
# ==== Return
# [TrueClass] 表示する場合true
def show_edge?
true end
# SubPartsに表示する _Message_ 。
# 複数表示可能なので、それらを上に表示されるものから順番に返す。
# サブクラスで処理を実装すること。
......
# [Pango::FontDescription] フォント情報
# [Pango::Attribute] マークアップ情報
def header_left_content(message)
attr_list, text = Pango.parse_markup("<b>#{Pango.escape(message[:user][:idname])}</b> #{Pango.escape(message[:user][:name] || '')}")
return text, header_left_font(message), attr_list end
if show_header?
attr_list, text = Pango.parse_markup("<b>#{Pango.escape(message[:user][:idname])}</b> #{Pango.escape(message[:user][:name] || '')}")
return text, header_left_font(message), attr_list end end
# ヘッダ左に使用するフォントを返す
# ==== Args
......
# [Pango::FontDescription] フォント情報
# [Pango::Attribute] マークアップ情報
def header_right_content(message)
attr_list, text = Pango.parse_markup("<span foreground=\"#999999\">#{Pango.escape(header_right_text(message))}</span>")
return text, header_right_font(message), attr_list end
if show_header?
attr_list, text = Pango.parse_markup("<span foreground=\"#999999\">#{Pango.escape(header_right_text(message))}</span>")
return text, header_right_font(message), attr_list end end
# ヘッダ右に使用するフォントを返す
# ==== Args
......
else
[1.0]*3 end end
# 枠のタイプを返す
# ==== Return
# 以下の値のいずれか一つ
# :floating :: 影にblurを入れて、浮いているような感じに
# :solid :: 細い線を入れる
# :flat :: 枠線なし
def edge_type
:floating end
# SubParts内の _Message_ の枠の色を返す
# ==== Args
# [message] Message
......
# [Gdk::Rectangle] サイズ(px)。xとyは無視され、widthとheightのみが利用される
# [nil] アイコンを表示しない
def icon_size
Gdk::Rectangle.new(0, 0, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE) end
if show_icon?
Gdk::Rectangle.new(0, 0, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE)
else
nil end end
# _message_ の本文のテキスト色を返す
# ==== Args
......
# ヘッダ(左)のための Pango::Layout のインスタンスを返す
def header_left(message, context = dummy_context)
text, font, attr_list = header_left_content(message)
if text
if show_header?
layout = context.create_pango_layout
layout.attributes = attr_list if attr_list
layout.font_description = font if font
......
layout end
def render_outline(message, context, base_y)
render_outline_floating(message, context, base_y) end
unless show_edge?
@edge = 2
return end
@edge = 8
case edge_type
when :floating
render_outline_floating(message, context, base_y)
when :solid
render_outline_solid(message, context, base_y)
when :flat
render_outline_flat(message, context, base_y) end end
# エッジの描画。
# 影にblurを入れて、浮いているような感じに
......
context.rounded_rectangle(x,y,w,h, radius) } } end
def render_badge(message, context)
render_badge_floating(message, context) end
return unless show_edge?
case edge_type
when :floating
render_badge_floating(message, context)
when :solid
render_badge_solid(message, context)
when :flat
render_badge_flat(message, context) end end
# バッジの描画。
# 影にblurを入れて、浮いているような感じに
......
context.paint end end
def render_icon(message, context)
if icon_size
if show_icon?
context.set_source_pixbuf(main_icon(message))
context.paint end end
......
Gdk::WebImageLoader.pixbuf(message[:user][:profile_image_url], icon_size){ |pixbuf|
helper.on_modify } end
end
core/mui/cairo_sub_parts_quote.rb
def main_text_font(message)
Pango::FontDescription.new(UserConfig[:quote_text_font]) end
def header_left_content(*args)
if show_header?
super end end
def header_right_content(*args)
if show_header?
super end end
def icon_size
if show_icon?
if UserConfig[:quote_icon_size]
......
def text_max_line_count(message)
UserConfig[:quote_text_max_line_count] || super end
def render_outline(message, context, base_y)
unless show_edge?
@edge = 2
return end
@edge = 8
case UserConfig[:quote_edge]
when :floating
render_outline_floating(message, context, base_y)
when :solid
render_outline_solid(message, context, base_y)
when :flat
render_outline_flat(message, context, base_y) end end
def render_badge(message, context)
return unless show_edge?
case UserConfig[:quote_edge]
when :floating
render_badge_floating(message, context)
when :solid
render_badge_solid(message, context)
when :flat
render_badge_flat(message, context) end end
def edge_type
UserConfig[:quote_edge] end
def show_header?
(UserConfig[:quote_present_policy] || []).include?(:header) end
......
def show_edge?
(UserConfig[:quote_present_policy] || []).include?(:edge) end
end
(2-2/2)