resource-tab.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
  2. /*
  3. * resource-tab.h
  4. * Copyright (C) 2017 Unknown <francois@gautrais.eu>
  5. *
  6. * histodexc is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * histodexc is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. * See the GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _RESOURCE_TAB_H_
  20. #define _RESOURCE_TAB_H_
  21. #include "tab.h"
  22. #include "resource.h"
  23. const char* typetostring(int i);
  24. int stringtotype(const std::string & a);
  25. class ResourceTab : public Tab
  26. {
  27. public:
  28. ResourceTab(GtkWidget *window, GtkBuilder *builder);
  29. virtual ~ResourceTab();
  30. virtual void write(const std::string& file);
  31. virtual Json::Value getJson(bool genFinal=false);
  32. virtual Json::Value getJsonOrphelin();
  33. virtual void open(Json::Value& val);
  34. void insert(std::string name, Resource* ra=NULL);
  35. void remove(std::string name);
  36. virtual void on_save_clicked();
  37. static int on_stage_changed(void *x);
  38. void on_type_changed(int i);
  39. void on_select();
  40. void on_remove();
  41. void on_add();
  42. GtkListStore* getModel();
  43. std::vector<Resource>& getResources() {return m_resources;}
  44. protected:
  45. GtkEntry* m_name;
  46. GtkSpinButton* m_stage;
  47. GtkSpinButton* m_scale[3];
  48. GtkSpinButton* m_position[3];
  49. GtkSpinButton* m_rotation[3];
  50. GtkTextView* m_comments;
  51. GtkEntry* m_title;
  52. GtkGrid* m_layout[4];
  53. GtkRadioButton* m_type[4];
  54. GtkTreeView* m_list;
  55. GtkListStore* m_listStore;
  56. GtkTreeModel* m_model;
  57. GtkTreeSelection* m_selection;
  58. GtkFileChooserButton* m_files[4];
  59. GtkButton* m_add;
  60. GtkButton* m_delete;
  61. GtkBox* m_root;
  62. int m_activeTab;
  63. bool m_isLoading;
  64. std::vector<Resource> m_resources;
  65. protected:
  66. Data& getTab(bool& genFinal);
  67. void setupTab(Data& a);
  68. void setCurrentResource(Resource& r);
  69. Resource* findResource(const std::string& name);
  70. void set_layout(int i=-1);
  71. void test();
  72. };
  73. #endif // _RESOURCE_TAB_H_