Skip to content

Commit

Permalink
fix: hint ui does not fit
Browse files Browse the repository at this point in the history
related: #123
  • Loading branch information
Ark2000 committed Aug 4, 2023
1 parent 7e2cb1c commit 4c2b00a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func _update_hints(exp:String):
_hints.visible = _current_hints["hints_value"].size() > 0
_helpbar.visible = _hints.visible
_input_area.input.hints = _current_hints["hints_value"]
_hints.disable_buttons = false
_hints.set_hints(_current_hints["hints_bbcode"])
_hint_idx = -1
_helpbar_label.text = "[Hint] Use TAB or up/down to autocomplete!"
Expand All @@ -89,7 +88,6 @@ func _ready():
_input_area.navigate_histories.connect(
func(histories, id):
if histories.size() > 0:
_hints.disable_buttons = true
_hints.set_hints(histories)
_hints.selected = id
_hints.visible = true
Expand All @@ -99,10 +97,6 @@ func _ready():
_helpbar_label.text = "[Hint] Use up/down to navigate through submit histories!"

)
_hints.hint_button_clicked.connect(
func(i:int):
_set_hint_idx(i)
)

_helpbar.hide()
_hints.hide()
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
extends Button
extends PanelContainer

@export var label:RichTextLabel
@export var bg2:ColorRect

func set_highlight(b:bool):
bg2.scale.x = 1.0 if b else 0.0
bg2.visible = b
50 changes: 21 additions & 29 deletions addons/panku_console/modules/interactive_shell/hints_list/hint.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[gd_scene load_steps=7 format=3 uid="uid://dbtn0x604fx5o"]
[gd_scene load_steps=9 format=3 uid="uid://dbtn0x604fx5o"]

[ext_resource type="Script" path="res://addons/panku_console/modules/interactive_shell/hints_list/hint.gd" id="1_sa53g"]

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_wylp8"]

[sub_resource type="SystemFont" id="SystemFont_tt6oo"]
font_names = PackedStringArray("Consolas")

Expand All @@ -18,45 +20,32 @@ font_weight = 900

[sub_resource type="SystemFont" id="SystemFont_75v2u"]

[node name="Hints" type="Button" node_paths=PackedStringArray("label", "bg2")]
custom_minimum_size = Vector2(0, 24)
offset_right = 1152.0
offset_bottom = 18.0
flat = true
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ganpp"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0

[node name="Hint" type="PanelContainer" node_paths=PackedStringArray("label", "bg2")]
anchors_preset = 10
anchor_right = 1.0
grow_horizontal = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_wylp8")
script = ExtResource("1_sa53g")
label = NodePath("RichTextLabel")
bg2 = NodePath("Bg2")

[node name="Blur" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
layout_mode = 2
color = Color(0.219608, 0.219608, 0.223529, 0.658824)

[node name="Bg2" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(1e-05, 1)
visible = false
layout_mode = 2
color = Color(0.290196, 0.509804, 0.305882, 1)

[node name="RichTextLabel" type="RichTextLabel" parent="."]
layout_mode = 1
anchors_preset = -1
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_left = 4.0
offset_top = -7.5
offset_bottom = 7.5
grow_horizontal = 2
grow_vertical = 2
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
mouse_filter = 2
Expand All @@ -70,6 +59,9 @@ theme_override_font_sizes/bold_font_size = 14
theme_override_font_sizes/italics_font_size = 14
theme_override_font_sizes/bold_italics_font_size = 14
theme_override_font_sizes/mono_font_size = 14
theme_override_styles/normal = SubResource("StyleBoxEmpty_ganpp")
bbcode_enabled = true
text = "[color=cyan]w_button[/color][color=gray]([/color]display_name:[color=green]String[/color], env:[color=green]String[/color], exp:[color=green]String[/color][color=gray])[/color]"
fit_content = true
scroll_active = false
autowrap_mode = 0
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
extends ScrollContainer

signal hint_button_clicked(idx:int)

const hint_pck = preload("./hint.tscn")

const MAX_HEIGHT = 400
Expand All @@ -12,8 +10,6 @@ const MAX_HEIGHT = 400

var hints_count = 0

var disable_buttons := false

var selected:int = 0:
set(v):
if !container: return
Expand Down Expand Up @@ -47,7 +43,6 @@ func set_hints(texts:Array):
h = hint_pck.instantiate()
container.add_child(h)
h.set_meta("idx", i)
h.button_down.connect(func(): _on_btn_clicked(i))
h.label.text = texts[i]
h.set_highlight(false)
if texts.size() < container.get_child_count():
Expand All @@ -57,7 +52,3 @@ func set_hints(texts:Array):
if auto_resize:
await get_tree().process_frame
custom_minimum_size.y = min(MAX_HEIGHT, container.size.y)

func _on_btn_clicked(i:int):
if !disable_buttons:
hint_button_clicked.emit(i)
2 changes: 1 addition & 1 deletion addons/panku_console/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="PankuConsole"
description="All-in-One Godot Engine runtime debugging tool."
author="Feo (k2kra) Wu"
version="1.6.0"
version="1.6.1"
script="plugin.gd"

0 comments on commit 4c2b00a

Please sign in to comment.