mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
new file
This commit is contained in:
parent
d763669d75
commit
68cc677b65
0
panda/src/gui/config_gui.cxx
Normal file
0
panda/src/gui/config_gui.cxx
Normal file
4
panda/src/gui/config_gui.h
Normal file
4
panda/src/gui/config_gui.h
Normal file
@ -0,0 +1,4 @@
|
||||
// Filename: config_gui.h
|
||||
// Created by: cary (26Oct00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
79
panda/src/gui/guiManager.cxx
Normal file
79
panda/src/gui/guiManager.cxx
Normal file
@ -0,0 +1,79 @@
|
||||
// Filename: guiManager.cxx
|
||||
// Created by: cary (25Oct00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "guiManager.h"
|
||||
|
||||
#include <dataRelation.h>
|
||||
#include <renderRelation.h>
|
||||
#include <depthTestTransition.h>
|
||||
#include <depthWriteTransition.h>
|
||||
#include <materialTransition.h>
|
||||
#include <cullFaceTransition.h>
|
||||
#include <lightTransition.h>
|
||||
#include <frustum.h>
|
||||
#include <orthoProjection.h>
|
||||
|
||||
GuiManager::GuiMap* GuiManager::_map = (GuiManager::GuiMap*)0L;
|
||||
|
||||
GuiManager* GuiManager::get_ptr(GraphicsWindow* w, MouseAndKeyboard* mak) {
|
||||
GuiManager* ret;
|
||||
if (_map == (GuiMap*)0L)
|
||||
_map = new GuiMap;
|
||||
GuiMap::const_iterator gi;
|
||||
gi = _map->find(w);
|
||||
if (gi != _map->end())
|
||||
ret = (*gi).second;
|
||||
else {
|
||||
// going to allocate a new GuiManager for this window
|
||||
// first see if there is a mouseWatcher already under the MouseAndKeyboard
|
||||
bool has_watcher = false;
|
||||
TypeHandle dgt = DataRelation::get_class_type();
|
||||
MouseWatcher* watcher;
|
||||
for (int i=0; i<mak->get_num_children(dgt); ++i)
|
||||
if (mak->get_child(dgt, i)->get_child()->get_type() ==
|
||||
MouseWatcher::get_class_type()) {
|
||||
has_watcher = true;
|
||||
watcher = DCAST(MouseWatcher, mak->get_child(dgt, i)->get_child());
|
||||
}
|
||||
if (!has_watcher) {
|
||||
// there isn't already a mousewatcher in the data graph, so we'll make
|
||||
// one and re-parent everything to it.
|
||||
watcher = new MouseWatcher("GUI watcher");
|
||||
DataRelation* tmp = new DataRelation(mak, watcher);
|
||||
for (int j=0; j<mak->get_num_children(dgt); ++j) {
|
||||
NodeRelation* rel = mak->get_child(dgt, j);
|
||||
if (rel != tmp)
|
||||
// it's not the node we just created, so reparent it to ours
|
||||
rel->change_parent(watcher);
|
||||
}
|
||||
}
|
||||
// next, create a 2d layer for the GUI stuff to live in.
|
||||
Node* root2d_top = new NamedNode("GUI_top");
|
||||
Node* root2d = new NamedNode("GUI");
|
||||
NodeRelation* root2d_arc = new RenderRelation(root2d_top, root2d);
|
||||
root2d_arc->set_transition(new DepthTestTransition(DepthTestProperty::M_none), 1);
|
||||
root2d_arc->set_transition(new DepthWriteTransition(DepthWriteTransition::off()), 1);
|
||||
root2d_arc->set_transition(new LightTransition(LightTransition::all_off()), 1);
|
||||
root2d_arc->set_transition(new MaterialTransition(MaterialTransition::off()), 1);
|
||||
root2d_arc->set_transition(new CullFaceTransition(CullFaceProperty::M_cull_none), 1);
|
||||
PT(Camera) cam = new Camera("GUI_cam");
|
||||
new RenderRelation(root2d, cam);
|
||||
cam->set_scene(root2d_top);
|
||||
Frustumf frust2d;
|
||||
frust2d.make_ortho_2D();
|
||||
cam->set_projection(OrthoProjection(frust2d));
|
||||
GraphicsChannel *chan = w->get_channel(0); // root/full-window channel
|
||||
nassertv(chan != (GraphicsChannel*)0L);
|
||||
GraphicsLayer *layer = chan->make_layer();
|
||||
nassertv(layer != (GraphicsLayer*)0L);
|
||||
DisplayRegion *dr = layer->make_display_region();
|
||||
nassertv(dr != (DisplayRegion*)0L);
|
||||
dr->set_camera(cam);
|
||||
// now make the manager for this window
|
||||
ret = new GuiManager(watcher, root2d);
|
||||
(*_map)[w] = ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
72
panda/src/testbed/gui_demo.cxx
Normal file
72
panda/src/testbed/gui_demo.cxx
Normal file
@ -0,0 +1,72 @@
|
||||
#include "framework.h"
|
||||
|
||||
#include <eventHandler.h>
|
||||
#include <chancfg.h>
|
||||
#include <string>
|
||||
#include <renderModeTransition.h>
|
||||
#include <colorTransition.h>
|
||||
#include <colorBlendTransition.h>
|
||||
#include <cullFaceTransition.h>
|
||||
#include <depthTestTransition.h>
|
||||
#include <depthWriteTransition.h>
|
||||
#include <textureTransition.h>
|
||||
#include <textureApplyTransition.h>
|
||||
#include <lightTransition.h>
|
||||
#include <materialTransition.h>
|
||||
#include <transformTransition.h>
|
||||
#include <transparencyTransition.h>
|
||||
#include <drawBoundsTransition.h>
|
||||
#include <pruneTransition.h>
|
||||
#include <get_rel_pos.h>
|
||||
#include <boundingSphere.h>
|
||||
#include <geomSphere.h>
|
||||
#include <geomNode.h>
|
||||
#include <notify.h>
|
||||
#include <directionalLight.h>
|
||||
#include <renderRelation.h>
|
||||
#include <camera.h>
|
||||
#include <frustum.h>
|
||||
#include <orthoProjection.h>
|
||||
#include <perspectiveProjection.h>
|
||||
#include <textNode.h>
|
||||
#include <shaderTransition.h>
|
||||
#include <colorMatrixTransition.h>
|
||||
#include <alphaTransformTransition.h>
|
||||
#include <lensFlareNode.h>
|
||||
#include <texture.h>
|
||||
#include <texturePool.h>
|
||||
#include <spotlight.h>
|
||||
#include <nodePath.h>
|
||||
#include <pta_Colorf.h>
|
||||
#include <pta_float.h>
|
||||
#include <pt_Node.h>
|
||||
|
||||
#include <guiManager.h>
|
||||
|
||||
//From framework
|
||||
extern PT(GeomNode) geomnode;
|
||||
extern RenderRelation* first_arc;
|
||||
|
||||
static void setup_gui(void) {
|
||||
GuiManager* mgr = GuiManager::get_ptr(main_win, mak);
|
||||
}
|
||||
|
||||
static void event_2(CPT_Event) {
|
||||
static bool is_setup = false;
|
||||
if (!is_setup) {
|
||||
setup_gui();
|
||||
is_setup = true;
|
||||
}
|
||||
}
|
||||
|
||||
void demo_keys(EventHandler&) {
|
||||
new RenderRelation( lights, dlight );
|
||||
have_dlight = true;
|
||||
|
||||
event_handler.add_hook("2", event_2);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
define_keys = &demo_keys;
|
||||
return framework_main(argc, argv);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user