Rename the TextureProgress node to TextureProgressBar

Advantages:

- When searching for "progressbar", you'll see both nodes in the
  search results.
- More consistent with Button/TextureButton.
This commit is contained in:
Hugo Locurcio 2020-12-14 21:10:09 +01:00
parent a511a26ad8
commit 57dcc83152
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
9 changed files with 80 additions and 79 deletions

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TextureProgress" inherits="Range" version="4.0">
<class name="TextureProgressBar" inherits="Range" version="4.0">
<brief_description>
Texture-based progress bar. Useful for loading screens and life or stamina bars.
</brief_description>
<description>
TextureProgress works like [ProgressBar], but uses up to 3 textures instead of Godot's [Theme] resource. It can be used to create horizontal, vertical and radial progress bars.
TextureProgressBar works like [ProgressBar], but uses up to 3 textures instead of Godot's [Theme] resource. It can be used to create horizontal, vertical and radial progress bars.
</description>
<tutorials>
</tutorials>

View File

@ -851,15 +851,15 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
cc = 0;
for (int i = 0; i < CHANNELS_MAX; i++) {
channel[i].vu_l = memnew(TextureProgress);
channel[i].vu_l->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP);
channel[i].vu_l = memnew(TextureProgressBar);
channel[i].vu_l->set_fill_mode(TextureProgressBar::FILL_BOTTOM_TO_TOP);
hb->add_child(channel[i].vu_l);
channel[i].vu_l->set_min(-80);
channel[i].vu_l->set_max(24);
channel[i].vu_l->set_step(0.1);
channel[i].vu_r = memnew(TextureProgress);
channel[i].vu_r->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP);
channel[i].vu_r = memnew(TextureProgressBar);
channel[i].vu_r->set_fill_mode(TextureProgressBar::FILL_BOTTOM_TO_TOP);
hb->add_child(channel[i].vu_r);
channel[i].vu_r->set_min(-80);
channel[i].vu_r->set_max(24);

View File

@ -43,7 +43,7 @@
#include "scene/gui/panel_container.h"
#include "scene/gui/scroll_container.h"
#include "scene/gui/slider.h"
#include "scene/gui/texture_progress.h"
#include "scene/gui/texture_progress_bar.h"
#include "scene/gui/texture_rect.h"
#include "scene/gui/tree.h"
@ -66,8 +66,8 @@ class EditorAudioBus : public PanelContainer {
float peak_l = 0;
float peak_r = 0;
TextureProgress *vu_l = nullptr;
TextureProgress *vu_r = nullptr;
TextureProgressBar *vu_l = nullptr;
TextureProgressBar *vu_r = nullptr;
} channel[CHANNELS_MAX];
OptionButton *send;

View File

@ -57,7 +57,7 @@
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tabs.h"
#include "scene/gui/texture_progress.h"
#include "scene/gui/texture_progress_bar.h"
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
#include "servers/display_server.h"

View File

@ -81,7 +81,7 @@ class RunSettingsDialog;
class ScriptCreateDialog;
class TabContainer;
class Tabs;
class TextureProgress;
class TextureProgressBar;
class Button;
class VSplitContainer;
class Window;
@ -271,7 +271,7 @@ private:
Button *play_scene_button;
Button *play_custom_scene_button;
Button *search_button;
TextureProgress *audio_vu;
TextureProgressBar *audio_vu;
Timer *screenshot_timer;

View File

Before

Width:  |  Height:  |  Size: 391 B

After

Width:  |  Height:  |  Size: 391 B

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* texture_progress.cpp */
/* texture_progress_bar.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,21 +28,21 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "texture_progress.h"
#include "texture_progress_bar.h"
#include "core/config/engine.h"
void TextureProgress::set_under_texture(const Ref<Texture2D> &p_texture) {
void TextureProgressBar::set_under_texture(const Ref<Texture2D> &p_texture) {
under = p_texture;
update();
minimum_size_changed();
}
Ref<Texture2D> TextureProgress::get_under_texture() const {
Ref<Texture2D> TextureProgressBar::get_under_texture() const {
return under;
}
void TextureProgress::set_over_texture(const Ref<Texture2D> &p_texture) {
void TextureProgressBar::set_over_texture(const Ref<Texture2D> &p_texture) {
over = p_texture;
update();
if (under.is_null()) {
@ -50,33 +50,33 @@ void TextureProgress::set_over_texture(const Ref<Texture2D> &p_texture) {
}
}
Ref<Texture2D> TextureProgress::get_over_texture() const {
Ref<Texture2D> TextureProgressBar::get_over_texture() const {
return over;
}
void TextureProgress::set_stretch_margin(Margin p_margin, int p_size) {
void TextureProgressBar::set_stretch_margin(Margin p_margin, int p_size) {
ERR_FAIL_INDEX((int)p_margin, 4);
stretch_margin[p_margin] = p_size;
update();
minimum_size_changed();
}
int TextureProgress::get_stretch_margin(Margin p_margin) const {
int TextureProgressBar::get_stretch_margin(Margin p_margin) const {
ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return stretch_margin[p_margin];
}
void TextureProgress::set_nine_patch_stretch(bool p_stretch) {
void TextureProgressBar::set_nine_patch_stretch(bool p_stretch) {
nine_patch_stretch = p_stretch;
update();
minimum_size_changed();
}
bool TextureProgress::get_nine_patch_stretch() const {
bool TextureProgressBar::get_nine_patch_stretch() const {
return nine_patch_stretch;
}
Size2 TextureProgress::get_minimum_size() const {
Size2 TextureProgressBar::get_minimum_size() const {
if (nine_patch_stretch) {
return Size2(stretch_margin[MARGIN_LEFT] + stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_TOP] + stretch_margin[MARGIN_BOTTOM]);
} else if (under.is_valid()) {
@ -90,44 +90,44 @@ Size2 TextureProgress::get_minimum_size() const {
return Size2(1, 1);
}
void TextureProgress::set_progress_texture(const Ref<Texture2D> &p_texture) {
void TextureProgressBar::set_progress_texture(const Ref<Texture2D> &p_texture) {
progress = p_texture;
update();
minimum_size_changed();
}
Ref<Texture2D> TextureProgress::get_progress_texture() const {
Ref<Texture2D> TextureProgressBar::get_progress_texture() const {
return progress;
}
void TextureProgress::set_tint_under(const Color &p_tint) {
void TextureProgressBar::set_tint_under(const Color &p_tint) {
tint_under = p_tint;
update();
}
Color TextureProgress::get_tint_under() const {
Color TextureProgressBar::get_tint_under() const {
return tint_under;
}
void TextureProgress::set_tint_progress(const Color &p_tint) {
void TextureProgressBar::set_tint_progress(const Color &p_tint) {
tint_progress = p_tint;
update();
}
Color TextureProgress::get_tint_progress() const {
Color TextureProgressBar::get_tint_progress() const {
return tint_progress;
}
void TextureProgress::set_tint_over(const Color &p_tint) {
void TextureProgressBar::set_tint_over(const Color &p_tint) {
tint_over = p_tint;
update();
}
Color TextureProgress::get_tint_over() const {
Color TextureProgressBar::get_tint_over() const {
return tint_over;
}
Point2 TextureProgress::unit_val_to_uv(float val) {
Point2 TextureProgressBar::unit_val_to_uv(float val) {
if (progress.is_null()) {
return Point2();
}
@ -191,7 +191,7 @@ Point2 TextureProgress::unit_val_to_uv(float val) {
return (p + t1 * dir);
}
Point2 TextureProgress::get_relative_center() {
Point2 TextureProgressBar::get_relative_center() {
if (progress.is_null()) {
return Point2();
}
@ -204,7 +204,7 @@ Point2 TextureProgress::get_relative_center() {
return p;
}
void TextureProgress::draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate) {
void TextureProgressBar::draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate) {
Vector2 texture_size = p_texture->get_size();
Vector2 topleft = Vector2(stretch_margin[MARGIN_LEFT], stretch_margin[MARGIN_TOP]);
Vector2 bottomright = Vector2(stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_BOTTOM]);
@ -306,7 +306,7 @@ void TextureProgress::draw_nine_patch_stretched(const Ref<Texture2D> &p_texture,
RS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright, RS::NINE_PATCH_STRETCH, RS::NINE_PATCH_STRETCH, true, p_modulate);
}
void TextureProgress::_notification(int p_what) {
void TextureProgressBar::_notification(int p_what) {
const float corners[12] = { -0.125, -0.375, -0.625, -0.875, 0.125, 0.375, 0.625, 0.875, 1.125, 1.375, 1.625, 1.875 };
switch (p_what) {
case NOTIFICATION_DRAW: {
@ -428,17 +428,17 @@ void TextureProgress::_notification(int p_what) {
}
}
void TextureProgress::set_fill_mode(int p_fill) {
void TextureProgressBar::set_fill_mode(int p_fill) {
ERR_FAIL_INDEX(p_fill, 9);
mode = (FillMode)p_fill;
update();
}
int TextureProgress::get_fill_mode() {
int TextureProgressBar::get_fill_mode() {
return mode;
}
void TextureProgress::set_radial_initial_angle(float p_angle) {
void TextureProgressBar::set_radial_initial_angle(float p_angle) {
while (p_angle > 360) {
p_angle -= 360;
}
@ -449,64 +449,64 @@ void TextureProgress::set_radial_initial_angle(float p_angle) {
update();
}
float TextureProgress::get_radial_initial_angle() {
float TextureProgressBar::get_radial_initial_angle() {
return rad_init_angle;
}
void TextureProgress::set_fill_degrees(float p_angle) {
void TextureProgressBar::set_fill_degrees(float p_angle) {
rad_max_degrees = CLAMP(p_angle, 0, 360);
update();
}
float TextureProgress::get_fill_degrees() {
float TextureProgressBar::get_fill_degrees() {
return rad_max_degrees;
}
void TextureProgress::set_radial_center_offset(const Point2 &p_off) {
void TextureProgressBar::set_radial_center_offset(const Point2 &p_off) {
rad_center_off = p_off;
update();
}
Point2 TextureProgress::get_radial_center_offset() {
Point2 TextureProgressBar::get_radial_center_offset() {
return rad_center_off;
}
void TextureProgress::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_under_texture", "tex"), &TextureProgress::set_under_texture);
ClassDB::bind_method(D_METHOD("get_under_texture"), &TextureProgress::get_under_texture);
void TextureProgressBar::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_under_texture", "tex"), &TextureProgressBar::set_under_texture);
ClassDB::bind_method(D_METHOD("get_under_texture"), &TextureProgressBar::get_under_texture);
ClassDB::bind_method(D_METHOD("set_progress_texture", "tex"), &TextureProgress::set_progress_texture);
ClassDB::bind_method(D_METHOD("get_progress_texture"), &TextureProgress::get_progress_texture);
ClassDB::bind_method(D_METHOD("set_progress_texture", "tex"), &TextureProgressBar::set_progress_texture);
ClassDB::bind_method(D_METHOD("get_progress_texture"), &TextureProgressBar::get_progress_texture);
ClassDB::bind_method(D_METHOD("set_over_texture", "tex"), &TextureProgress::set_over_texture);
ClassDB::bind_method(D_METHOD("get_over_texture"), &TextureProgress::get_over_texture);
ClassDB::bind_method(D_METHOD("set_over_texture", "tex"), &TextureProgressBar::set_over_texture);
ClassDB::bind_method(D_METHOD("get_over_texture"), &TextureProgressBar::get_over_texture);
ClassDB::bind_method(D_METHOD("set_fill_mode", "mode"), &TextureProgress::set_fill_mode);
ClassDB::bind_method(D_METHOD("get_fill_mode"), &TextureProgress::get_fill_mode);
ClassDB::bind_method(D_METHOD("set_fill_mode", "mode"), &TextureProgressBar::set_fill_mode);
ClassDB::bind_method(D_METHOD("get_fill_mode"), &TextureProgressBar::get_fill_mode);
ClassDB::bind_method(D_METHOD("set_tint_under", "tint"), &TextureProgress::set_tint_under);
ClassDB::bind_method(D_METHOD("get_tint_under"), &TextureProgress::get_tint_under);
ClassDB::bind_method(D_METHOD("set_tint_under", "tint"), &TextureProgressBar::set_tint_under);
ClassDB::bind_method(D_METHOD("get_tint_under"), &TextureProgressBar::get_tint_under);
ClassDB::bind_method(D_METHOD("set_tint_progress", "tint"), &TextureProgress::set_tint_progress);
ClassDB::bind_method(D_METHOD("get_tint_progress"), &TextureProgress::get_tint_progress);
ClassDB::bind_method(D_METHOD("set_tint_progress", "tint"), &TextureProgressBar::set_tint_progress);
ClassDB::bind_method(D_METHOD("get_tint_progress"), &TextureProgressBar::get_tint_progress);
ClassDB::bind_method(D_METHOD("set_tint_over", "tint"), &TextureProgress::set_tint_over);
ClassDB::bind_method(D_METHOD("get_tint_over"), &TextureProgress::get_tint_over);
ClassDB::bind_method(D_METHOD("set_tint_over", "tint"), &TextureProgressBar::set_tint_over);
ClassDB::bind_method(D_METHOD("get_tint_over"), &TextureProgressBar::get_tint_over);
ClassDB::bind_method(D_METHOD("set_radial_initial_angle", "mode"), &TextureProgress::set_radial_initial_angle);
ClassDB::bind_method(D_METHOD("get_radial_initial_angle"), &TextureProgress::get_radial_initial_angle);
ClassDB::bind_method(D_METHOD("set_radial_initial_angle", "mode"), &TextureProgressBar::set_radial_initial_angle);
ClassDB::bind_method(D_METHOD("get_radial_initial_angle"), &TextureProgressBar::get_radial_initial_angle);
ClassDB::bind_method(D_METHOD("set_radial_center_offset", "mode"), &TextureProgress::set_radial_center_offset);
ClassDB::bind_method(D_METHOD("get_radial_center_offset"), &TextureProgress::get_radial_center_offset);
ClassDB::bind_method(D_METHOD("set_radial_center_offset", "mode"), &TextureProgressBar::set_radial_center_offset);
ClassDB::bind_method(D_METHOD("get_radial_center_offset"), &TextureProgressBar::get_radial_center_offset);
ClassDB::bind_method(D_METHOD("set_fill_degrees", "mode"), &TextureProgress::set_fill_degrees);
ClassDB::bind_method(D_METHOD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
ClassDB::bind_method(D_METHOD("set_fill_degrees", "mode"), &TextureProgressBar::set_fill_degrees);
ClassDB::bind_method(D_METHOD("get_fill_degrees"), &TextureProgressBar::get_fill_degrees);
ClassDB::bind_method(D_METHOD("set_stretch_margin", "margin", "value"), &TextureProgress::set_stretch_margin);
ClassDB::bind_method(D_METHOD("get_stretch_margin", "margin"), &TextureProgress::get_stretch_margin);
ClassDB::bind_method(D_METHOD("set_stretch_margin", "margin", "value"), &TextureProgressBar::set_stretch_margin);
ClassDB::bind_method(D_METHOD("get_stretch_margin", "margin"), &TextureProgressBar::get_stretch_margin);
ClassDB::bind_method(D_METHOD("set_nine_patch_stretch", "stretch"), &TextureProgress::set_nine_patch_stretch);
ClassDB::bind_method(D_METHOD("get_nine_patch_stretch"), &TextureProgress::get_nine_patch_stretch);
ClassDB::bind_method(D_METHOD("set_nine_patch_stretch", "stretch"), &TextureProgressBar::set_nine_patch_stretch);
ClassDB::bind_method(D_METHOD("get_nine_patch_stretch"), &TextureProgressBar::get_nine_patch_stretch);
ADD_GROUP("Textures", "texture_");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_under_texture", "get_under_texture");
@ -539,7 +539,7 @@ void TextureProgress::_bind_methods() {
BIND_ENUM_CONSTANT(FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE);
}
TextureProgress::TextureProgress() {
TextureProgressBar::TextureProgressBar() {
mode = FILL_LEFT_TO_RIGHT;
rad_init_angle = 0;
rad_center_off = Point2();

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* texture_progress.h */
/* texture_progress_bar.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef TEXTURE_PROGRESS_H
#define TEXTURE_PROGRESS_H
#ifndef TEXTURE_PROGRESS_BAR_H
#define TEXTURE_PROGRESS_BAR_H
#include "scene/gui/range.h"
class TextureProgress : public Range {
GDCLASS(TextureProgress, Range);
class TextureProgressBar : public Range {
GDCLASS(TextureProgressBar, Range);
Ref<Texture2D> under;
Ref<Texture2D> progress;
@ -95,7 +95,7 @@ public:
Size2 get_minimum_size() const override;
TextureProgress();
TextureProgressBar();
private:
FillMode mode;
@ -111,6 +111,6 @@ private:
void draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate);
};
VARIANT_ENUM_CAST(TextureProgress::FillMode);
VARIANT_ENUM_CAST(TextureProgressBar::FillMode);
#endif // TEXTURE_PROGRESS_H
#endif // TEXTURE_PROGRESS_BAR_H

View File

@ -118,7 +118,7 @@
#include "scene/gui/tabs.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/texture_button.h"
#include "scene/gui/texture_progress.h"
#include "scene/gui/texture_progress_bar.h"
#include "scene/gui/texture_rect.h"
#include "scene/gui/tree.h"
#include "scene/gui/video_player.h"
@ -349,7 +349,7 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
ClassDB::register_class<TextureProgress>();
ClassDB::register_class<TextureProgressBar>();
ClassDB::register_class<ItemList>();
ClassDB::register_class<LineEdit>();
@ -915,6 +915,7 @@ void register_scene_types() {
ClassDB::add_compatibility_class("SpringArm", "SpringArm3D");
ClassDB::add_compatibility_class("Sprite", "Sprite2D");
ClassDB::add_compatibility_class("StaticBody", "StaticBody3D");
ClassDB::add_compatibility_class("TextureProgress", "TextureProgressBar");
ClassDB::add_compatibility_class("VehicleBody", "VehicleBody3D");
ClassDB::add_compatibility_class("VehicleWheel", "VehicleWheel3D");
ClassDB::add_compatibility_class("ViewportContainer", "SubViewportContainer");