summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorjonyrock <ilms@live.ru>2014-05-01 20:15:28 +0400
committerjonyrock <ilms@live.ru>2014-05-01 20:15:28 +0400
commit209eaf6fa06eba8a05e5222bdab418cd0f20c91c (patch)
tree94eac56be6ad254a7c09e13d5e14bd843626232c /scene
parent34aea718b11e105d30c938ad34e474b1bd8b5d63 (diff)
parent6572d5128856b2ec55a2c417c92e584899f4906f (diff)
Merge remote-tracking branch 'upstream/master' into pair_symbols_tool
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/progress_bar.cpp110
-rw-r--r--scene/gui/progress_bar.h43
-rw-r--r--scene/resources/texture.cpp22
-rw-r--r--scene/resources/texture.h5
4 files changed, 114 insertions, 66 deletions
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index 09b960f345..73fa1fbb98 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -26,47 +26,69 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "progress_bar.h"
-
-
-Size2 ProgressBar::get_minimum_size() const {
-
- Ref<StyleBox> bg = get_stylebox("bg");
- Ref<Font> font = get_font("font");
-
- Size2 ms=bg->get_minimum_size()+bg->get_center_size();
- ms.height=MAX(ms.height,bg->get_minimum_size().height+font->get_height());
- return ms;
-}
-
-
-void ProgressBar::_notification(int p_what) {
-
-
- if (p_what==NOTIFICATION_DRAW) {
-
- Ref<StyleBox> bg = get_stylebox("bg");
- Ref<StyleBox> fg = get_stylebox("fg");
- Ref<Font> font = get_font("font");
- Color font_color=get_color("font_color");
- Color font_color_shadow=get_color("font_color_shadow");
-
- draw_style_box(bg,Rect2(Point2(),get_size()));
- float r = get_unit_value();
- int mp = fg->get_minimum_size().width;
- int p = r*get_size().width-mp;
- if (p>0) {
-
- draw_style_box(fg,Rect2(Point2(),Size2(p+fg->get_minimum_size().width,get_size().height)));
- }
-
- int fh=font->get_height();
- String txt=itos(int(get_unit_value()*100))+"%";
- font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
- }
-}
-
-ProgressBar::ProgressBar() {
-
- set_v_size_flags(0);
-}
+#include "progress_bar.h"
+
+
+Size2 ProgressBar::get_minimum_size() const {
+
+ Ref<StyleBox> bg = get_stylebox("bg");
+ Ref<Font> font = get_font("font");
+
+ Size2 ms=bg->get_minimum_size()+bg->get_center_size();
+ ms.height=MAX(ms.height,bg->get_minimum_size().height+font->get_height());
+ return ms;
+}
+
+
+void ProgressBar::_notification(int p_what) {
+
+
+ if (p_what==NOTIFICATION_DRAW) {
+
+ Ref<StyleBox> bg = get_stylebox("bg");
+ Ref<StyleBox> fg = get_stylebox("fg");
+ Ref<Font> font = get_font("font");
+ Color font_color=get_color("font_color");
+ Color font_color_shadow=get_color("font_color_shadow");
+
+ draw_style_box(bg,Rect2(Point2(),get_size()));
+ float r = get_unit_value();
+ int mp = fg->get_minimum_size().width;
+ int p = r*get_size().width-mp;
+ if (p>0) {
+
+ draw_style_box(fg,Rect2(Point2(),Size2(p+fg->get_minimum_size().width,get_size().height)));
+ }
+
+ if (percent_visible) {
+ int fh=font->get_height();
+ String txt=itos(int(get_unit_value()*100))+"%";
+ font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
+ }
+ }
+}
+
+
+void ProgressBar::set_percent_visible(bool p_visible) {
+
+ percent_visible=p_visible;
+ update();
+}
+
+bool ProgressBar::is_percent_visible() const{
+
+ return percent_visible;
+}
+
+void ProgressBar::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_percent_visible","visible"),&ProgressBar::set_percent_visible);
+ ObjectTypeDB::bind_method(_MD("is_percent_visible"),&ProgressBar::is_percent_visible);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent/visible"),_SCS("set_percent_visible"),_SCS("is_percent_visible"));
+}
+
+ProgressBar::ProgressBar() {
+
+ set_v_size_flags(0);
+ percent_visible=true;
+}
diff --git a/scene/gui/progress_bar.h b/scene/gui/progress_bar.h
index fa334a2ad9..fd34c67fae 100644
--- a/scene/gui/progress_bar.h
+++ b/scene/gui/progress_bar.h
@@ -26,22 +26,27 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PROGRESS_BAR_H
-#define PROGRESS_BAR_H
-
-#include "scene/gui/range.h"
-
-class ProgressBar : public Range {
-
- OBJ_TYPE( ProgressBar, Range );
-
-protected:
-
- void _notification(int p_what);
-public:
-
- Size2 get_minimum_size() const;
- ProgressBar();
-};
-
-#endif // PROGRESS_BAR_H
+#ifndef PROGRESS_BAR_H
+#define PROGRESS_BAR_H
+
+#include "scene/gui/range.h"
+
+class ProgressBar : public Range {
+
+ OBJ_TYPE( ProgressBar, Range );
+
+ bool percent_visible;
+protected:
+
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ void set_percent_visible(bool p_visible);
+ bool is_percent_visible() const;
+
+ Size2 get_minimum_size() const;
+ ProgressBar();
+};
+
+#endif // PROGRESS_BAR_H
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index be3b921bad..baf6fa9d8d 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -648,15 +648,31 @@ uint32_t LargeTexture::get_flags() const{
}
-void LargeTexture::add_piece(const Point2& p_offset,const Ref<Texture>& p_texture) {
+int LargeTexture::add_piece(const Point2& p_offset,const Ref<Texture>& p_texture) {
- ERR_FAIL_COND(p_texture.is_null());
+ ERR_FAIL_COND_V(p_texture.is_null(), -1);
Piece p;
p.offset=p_offset;
p.texture=p_texture;
pieces.push_back(p);
+
+ return pieces.size() - 1;
}
+void LargeTexture::set_piece_offset(int p_idx, const Point2& p_offset) {
+
+ ERR_FAIL_INDEX(p_idx, pieces.size());
+ pieces[p_idx].offset = p_offset;
+};
+
+void LargeTexture::set_piece_texture(int p_idx, const Ref<Texture>& p_texture) {
+
+ ERR_FAIL_INDEX(p_idx, pieces.size());
+ pieces[p_idx].texture = p_texture;
+};
+
+
+
void LargeTexture::set_size(const Size2& p_size){
size=p_size;
@@ -709,6 +725,8 @@ Ref<Texture> LargeTexture::get_piece_texture(int p_idx) const{
void LargeTexture::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_piece","ofs","texture:Texture"),&LargeTexture::add_piece);
+ ObjectTypeDB::bind_method(_MD("set_piece_offset", "idx", "ofs"),&LargeTexture::set_piece_offset);
+ ObjectTypeDB::bind_method(_MD("set_piece_texture","idx", "texture:Texture"),&LargeTexture::set_piece_texture);
ObjectTypeDB::bind_method(_MD("set_size","size"),&LargeTexture::set_size);
ObjectTypeDB::bind_method(_MD("clear"),&LargeTexture::clear);
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 1e7528eb61..6259362882 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -225,7 +225,10 @@ public:
virtual void set_flags(uint32_t p_flags);
virtual uint32_t get_flags() const;
- void add_piece(const Point2& p_offset,const Ref<Texture>& p_texture);
+ int add_piece(const Point2& p_offset,const Ref<Texture>& p_texture);
+ void set_piece_offset(int p_idx, const Point2& p_offset);
+ void set_piece_texture(int p_idx, const Ref<Texture>& p_texture);
+
void set_size(const Size2& p_size);
void clear();