Anim Editor: List control no longer fills in its background

This commit is contained in:
Maruno17
2024-04-07 23:49:23 +01:00
parent f34f9040c6
commit d0e15a8939
4 changed files with 44 additions and 28 deletions

View File

@@ -138,11 +138,9 @@ class UIControls::List < UIControls::BaseControl
end
def refresh
self.bitmap.clear
# Draw control outline and background
super
# Draw control outline
self.bitmap.outline_rect(0, 0, width, height, Color.black)
self.bitmap.fill_rect(1, 1, width - 2, height - 2, Color.white)
draw_area_highlight
# Draw text options
@values.each_with_index do |val, i|
next if i < @top_row || i >= @top_row + @rows_count

View File

@@ -56,15 +56,24 @@ class UIControls::DropdownList < UIControls::BaseControl
def make_dropdown_menu
menu_height = (UIControls::List::ROW_HEIGHT * [@options.length, @max_rows].min) + (UIControls::List::BORDER_THICKNESS * 2)
# Draw menu's background
@dropdown_menu_bg = BitmapSprite.new(@button_rect.width, menu_height, self.viewport)
@dropdown_menu_bg.x = self.x + @button_rect.x
@dropdown_menu_bg.y = self.y + @button_rect.y + @button_rect.height
@dropdown_menu_bg.z = self.z + 1
@dropdown_menu_bg.bitmap.fill_rect(0, 0, @dropdown_menu_bg.width, @dropdown_menu_bg.height, Color.white)
# Create menu
@dropdown_menu = UIControls::List.new(@button_rect.width, menu_height, self.viewport, @options)
@dropdown_menu.x = self.x + @button_rect.x
@dropdown_menu.y = self.y + @button_rect.y + @button_rect.height
@dropdown_menu.x = @dropdown_menu_bg.x
@dropdown_menu.y = @dropdown_menu_bg.y
@dropdown_menu.z = self.z + 2
@dropdown_menu.set_interactive_rects
@dropdown_menu.repaint
end
def remove_dropdown_menu
@dropdown_menu_bg&.dispose
@dropdown_menu_bg = nil
@dropdown_menu&.dispose
@dropdown_menu = nil
@captured_area = nil

View File

@@ -52,15 +52,24 @@ class UIControls::TextBoxDropdownList < UIControls::TextBox
def make_dropdown_menu
menu_height = (UIControls::List::ROW_HEIGHT * [@options.length, @max_rows].min) + (UIControls::List::BORDER_THICKNESS * 2)
# Draw menu's background
@dropdown_menu_bg = BitmapSprite.new(@text_box_rect.width + @button_rect.width, menu_height, self.viewport)
@dropdown_menu_bg.x = self.x + @text_box_rect.x
@dropdown_menu_bg.y = self.y + @text_box_rect.y + @text_box_rect.height
@dropdown_menu_bg.z = self.z + 1
@dropdown_menu_bg.bitmap.fill_rect(0, 0, @dropdown_menu_bg.width, @dropdown_menu_bg.height, Color.white)
# Create menu
@dropdown_menu = UIControls::List.new(@text_box_rect.width + @button_rect.width, menu_height, self.viewport, @options)
@dropdown_menu.x = self.x + @text_box_rect.x
@dropdown_menu.y = self.y + @text_box_rect.y + @text_box_rect.height
@dropdown_menu.x = @dropdown_menu_bg.x
@dropdown_menu.y = @dropdown_menu_bg.y
@dropdown_menu.z = self.z + 2
@dropdown_menu.set_interactive_rects
@dropdown_menu.repaint
end
def remove_dropdown_menu
@dropdown_menu_bg&.dispose
@dropdown_menu_bg = nil
@dropdown_menu&.dispose
@dropdown_menu = nil
@captured_area = nil

View File

@@ -170,6 +170,14 @@ class AnimationEditor::Canvas < Sprite
return ret_x, ret_y
end
def mouse_in_sprite?(sprite, mouse_x, mouse_y)
return false if mouse_x < sprite.x - sprite.ox
return false if mouse_x >= sprite.x - sprite.ox + sprite.width
return false if mouse_y < sprite.y - sprite.oy
return false if mouse_y >= sprite.y - sprite.oy + sprite.height
return true
end
#-----------------------------------------------------------------------------
def busy?
@@ -509,12 +517,10 @@ class AnimationEditor::Canvas < Sprite
# Position frame over spr
frame.x = spr.x
frame.y = spr.y
# TODO: Offset frame.x and frame.y for screen-sized sprites with a
# screen-based focus, and for sprites whose graphic has "[bottom]" in
# its name.
case particle[:graphic]
when "USER", "USER_OPP", "USER_FRONT", "USER_BACK",
"TARGET", "TARGET_OPP", "TARGET_FRONT", "TARGET_BACK"
# Offset battler frames because they aren't around the battler's position
frame.y -= spr.bitmap.height / 2
end
end
@@ -543,12 +549,16 @@ class AnimationEditor::Canvas < Sprite
ensure_battler_sprites
refresh_battler_graphics
refresh_battler_positions
@battler_sprites.each { |s| s.visible = false if s && !s.disposed? }
@particle_sprites.each do |s|
if s.is_a?(Array)
s.each { |s2| s2.visible = false if s2 && !s2.disposed? }
else
s.visible = false if s && !s.disposed?
[@battler_sprites, @battler_frame_sprites].each do |sprites|
sprites.each { |s| s.visible = false if s && !s.disposed? }
end
[@particle_sprites, @frame_sprites].each do |sprites|
sprites.each do |s|
if s.is_a?(Array)
s.each { |s2| s2.visible = false if s2 && !s2.disposed? }
else
s.visible = false if s && !s.disposed?
end
end
end
@anim[:particles].each_with_index do |particle, i|
@@ -563,14 +573,6 @@ class AnimationEditor::Canvas < Sprite
#-----------------------------------------------------------------------------
def mouse_in_sprite?(sprite, mouse_x, mouse_y)
return false if mouse_x < sprite.x - sprite.ox
return false if mouse_x >= sprite.x - sprite.ox + sprite.width
return false if mouse_y < sprite.y - sprite.oy
return false if mouse_y >= sprite.y - sprite.oy + sprite.height
return true
end
def on_mouse_press
mouse_x, mouse_y = mouse_pos
return if !mouse_x || !mouse_y
@@ -726,12 +728,10 @@ class AnimationEditor::Canvas < Sprite
@sel_frame_sprite.visible = true
@sel_frame_sprite.x = target.x
@sel_frame_sprite.y = target.y
# TODO: Offset sel_frame_sprite.x and sel_frame_sprite.y for screen-sized
# sprites with a screen-based focus, and for sprites whose graphic has
# "[bottom]" in its name.
case @anim[:particles][@selected_particle][:graphic]
when "USER", "USER_OPP", "USER_FRONT", "USER_BACK",
"TARGET", "TARGET_OPP", "TARGET_FRONT", "TARGET_BACK"
# Offset battler frames because they aren't around the battler's position
@sel_frame_sprite.y -= target.bitmap.height / 2
end
end